CS 487 Networks Solutions for Homework # 3 By Elena Gabriela Barrantes-Sliesarieva ====================================================================== 2.18 BER=p Bit error rate = # bits in error out of an observed k bits sequence = (# bits in error) / (k bits) Notice that BER is different from the probability that a packet is damaged. It is the probability that a single bit gets damaged. So, what we need is the probability that a packet of n bits gets damaged. The packet won't get damaged only if neither of its bits gets damaged. So, p(packet free of damage) = (1-p)^n, from which follows that (*) p(packet is damaged) = 1 - (1-p)^n Now, I'll repeat the reasoning from homework # 2. p(success at packet transmission) = r p(success at ACK transmission) = s t = p(successful transmission) = p(success at packet transmission) * p(success at ACK transmission) = r * s p(failed transmission) = 1 - t = 1 - r*s or, equivalently, p(failed transmission) = p(success at packet transmission) * p(failure at ACK transmission) + p(failure at packet transmission) = r * (1 - s) + (1 - r) = 1 - r*s Now, p(delivering a packet in 1 attempt) = t p(delivering a packet in 2 attempts) = (1-t) * t ... p(delivering a packet in n attempts) = (1-t)^(n-1) * t Let X be the number of attempts needed to correctly deliver a packet. The average number of attempts is the expectancy of X: E(X) = 1 * t + 2 * (1-t)t + ... + n * (1-t)^(n-1) * t + ... which is the expectancy for a geometric distribution, so we know that E(X) = 1 / t for this particular exercise, we know that r = 1 - (1-p)^n (from (*) ), n being the number of bits in a packet. s = 1 (because there are no errors in the backward link), So: t = 1 - 1 * (1 - (1-p)^n = 1 - 1 + (1-p)^n = (1-p)^n & E(X) = 1/(1-p)^n // ====================================================================== 2.20 (a) Total propagation time (round trip) = [5 * 10 ^(-6) s/Km] * [10^4 Km] = 5 x 10^(-2) s Transmission time for a single packet = 10^3 b / (100 * 10^6 b/s) = 10^(-5) s Number of packets needed to fill the link = Total propagation time / Transm. time of a packet = [5 * 10^(-2) s] / [10^(-5) s] = 5 * 10^3 packets = 5000 packets (b) Minimum window size must be equal to round trip time (RTT). But here, we can obtain it directly, because we know that we can squeeze 5000 packets in the tound trip propagation delay, so we only need to add one packet at the start and one at the end, so W = 5002. Remember that RTT = packet transmission time + packet propagation delay + ack transmission time + ack propagation delay We are assuming that packets and ACK's are the same size. & w >= RTT/packet transmission time // ============================================================================ 2.21 (a) Window size ---------------- Let: X : packet size in bits R1 : transmission rate on the forward link in bits/second R2 : transmission rate on the backward link in bits/second ACK : ACK packet size in bits p : probability that a packet gets damaged on the forward link q : probability that a packet gets damaged on the backward link t : propagation delay (one way) W : size of the window in packets RTT : Round Trip Time X = 1000 * 8 bits = 8000 bits R1 = 10^7 b/s R2 = 30 * 10^3 b/s ACK = 40 bytes = 40 * 8 bits = 320 bits p = 0 q = 0.05 t = 1 * 10^(-3) sec packet transmission time = X/R1 = 8000/10,000,000 = 0.0008 RTT = X/R1 + t + ACK/R2 + t = (8000/10^7) + 10^(-3) + (320/30000) + 10^(-3) =~ 0.0134 sec For "optimal" window size: w >= RTT/(X/R1) = 0.0134 / 0.0008 =~ 16.833 So we take w to be 17. --------------------- (b) Average throughput ---------------------- For Go Back N or Selective Repeat, this is NOT a trivial question, as it must be clear for anybody. Here is what we are looking for: Throughput = (R/X) * Efficiency, that is, of the total number of packets the system is able to deliver at the given rate (R/X), is the percentage that gets really delivered and is not wasted in retransmissions, overhead, etc. So actually, the problem comes down to the basic question of how to calculate the efficiency in this case. What is the efficiency? Is the percentage of time we are doing useful work: if k is the number of packets successfuly delivered during an interval of time T, the efficiency is: (**) k * (X/R) / T However, notice that it is not easy at all to pin down a consistent number of packets during an interval, as it will change because of the specific packets that get lost, or retransmitted unnecesarily, etc. Sometimes we will be able to send the whole window, sometimes a window and 3 packets, sometimes half window, and so on. So, what we can do is oversimplify the problem and use the regenerative method to calculate the average time to deliver one packet (slide the window one position): Let n be the state of the system at some given moment (k packets in the window). Let n+1 be the state of the system after a s~uccessful one-packet transmission (window slides one position). Notice that we need only X/R time to transition from state n to n+1, because if the pipeline is full (and we are looking at the system at any arbitrary moment in time), then the ACK for that packet will be received just after we have finished sending the packet. Actually this is not true. Sometimes we will have to wait almost until the end of the timeout to receive the ACK. Sometimes we will not transition to state n+1 but to state n+s, because Go Back N allows accumulative ACK's, etc. But let's stick with the standard analysis. (1-r, X/R) |---------------| | \/ ---> [n] <- [n+1] ---->... | | |____| (r, timeout) Let r be the cumulative probability that a packet or its ACK get lost. With probability r, we are just back where we started, in state n, after waiting timeout time. Timeot is usually taken to be equal to RTT. With probability (1-r), we slide the window one position, in time X/R. So, what we need to know is the average time it will take us to slide the window one position, If t is the time for a one position sliding, then: E(t) = r * (timeout + E(t)) + (1-r)* (X/R1) (this is using the regenerative method to calculate the expectancy) r = p(packet gets lost) + p(packet travels successfully) * p(ack gets lost) = 0 + 1 * 0.05 = 0.05 Using timeout = W * (X/R1) = 17 * 0.0008 = 0.0136 E(t) = 0.05 * ( 0.0136 sec + E(t) ) + 0.95 * 0.0008 = 0.00068 + 0.00076 E(t) = 0.00144/0.95 = 0.0015 Now that we have an expression for the expected time it takes to deliver successfully one packet, we rewrite (**) as: Efficiency = 1 * (X/R1) / E(t) = 0.0008 / 0.0015 =~ 0.53 So, the throughput is: (R1/X) * Efficiency = (10^7 / 8000) * 0.53 = 662.5 // Of course, if you found any Go Back N efficiency calculation in any networks textbook, you could have used it (this one, for example, is used in "Data Networks" by Walrand (1991). There is another one in Tanenbaum (1996) and yet anoter one in Bertsekas & Gallagher (1992). All authors use different methods to approximate GBN's efficiency). =========================================================================== 2.22 This is simply a paraphrasing in abstract of 2.21. Using the same approximation, we get: Efficiency = (X/R) / E(t) = (X/R) / [X/R * (1 + W * p / (1-p) )] [using timeout = W * X/R] = 1 / [1 + W*p/(1-p) ] It evidently depends on window size W (N in the text). The larger the window, the less efficiency we obtain. However, if the window were less than optimal, then we will be loosing efficiency for not transmitting while the ACK's are still in transit. ============================================================================ 2.23 The most important part here was to realize that Selective Repeat with infinite window size is logically equivalent to Stop & Wait at each slot. Also it is important to notice that we are dealing with Bit Error Rate again, instead of direct packet loss probability. (a) (1 - p)^(d+h) (b) (1 - p)^(d+h) * (1 - q)^a (c) E(t) = 1/[(1 - p)^(d+h) * (1 - q)^a] (d) Efficiency = (time to transmit d data bits) / (time to transmit average number of bits before a successful ACK) = (d/R) / [E(t)*(d+h+a)/R] (ignoring propagation and processing delays) = d / (E(t)*(d+h+a)) = d / [(1/[(1 - p)^(d+h) * (1 - q)^a]) * (d+h+a)] = d * [(1 - p)^(d+h) * (1 - q)^a] / (d+h+a) (d) Of course this beautiful analysis could never be used with standard Selective Repeat, because after a window has been sent, we have to wait for ACK's and all kind of awful things start happening depending on WHICH slots get ACK'd and which ones don't, and how the window slides, etc. In fact, the efficiency analysis for real Selective Repeat is even worse than for Go Back N. ============================================================================== 6. General case solution: --------------------- Assuming that p = 0, the efficiency of stop and wait is packet transmission time / Round trip time We want this to be higher than 50%. Let: X : packet size in bits R : transmission rate in b/s t : propagation delay ACK : ack packet size First, let's assume that ACK's and packets have the same size: [X/R] / [2 * X/R + 2 * t] >= 0.5 [X/R] >= 0.5 * 2 * [X/R + t] X >= X + Rt 0 >= Rt What does this mean? What we already know: that if packets and ACK's are equal, the very best case we can hope for, is that with a negligible propagation delay, we will get AT MOST a 50% efficiency. (Actually this is obvious from the first line of the inequation). So, in order to get a better than 50% efficiency, we must decrease the ACK size. Let's use ACK's with size 1 bit (the ABP bit only). So now, our inequation looks like this: (***) [X/R] / [X/R + 2 * t + 1/R] >= 0.5 X /R >= [ (0.5 * X/R) + (10^(-3)) + (0.5 * 1/R)] X >= 0.5 * X + (4 * 10^3) * (10^(-3)) + 0.5 0.5 * X >= 4 + 0.5 X >= 4.5/0.5 = 9 bits So, that's the lower limit of the packet size under that ACK assumption. In fact, we can deduce a general expression for a given ACK size: X >= 8 + ACK (ACK is the size of the ACK packet in bits) Another solution: ----------------- Assume ACKs are piggybacked in the reverse link, so they don't have independent packets, and we can assume their transmission time is 0. Now (***) changes to: [X/R] / [X/R + 2 * t] >= 0.5 (X/R) >= 0.5*(X/R) + t 0.5 * X/R >= t X >= R * t / 0.5 = 4000 * 0.02 / 0.5 = 160 ===================================================================== 7. The throughput is the number of packets that the system can successfully absorb in a given amount of time. The very general formula for this is (1) Throughput = Efficiency * [Channel Rate / Packet size] Assuming no errors, the efficiency for any window size less than --------- the optimal will be ----------- (2) Efficiency = (Packet transmission time * window size) / (Round trip delay) >From the optimal window size and up, the efficiency will be 1 (because -------------------------- -------------------- we are assuming that there are no errors). So, the first thing is to calculate the optimal window size: Let X, R, ACK and t be as in exercise 6. Let w be the window size, and RTT be the Round Trip Time. (3) RTT = (X/R + t + ACK/R + t) (4) X/R * w >= RTT Calculating RTT from (3): ------------------------ X/R = (512 * 8) / (64000) = 0.064 s 2 * t = 0.5 s (Here we are using the round trip propagation delay for geostationary satellites: you could have used another figure if it were a LEO or MEO satellite. However, the very low (64 K) channel rate suggested that it was a traditional geostationary thing) ACK/R =~ 0 (from the assumptions: we will use 0 to simplify things) RTT = 0.564 s Now, using it to calculate the optimal window size from (4): ----------------------------------------------------------- w >= 0.564 / 0.064 = 8.8125, so we must pick w = 9 at least. This means that for window sizes 1 & 7 we will have to calculate (2) first, and then apply it to 1 to get the answer. For window sizes 15 & 127 the answer will be exactly the same: Channel rate / packet size, given that the efficiency will be 1. So: Packet transmission time = X/R = 0.064 s Round trip delay = RTT = 0.564 s Maximum throughput = Channel rate / packet transmission time = 64000 b/s / (512 * 8) b/packet = 15.625 packets/sec Window size 1: ------------- Efficiency = 1 * 0.064 / 0.564 =~ 0.11 Throughput = 15.625 * 0.11 = 1.71 packets /sec Window size 7: ------------- Efficiency = 7 * 0.064/ 0.564 =~ 0.79 Throughput = 15.625 * 0.79 = 12.41 packets/sec Window size 15: -------------- Efficiency = 1 Throughput = 15.625 packets/sec Window size 127: --------------- Efficiency = 1 Throughput = 15.625 packets/sec [IMPORTANT NOTE: Throughput can also be expressed directly as a data rate, so you could have used R instead of R/X in the throughput formulas] ====================================================================== 8. OK, here we had two possiblities: the original question was to prove that Selective Repeat needed to use a modulo 2w at least in order to be consistent, and the modification was to prove that Go Back N needed to operate on modulo w+1 at least. You can find a very neat, very formal, proof of both in "Data Networks" (Bertsekas & Gallagher 1992), but what was important at this level was for you to notice the ambiguity cases. I will pose an example for both. Selective Repeat ================ Suppose you are using a window of size 3, with modulo 5. Assume you want to send packets 9,10,11,12,13,14 You send packets 9,10,11 with sequence numbers 0, 1 & 2, and they arrive correctly at the receiver. Receiver passes them to the network layer (packets 9,10, 11) and then slides its window. Now it is expecting packets with SEQUENCE NUMBERS 3,4,0 (because we are using modulo 5). Logically it is expecting packets 12,13,14. All ACK's get lost, so the sender times out, and resends packets 9,10,11 with sequence numbers 0, 1 & 2 (obviously). Now, the receiver will (quite incorrectly) accept packet 0 because it believes it to be a NEW packet when it actually is a retransmission from the last serie. It inserts this packet (9) at the network layer propagating the error to upper layers, and worse, it slides, without having never received real packet 12! You can see that the problem is that the sender's and receiver's frames of reference intersect in one packet, creating ambiguity, as the sender has no way of telling the receiver that this packets belong to a retransmission. The solution is to separate them completely. Given that the sender has a buffer of size w, and the receiver ALSO has a buffer of size w, to avoid this kind of problems we need to have AT LEAST 2w different sequence numbers. Go Back N ========= Suppose we have a window size 3, and use modulo 3. We send packets 9,10,11 with sequence numbers 0,1,2. They all arrive correctly at the receiver and are passed to the network layer. The receiver is now expecting logical packet 12, but in terms of sequence numbers it is expecting packet 0 (because of the modulo) All ACK's get lost. Sender times out and resends packets 9,10,11 with sequence numbers 0,1,2. Now, the receiver gets packet 0, and ACCEPTS it because it has no way to know it's a retransmission and it was expecting packet number 0. Again, we insert packet 9 in the network layer, and never receive packet 12, and from then on, everything is incorrect. What happened? Again, frame of reference intersection. However, because here the buffer at the receiver is size 1, we need a total w+1 different numbers to avoid this situation.