Docsity

Go-Back-N and Selective Repeat: Efficiency and Window Size - Prof. Rudra Dutta, Assignments of Computer Systems Networking and Telecommunications

Toggle sidebar
bg1
Homework 4 – Solution Guidelines
1. (a) The string becomes the following string; stuffed zeros have been underlined.
01111011111001111101011111011111011111010010
(b) “Copy bits as received into the frame. If the last 6 bits to be seen were ‘015’,
then discard the next bit if it is a ‘0’, otherwise copy as usual. If the last 8 bits to
be copied were ‘0160’, recognize it as a frame-delimiting FLAG.”
Note: In the stuffing above, we have specified the stuffing rule as “if you just transm itted ‘015’,
then stuff a ‘0’ ” – this leads above to the last two zeros being stuffed even though they did not
come after ‘015’ in the input string. Clearly, an alternative exists here – we could eliminate th ese
zeros and only stuff when the ‘015’ occurred in the input string. You can verify for yourself that
the destuffing would work correctly if we changed the word “seen” to “copied” in the destuffing
rule. However, th is would partly offset the utility of the FLAG byte. Imagine a receiver which
has lost frame synchronization and is hunting for a FLAG byte to start copying fra mes again. If
we used the stuffing rule as explained in this note, then the receiver would wrongly resynchronize.
If we use the rule as in the answer g iven (as is usually done), then this will never occur because
the FLAG byte never occurs in the transmitted data except when it really indicates the FLAG.
(c) You can verify for yourself that the destuffing works.
(d) This rule would not work. Certainly, it would keep the receiver from
mistakenly finding FLAG bytes; either the data bits would be transmitted as
‘…0111111111…”, or the input string consisted of ‘…0150…’. However, the
receiver would have no way of distinguishing stuffed zeros unambiguously, if it
received the string ‘…015010…’ – the underlined zero may be the result of
stuffing ‘…0160…’, but equally well the input string might have been
‘…015010…’ to start with (and not been stuffed). The key observation is that the
‘0’ bit must be stuffed whether the ‘015’ is followed by a ‘1’ or not.
2. Denoting the sender’s window by (Sl, Su), the receiver’s window by (Rl, Ru), and
the window size by W, we must have the three conditions stated below. With
respect to the first condition, the first form makes more sense when we assume
that frames are always available from the network layer to send, so there is no
reason for the sender’s window to be less than W frames. The second form is
applicable when the network layer may not provide frames to receive for a certain
period, so Su cannot grow beyond the last frame actually supplied by the network
layer. The second condition simply states that the receiver is always ready to
receive any frame within its reception window; the window size is 1 if the
receiver does not buffere frames (GoBackN), or W if it does (Selective Repeat).
The last condition is the interesting one: the first half says that the sender must not
purge a frame from its buffer that the receiver has not yet received (and hence
could need to be retransmitted), and the latter half says that the receiver should
not believe itself to have received a frame that the sender has not yet sent even
once.
1. Su – Sl + 1 = W, OR 0 <= Su – Sl + 1 <= W
2. Ru – Rl + 1 = 0, OR Ru – Rl + 1 = 0
3. Sl <= Rl <= Su + 1
pf3
pf4
pf5
pf8

Partial preview of the text

Download Go-Back-N and Selective Repeat: Efficiency and Window Size - Prof. Rudra Dutta and more Assignments Computer Systems Networking and Telecommunications in PDF only on Docsity!

