This problem is related to the idea of exponential backoff, whichis part of the
ID: 3616241 • Letter: T
Question
This problem is related to the idea of exponential backoff, whichis part of the ethernet protocol.We have a large number of computers sharing a communicationschannel, and n of them have a packet of data to send. Time isdivided into intervals t0,t1,. . .. Any one packet can be sent in a single time interval, but iftwo or more packets are sent during the same interval ti thepackets collide, and none of them is successfully transmitted. Thecomputers can only detect whether their packet is successfullytransmitted or not; they do not otherwise communicate with any ofthe other computers, and they do not know n or the total number ofcomputers on the channel.
The computers use the following protocol. They all try to transmitat t1;assuming n > 1 there will be a collision. We call this roundzero. In round 1, each computer then chooses randomly whether totransmit during either t2 ort3.If it fails again to transmit, it continues to round 2. In general,if a computer fails at time ti, 2k i < 2k+1 forsome integer k, it picks a new time tj atrandom, from the range 2k+1 j < 2k+2,and tries again at tj .The process continues until all of the n computers succeed intransmitting their packets. Give the best upper bound you can onthe number of rounds which will be required for every computer totransmit its message.
Explanation / Answer
boolean shouldRetry = true;int retries = 0;do {try {/* Submit request */if (status == HttpStatus.SC_OK) {shouldRetry = false;/* Process successful response from DB */} else {if (status == HttpStatus.SC_INTERNAL_SERVER_ERROR|| status == HttpStatus.SC_SERVICE_UNAVAILABLE) {shouldRetry = true;long delay = (long) (Math.random() * (Math.pow(4, retries++) * 100L));try {Thread.sleep(delay);} catch (InterruptedException iex){log.error("Caught InterruptedException exception", iex);}} else {shouldRetry = false;/* Process 4xx (Client) error */}}} catch (IOException ioe) {log.error("Caught IOException exception", ioe);} catch (Exception e) {log.error("Caught Exception", e);} finally {/* Perform clean-up as necessary */}} while (shouldRetry && retriesRelated Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.