CS 533 - HOMEWORK 2 SOLUTION Page 1 ---------------------------- Version 7, Mar 4, 2004 Problem 1 (0 Points) --------- This is Problem 41, Chapter 2 in the Peterson text. The details of the calculation will not be published per request of the publisher. However, they will be given in class. Below is a typical worst-case configuration (R: Repeater, T: Transceiver, H: Host). coaxial cable =T=======================================T= | | | drop (transceiver) cable | drop | | R R | | | drop | drop | | -T------T-- link cable --T-------T- link | | | drop | drop | | H H Figure 13-4 at http://www.ethermanage.com/ethernet/ch13-ora/ch13.html shows a similar but more modern configuration. In that diagram, the M stands for MAU (Media Attachment Unit) and is a transceiver. The above URL provides a much more detailed set of rules for calculating RTTs. Our calculations are based on a simpler but similar model. [ The complete solution will be presented in class. ] Problem 2 (0 Points) --------- a) A collides with B with certainty in round 1. b) Let the first attempt be attempt (round) round 1. Note that the round number is the backoff count B after incrementing. Initially, B=0 when the two hosts attempt to transmit the first time. A collision occurs; B is incremented to 1; the hosts pick a random (equiprobable) W between 0 and 1; and defer for W slot times. Each time there is a successive collision, the range of W doubles. If the first station to be sucessful occurs in attempt k, then we know that there were collisions in all previous attempts and that both stations picked the same defer time. Attempt 1 is a failure. In attempt 2 For example, in round 1, both stations pick 0 or 1 with equal probability: Case A B Probability Comment --------------------------------------------------------------- a 0 0 0.25 Collide in round 2 b 0 1 0.25 A successful in round 2 B successful in round 3 c 1 0 0.25 B successful in round 2 A successful in round 3 d 1 1 0.25 Collide in round 2 This continues with the number of possible W values doubling after each collision. So, cases a and d lead to a collision in round 2, and the probability that there is a collision in round 2 is 0.5 = 0.25+0.25. c) In attempt k, the range of values are the integers 0, 1, ... , 2^k-1. The probability of W having each of these values is 1/2^k. Note that the stations will succeed in consecutive rounds after a number of collisons. If the first station succeeds in attempt k, both stations collided k-1 times, then picked different W values for attempt k, and succeed in attempts k and k+1. Let P_k be the probability of a collision in attempt k, k=0,1,2,.... Since there are 2^k possible cases that both stations pick the same W out of 2^{2k} possible combinations of W's, 1 P_k = ------- , k=1,2,... [12] 2^{k-1} In order for the contention to end in attempt k, there must have been k-1 collisions followed by no collision (the stations pick different W-values). This occurs with probability: Pr [ Succeed in attempt k ] = P_0 P_1 ... P_{k-1} (1 - P_k) 1 1 = ------------------------- (1 - -------) 1 x 2 x 4 x ... x 2^{k-2} 2^{k-1} 2^{k-1} - 1 = -----------, k = 1, 2, ... [13] 2^K where K = k(k-1)/2. Note that for k=1, the probability is 0 as expected. We can rewrite [13] as: Pr [ Succeed in attempt k ] = F(k-1) - F(k) [14] where 1 1 F(n) = --------------------- = ---, n = 1, 2, ... 1 x 2 x 4 x ... x 2^n 2^N = 1, n = 0 where N = n(n-1)/2. Note that this is the probability that there were k-1 collisions before succeeding since the collisions occur in rounds 0, 1, 2, ... , (k-1); i.e., Pr [ k collisions before 1 node is successful ] = Pr [ Succeed in attempt k+1 ], k = 0, 1, 2, ... 2^k - 1 = ------------, k = 0, 1, 2, ... 2^{k(k+1)/2} d) We seek the expectation E[Z] where Z has the probability distribution in [14]: E[Z] = Sum [ k=1..Inf : k x Pr[ Succeed in attempt t ] ] = Sum [ k=1..Inf : k x (F(k-1) - F(k)) ] for k = 1, 2, .... Since F(k-1) = F(k) 2^{k-1}, E[Z] = Sum [ k=1..Inf : k x F(k) x (2^{k-1} - 1) ] This expression quickly converges to 2.64 by the sixth term; i.e., on average, we expect to successfully transmit both packets after 1.64 collisions. Problem 3 (0 Points) --------- This problem is Problem 25, Chapter 2 in the Peterson text, and its solution is in the back of the book. a) The 2-way propagation delay will be 0.2 sec (= 2 x 3 x 10^4 km / 3 x 10^8 m/sec). The transmission time of a 1 KB frame is 8 x 1024 bits / 1 Mbps = 8192 usec or 8.192 msec. The bandwidth-delay product is about 0.2 megabits (= 1 Mbps x 0.2 sec) or about 25 frames (= 0.2 Mb / (8 x 1024)). So, the sender's window size should be W = 25 frames. When W' = 1, the sequence number set needs to have W+1 numbers or 26; i.e., the set should be {0, 1, ... , 25}. b) Since now W' = W = 25, we need 2W = 50 numbers; i.e., the set should be {0, 1, ... , 49}. Problem 4 (0 Points) --------- This problem is Problem 32, Chapter 2 in the Peterson text, and its solution is in the back of the book. The explanation below uses a different representation. a) In the diagram below, the symbols should be interpreted as follows: +++++ Frame propagation @@@@@ ACK propagation (+ has precedence over @ when both occupy the same point) An ACK n (i.e., the receiver wants sequence number n next) * Marks the sequence number that was last transmitted ** Marks the sequence number that was last transmitted AND it was a retransmission -n- The receiver accepted a frame with sequence number n -Dn- The receiver rejected (dropped) a frame with sequence number n The vertically alligned integers indicate the sequence number of the buffered frames. I assume that frames are delivered to the user as soon as possible and the propagation time dominates the transmission time. In fact, the diagrams depict the situation when W = 4 is insufficient to fill the pipe. User: 0 1,2,3,4 ^ 2 ^ | 2 3 | | 2 3 4 | A1 A1 A1 A1 A5 Rcvr ----------------0-------2---3----------------4-------------------------------1 + @ + + @ + @ + + + + @ @ + @ + + + + @ @ + @ + + X + + @ @ + @ + + + + + @ + @ @ + + + + + @ + @ @ @ + Sndr --+---+---+---+---------------+-------@---@----------------@---+------- 0* 1* 2* 3* 4* 4 0 1 2 3 3 0 1 2 2 0 1 1** |<------------------------------------------------------>| timeout 2 x RTT b) User: 0 1,2,3,4 ^ 2 ^ | 2 3 | | 2 3 4 | A1 A1 A1 A1 A5 Rcvr ----------------0-------2---3----------------4------1------------------ + @ + + @ + + @ + + + @ @ + + @ + + + @ @ + + @ + X + + @ @ + + @ + + + + @ + @ + @ + + + + + @ + @ + @ + Sndr --+---+---+---+---------------+-------+---@-----------------------+---+ 0* 1* 2* 3* 4* 4 5* 6* 0 1 2 3 3 5 0 1 2 2 0 1 1** |<------------------------->| 1 RTT c) The approach in Part b improves the throughput in the example scenario by about a factor of 3/2. Let T be the transmission time of a single frame. Then, in Part a it takes 3 x RTT + T to transmit 5 frames. In Part b, it takes 2 x RTT + 2T to transmit the same 5 frames. So, the improvement is (3 x RTT + T)/(2 x RTT + 2T) ~= 3/2 when RTT >> T. d) 0 ^ 2 | 2 3 | 2 3 4 A1 A1 A1 A1 Rcvr ----------------0-------2---3----------------4------------------------- + @ + + @ + @ + + + @ @ + @ + + + @ @ + @ + X + + @ @ + @ + + + + @ + @ + + + + + + @ + @ @ + + Sndr --+---+---+---+---------------+-------@---@----------------@---+---+---+ 0* 1* 2* 3* 4* 4** 0 1 2 3 3** 0 1 2 2** 0 1 1** |<------------------------------------------------------>| 2 x RTT The throughput actually decreases because bandwidth is consumed by retransmitting frames that have already been buffered at the receiver. Problem 5 (6 Points) --------- a) The slot time is function of the maximum distance between the two furthest stations and is therefore independent of the network bandwidth. Slot Time = 2 x D_max / c' = 20,000/200 usec = 100 usec b) We want to solve for L, the packet length in bits, such that: Slot Time = L/R for R = 10 Mbps, 100 Mbps, and 1 Gbps, and then round up to the nearest quantity such that L/8 is evenly divisible by 4. L = R x 100 usec So, R L (bits) L (bytes) Min Pkt Length (bytes) ---------------------------------------------------------------------- 10 Mbps 1,000 125 128 100 Mbps 10,000 1,250 1,252 1 Gbps 100,000 12,500 12,500 c) R = 10 Mbps: *** I probably should have used the adjusted pkt size of 128 bytes. F (bytes) max(S,F)+I+P (bytes) e ----------------------------------------------------- 16 145 = max(125,16)+12+8 0.110 64 145 = max(125,64)+12+8 0.440 256 276 = max(125,256)+12+8 0.928 1024 1044 = max(125,1024)+12+8 0.981 4096 4116 = max(125,4096)+12+8 0.955 d) R = 100 Mbps: *** I probably should have used the adjusted pkt size of 12,500 bytes. F (bytes) max(S,F)+I+P (bytes) e ----------------------------------------------------- 16 1270 = max(1250,16)+12+8 0.013 64 1270 = max(1250,64)+12+8 0.050 256 1270 = max(1250,256)+12+8 0.202 1024 1270 = max(1250,1024)+12+8 0.806 4096 4116 = max(1250,4096)+12+8 0.995 e) R = 1 Gbps: *** I probably should have used the adjusted pkt size of 1252 bytes. F (bytes) max(S,F)+I+P (bytes) e ------------------------------------------------------- 16 12520 = max(12500,16)+12+8 0.001 64 12520 = max(12500,64)+12+8 0.005 256 12520 = max(12500,256)+12+8 0.020 1024 12520 = max(12500,1024)+12+8 0.082 4096 12520 = max(12500,4096)+12+8 0.327 What Parts c-e show is that the efficiency drops with increasing transmission rate. f) We must decrease the slot time (expressed in bit times) in order to increase the efficiency; i.e., we need a slot time that is equivalent to the transmission of 125 bytes. For rates of 100 Mbps and 1 Gbps, the slot times will be 1,000/100 usec and 1,000/1,000 usec respectively. These two times correspond to propagation delays over maximum one-way distances of 1,000 meters and 100 meters respectively. Problem 6 (6 Points) --------- [ The solution will be presented in class. ] Problem 7 (4 Points) --------- [ The solution will be presented in class. ] Problem 8 (4 Points) --------- [ The solution will be presented in class. ] Problem 9 (8 Points) --------- [ No code will be provided. ]