Homework 4 – Solution Guidelines

  1. (a) The string becomes the following string; stuffed zeros have been underlined. 01111011111001111101011111011111011111010010 (b) “Copy bits as received into the frame. If the last 6 bits to be seen were ‘01^5 ’, then discard the next bit if it is a ‘0’, otherwise copy as usual. If the last 8 bits to be copied were ‘01^6 0’, recognize it as a frame-delimiting FLAG.” Note: In the stuffing above, we have specified the stuffing rule as “if you just transmitted ‘01^5 ’, then stuff a ‘0’ ” – this leads above to the last two zeros being stuffed even though they did not come after ‘01^5 ’ in the input string. Clearly, an alternative exists here – we could eliminate these zeros and only stuff when the ‘01^5 ’ occurred in the input string. You can verify for yourself that the destuffing would work correctly if we changed the word “seen” to “copied” in the destuffing rule. However, this would partly offset the utility of the FLAG byte. Imagine a receiver which has lost frame synchronization and is hunting for a FLAG byte to start copying frames again. If we used the stuffing rule as explained in this note, then the receiver would wrongly resynchronize. If we use the rule as in the answer given (as is usually done), then this will never occur because the FLAG byte never occurs in the transmitted data except when it really indicates the FLAG. (c) You can verify for yourself that the destuffing works. (d) This rule would not work. Certainly, it would keep the receiver from mistakenly finding FLAG bytes; either the data bits would be transmitted as ‘…0111111111…”, or the input string consisted of ‘…01^5 0…’. However, the receiver would have no way of distinguishing stuffed zeros unambiguously, if it received the string ‘…01^50 10…’ – the underlined zero may be the result of stuffing ‘…01^6 0…’, but equally well the input string might have been ‘…01^50 10…’ to start with (and not been stuffed). The key observation is that the ‘0’ bit must be stuffed whether the ‘01^5 ’ is followed by a ‘1’ or not.
  2. Denoting the sender’s window by (Sl, Su), the receiver’s window by (Rl, Ru), and the window size by W, we must have the three conditions stated below. With respect to the first condition, the first form makes more sense when we assume that frames are always available from the network layer to send, so there is no reason for the sender’s window to be less than W frames. The second form is applicable when the network layer may not provide frames to receive for a certain period, so Su cannot grow beyond the last frame actually supplied by the network layer. The second condition simply states that the receiver is always ready to receive any frame within its reception window; the window size is 1 if the receiver does not buffere frames (GoBackN), or W if it does (Selective Repeat). The last condition is the interesting one: the first half says that the sender must not purge a frame from its buffer that the receiver has not yet received (and hence could need to be retransmitted), and the latter half says that the receiver should not believe itself to have received a frame that the sender has not yet sent even once. 1. Su – Sl + 1 = W, OR 0 <= Su – Sl + 1 <= W 2. Ru – Rl + 1 = 0, OR Ru – Rl + 1 = 0 3. Sl <= Rl <= Su + 1
  1. (a) Protocol 4 is equivalent to Stop-and-Wait with ABP, except that we did not consider piggybacking on a bidirectional link in class. Protocols 1 and 2 do not have sequence numbers, and Protocol 3 uses no sequence numbers on the ACK, and is therefore like the simple Stop-and-Wait we discussed in the lecture. (b) Protocol 5 is closest to GoBackN. Other than the bidirectional character, Protocol 5 also considers the situation that there may be no frames to send. For GoBackN we assumed there is always data waiting to be sent. (c) Protocol 6 is closest to Selective Repeat, again with same differences.
  2. (a) The timeout from the end of the packet transmission time would be twice the propagation delay, that is 0.7 s. (b) The error-free efficiency of GBN is 100% when the window is sufficiently large so that the sender can continue to send unacknowledged packets while the acknowledgment for a transmitted packet comes back. That is, we must have Wτ / S >= 1. In this case, τ = 10^3 /10^6 , S = ρ + τ + ρ = 0.35 + 10^3 /10^6 + 0.35. Thus the minimum value of W is 701. (c) Since the round trip time (twice propagation delay) is quite large compared to the transmission delay, it would make sense to try to transmit more frames during that time by using GBN rather than Stop-and-Wait. Unless the error rate was really high, it would achieve somewhat the better efficiency of the two. With such a large ratio between propagation delay and transmission delay, error correction would be a sensible choice if available.
  3. (a) The timeout from the end of the packet transmission time would be twice the propagation delay, that is 2 * 10-^5 s. The timeout from the beginning would be this plus the transmission time, or 9.29 * 10-^4 s. Big difference this time! (b) As before, we must have Wτ / S >= 1. In this case, τ = 10^4 /(1.1 * 10^7 ), S = 10-^5
    • 10^4 /(1.1 * 10^7 ) + 10-^5. Thus the minimum value of W is 2. (c) Since the round trip time (twice propagation delay) is very small compared to the transmission delay, it is hardly worth the complication of using GBN rather than Stop-and-Wait. The best GBN could achieve would be to snip out the 20 μs delay in roughly every 1 ms. Also, with the penalty of retransmission being only the same 20 μs, the added overhead of error correction might not be deemed necessary. To an extent, it will depend on the strength versus the bitrate overhead of the error correction code to be used.
  4. The analysis is exactly like SWP. Provided enough traffic always exists at the sender (an assumption we always make), in the absence of error a new packet is transmitted every τ units of time (for SWP this was τ + T, because we had to wait for the acknowledgment for the successful transmission to be completed, and we simplified by assuming that an acknowledgment always arrives, if at all, at the last possible instant). However, if a packet has an error (with probability 1- p ), it will be retransmitted T time later again. We assume realistically that the T time units are counted from the end of the packet transmission, not the beginning. In the meantime many later packets have been transmitted, but this does not matter, since they will need to be retransmitted. This retransmitted packet has the same

The time axis was broken into two segments for formatting requirements. When you draw them, you should take advantage of the flexibility of hand-drawing to present them continuously. (c) The timeout would be less than the minimum possible time in which the ACK could possibly come back for a frame. Thus every frame would timeout and be retransmitted at least once. This could cause other undesirable effects if (as in realistic protocols) the behavior of the protocol is different for normal and retransmitting modes.

  1. As noted in the homework, this is a trick question! If the SRP window is 5 frames long, how can frame 3 be transmitted a second time, far less lost at that transmission? You can make it work by assuming the acknowledgment for frame 3 is lost the first time, but (i) it would not change the time frame 3 is correctly received, and (ii) the question specifically says no ACKs are lost. You could also assume that the frame must have been lost the first time (again specifically contradicting the question), or you could just draw the timing diagram until the first (and successful) transmission of frame 3. The best way is to point out that it cannot happen and ignore it thereafter. It does not much matter what you do. Basically this one is to see if you are awake or not.
  2. (a) The timing diagram is as follows. 0 1 2 3 4 5 10 15 20 0 1 2 3 4 5 10 15 20 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 8 20 21 22 23 24 25 30 20 21 22 23 24 25 30 7 3 4 5 6 T 7 A

(b) Curiously enough, in this artificially created scenario, frame 8 never gets through! As can be seen from the diagram above, the second transmission of frame 8 is the 16th^ attempt at transmission by the sender, and therefore fails again. Thus the situation recurs, and the communication completely stalls after 7 frames.

  1. We make the usual assumption that packets are always available for transmission. We argue two boundary conditions: (1) At time t , the smallest packet number not yet acknowledged is Lmin , so Lmin - 1 has been acknowledged. This acknowledgment was carried on a packet transmitted by the receiver to the sender, which must have taken at least τmin time to transmit and ρ time to propagate to the sender. Thus the receiver cannot have sent this packet any later than t r1 = t - τmin - ρ, otherwise it would not have reached the sender by t. Starting from the time the receiver decided to acknowledge packet Lmin - 1, it was expecting packet Lmin , thus the expected reception number R must have been Lmin or more at all times after time t r1. (It may be more because the receiver may have received later packets for which the sender may not yet have received the ACK, or the ACKs may be lost.) (2) Similarly, at time t , the last packet sent is Lmax - 1. The expected reception number will not become Lmax +1 until the packet Lmax is received correctly. Even if the packet Lmax is sent the instant after time t , it is a minimum sized packet and is received correctly the first time, it cannot be received at the receiver until t r2 = t
    • τmin + ρ. Thus the reception number at the receiver is Lmax or less for all times earlier than t r2. Putting these two arguments together, the desired result is obtained.
  2. (a) If packet L is completely received at time t 1 , the sender must have started the transmission at time t 0 = t 1 – τ – ρ, and at this time the sender’s window must have included the packet L. Therefore at least packet L-W must have been acknowledged at time t 0. Thus at all times following t 0 (therefore also t 1 ) the earliest packet that the receiver might have been waiting for is L-W+1. (b) Since a NAK is not used, when the receiver is expecting packet L 1 and the sender transmits the entire window, the receiver will continue to expect L 1 and not send any acknowledgments iff the frame L 1 is lost in transmission. The earlier frames in the window do not matter, since they are duplicates of previously accepted frames. (Indeed, with the condition that no ACKs are lost, accepted frames will never be retransmitted.) The later frames do not matter if frame L 1 is lost. If frame L 1 is not lost, the receiver starts expecting frame L 1 + 1, and the condition “the receiver is expecting L 1 ” no longer obtains. Every time frame L 1 is lost, the sender eventually times out and retransmits the whole window. Therefore the entire window (and frame L) will be transmitted as many times as frame L 1 is expected to be lost. We already know that this number is 1/ p – 1.

after the frame following the lost frame has been received. The first retransmission succeeds, and the time attributed to frame i is τ + (2τ + Tnak). Finally, when k is 2 or more, ( k – 1) durations of (τ + Tout) are added onto the above time. All the different conditions in the question help you draw the above conclusions. You should consider how the answers would change if one or the other condition were changed; for example, if Tout < Tnak + τ,then the timeout would occur before the NAK could have any effect. (b) The probabilities are that of exactly one transmission, exactly one loss, exactly two losses, etc. The probabilities are as usual, respectively, P[ k = 0] = p , P[ k = 1] = (1- p ) p , P[ k = 2] = (1- p )^2 p , and generally (1- p ) k^ p. (c) Combining the answers to parts (a) and (b), that is summing the times required for exactly k losses weighted by the probabilities over all possible k , it is straightforward to obtain the given expression.

  1. (a) The window is initially [ #1, #2, #3, #4, #5 ]. As ACKs for frames 2, 3 and 5 come in, they are replaced by the next three frames 6, 7 and 8, resulting in the sender’s window as specified. (b) There is no such sequence. The key observation here is that the receiver has the same buffer of W frames as before. With the modified algorithm, the sender is now allowed to transmit frames 6, 7 and 8, but the receiver has no place to put them in until it has received frame 1 and advanced its window. By the conditions of the question, ACKs are not lost; and by the above argument, the ACK for 6 has to be transmitted by the receiver after the ACK for 1. If the channel is FIFO, the two ACKs will reach the receive in the same order, no matter how many times the frames were transmitted and lost. (c) The answer to part (b) provides a starting point for this estimation. We argue that under reasonable circumstances, this modification will almost never result in an improvement in the number of new correct transmissions over a period of time. i i+ 2 τ i Tnak (^) τ Tout i k = 2 τ

The key observation is that this modification allows the sender to send frames which otherwise could not have been sent, but almost certainly at the wrong times. For example, consider the extreme case when only frame #1 has failed during original transmission, so the sender’s window is [#1, #6, #7, #8, #9]. Now when #1 times out and is retransmitted, if it is received correctly, it immediately slides the receiver’s window out to [#6, #7, #8, #9, #10] and allows the receiver to accept the later packets which the sender is already allowed to transmit (without the modification the sender would not be allowed to transmit those frames until the ACK for #1 reached the sender). But the sender has already transmitted frames #6, #7, #8 and #9, when they originally moved into the sender’s window, and will not now retransmit them until they time out. When those original transmissions had been received by the receiver, it had not accepted them because they were still outside the window. Now assuming that the window size is such that the transmission delay of W frames is roughly equal to twice the propagation delay (remember the approach to problems 5 and 6 of HW4), and that the timeout is a little larger than twice the propagation delay, we find that frame #1 is likely to timeout during the time the sender is transmitting frames #6, #7, #8 and #9, or a little later. If later, then these transmissions are discarded by the receiver as described above. If during, then the sender has two choices; either it finished the original transmissions and then retransmits #1, this case then boils down to the above. Otherwise it should go into retransmission mode, in which case it retransmits #1, but now it should not transmit original frames because it is already retransmitting. Either way, the only extra transmissions the modified algorithm allows the sender to make occur before they can possibly be accepted by the receiver. You can make the argument that after retransmitting #1, the sender should transmit any remaining frames in its window that have not been transmitted before. This is a little irregular, but it can be done without compromising correctness. However, if even one of the new frames was transmitted before the retransmission of frame #1, then the receiver’s window will not be able to move forward, and the situation simply repeats. Efficiency may improve, but not greatly over a long time. Another issue that we have not considered is the sequence number wraparound. Because a wider range of frames can be in the channel, the number of distinct sequence numbers must be increased. If we try this modification with the usual 2W sequence numbers, then it can easily be shown that correctness will not be retained.

  1. Many such scenarios can be devised. An example is given in the relevant part of Walrand’s text which has been placed on e-reserve.