Sunteți pe pagina 1din 12

Homework 4 – Data Link Control

ECE/CSC 570 – Computer Networks, Fall 2018

Note: Please read all the information regarding homeworks on the course website pertaining to submission,
grading and penalties, fair process, etc.

1. The following data fragment occurs in the middle of a data stream for which the byte-stuffing
algorithm (with FLAG and ESC) described in the lecture is used: A B ESC C ESC FLAG FLAG
D . What is the output after stuffing?
1. Each FLAG will have to be Escaped, since the receiver will otherwise take those to be the end
of the frame. Each ESC will have to be Escaped, since the receiver will otherwise assume the
next byte to be escaped, so will discard it. Thus the fragment of the output corresponding to this
input fragment after stuffing will be: A B Esc Esc C Esc Esc Esc Flag Esc Flag D .

2. In a particular DLC, the FLAG is ‘0160’ (or more obviously written, ‘01111110’), and bit
stuffing is used with the rule “stuff a ‘0’ after any occurrence of ‘015’ in the bit string
transmitted.” A bit string, 01111111111111111101111011111011111110010 is handed to the
DLC as the SDU. For the purpose of this question, we assume that other than frame delineation,
the DLC does not add any header and trailer.
(a) What does this string become after bit stuffing? That is, what bits will go out on the wire?
(b) At the receiver, what must be the rule for de-stuffing?
(c) Take the answer to part (a) and de-stuff it with the answer to part (b), and show that the
original string is again obtained.
(d) Suppose the stuffing rule was “stuff a ‘0’ after any occurrence of ‘015’ in the original SDU”.
Comment on the correctness and efficacy of this rule. If possible, answer parts (a), (b) and (c)
again on the basis of this rule.
2. (a) The string fragment becomes the following string fragment; stuffed zeros have been
underlined. You may answer just with this string, or add the 0160 Flag before and after, since
the question indicates that this is the complete SDU, and specifies no other encapsulation except
delineation.
0111110111110111110110111101111100111110110010
(b) “Copy bits as received into the frame. If the last 6 bits to be received off the wire 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 that the receiver must make a distinction between bits received off the wire, and the bits
copied into the PDU (that is subsequently to be decapsulated and delivered to the upper layer as
SDU). You cannot write a correct rule without making this distinction.
(c) You can verify for yourself that the destuffing works.
(d) In the stuffing above, we have specified the stuffing rule as “if you just transmitted ‘015’,
then stuff a ‘0’ ” – this leads above to the second and third zeros being stuffed even though they
did not come after ‘015’ in the SDU string. Clearly, an alternative exists here – we could
eliminate these zeros and only stuff when the ‘015’ occurred in the input string; but the result of
the stuffing would be different, and the destuffing rule must change accordingly. The data link is
only going to operate correctly if a valid destuffing rule exists corresponding to this stuffing rule.
You can verify for yourself that the destuffing would work correctly if we changed the phrase
“received off the wire” to “copied” in the destuffing rule. However, this would partly offset the
utility of the FLAG byte. Imagine a receiver that 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. And of course, the original rule is
also superior in that the copied bits, once copied, never have to be modified. So the few
potential extra stuffing bits actually make the protocol more efficient.

3. We saw in class that parity check codes can utilize multiple parity bits for a message by
linearly combining (XORing) not all, but only some of the bits of the message. In this way, more
than one parity bit can be generated for the same message. (For example, the horizontal and
vertical grid parity bit scheme generates each parity bit by considering only those bits on a
particular row or column, after arranging the message bits on some sort of a grid. The other bits
are not considered, for that particular parity bit.)
Consider a parity check code with three data bits and four parity bits, in which the dataword is
the 3-bit bit vector u, and the parity bits together for a 4-bit bit vectore r , i.e. the complete
codeword looks like u2u1u0r3r2r1r0. Suppose that three of the codewords are 1001011, 1100110,
and 0011110. By inspection, find the rule for generating each of the parity bits, write down all 8
codewords, and find the minimum distance of this code.
3. We construct the partial truth table shown below, showing all possible XOR combination of
some subset of bits of the dataword:
u2 u1 u0 u0 ⊕ u1 u0 ⊕ u2 u1 ⊕ u2 u0 ⊕ u1 ⊕ u2
1 0 0 0 1 1 1
1 1 0 1 1 0 0
0 0 1 1 1 0 1
From the above, we see that each bit of the r vector can only be a unique function of the input
bits; r3 = u0 ⊕ u1 ⊕ u2 , r2 = u0 ⊕ u1 , r1 = u0 ⊕ u2 , and r0 = u1 ⊕ u2 . The codewords can now
be written down in a straightforward manner. Counting the minimum number of 1's in a nonzero
codeword, the minimum distance is 4. (See the text for a discussion of why, for a linear code,
the minimum distance between any two codewords is the same as the minimum distance of any
codeword from the all-zeros codeword.)

4. Consider a satellite connection with a one-way propagation delay of 0.35 seconds between the
sending and receiving ground stations (via satelite) and a transmission rate of 1 Mbps with
packets of 1000 bits. The transmission time for an acknowledgment is negligible.
(a) What is the minimum timeout period required for a Stop-and-Wait ARQ protocol? Specify
whether you are counting the timeout from the beginning of the frame transmission or from the
end.
(b) What is the minimum window size of Go Back N that would, over a period of time in which
no error happen to occur, result in an efficiency of 100% ? (We refer to this as the “full
window”).
4. (a) The minimum timeout from the end of the packet transmission time would be twice the
propagation delay, that is 0.7 s. Any less than this, and the sender would timeout before the
receiver’s ACK physically had enough time to get back to the sender, even assuming negligible
processing and queuing delays at the receiver, and negligible ACK transmission delay.
(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:
Wt / S >= 1. In this case, t = 103 /106 , S = r + t + r = 0.35 + 103 /106 + 0.35. Thus the
minimum value of W is 701.
In the above, t is the transmission delay of a frame, S is the time from the beginning of a
transmission till the ACK for that transmission comes back to the sender, and r is the one-way
propagation delay.

5. Consider a land wireless connection with a one-way propagation delay of 10 microseconds


between the sending and receiving stations and a transmission rate of 11 Mbps with packets of
10000 bits. The transmission time for an acknowledgment is negligible.
(a) What is the minimum timeout period required for a Stop-and-Wait ARQ protocol? Specify
whether you are counting the timeout from the beginning of the frame transmission or from the
end.
(b) What is the “full window” size of Go Back N in this case ?
5. (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 Wt / S >= 1. In this case, t = 104 /(1.1 * 107), S = 10-5 + 104 /(1.1 *
107) + 10-5. Thus the minimum value of W is 2.
It is worth trying to visualize the difference posed by the ratio of t and r in this problem and the
previous one, by means of timing diagrams (even if they cannot be drawn perfectly to scale).

6. Consider the SWP efficiency analysis in the ARQ lecture. Perform a similar analysis for the
GBN protocol, with the assumption that W is sufficiently large to allow the sender to transmit
continuously. Also account for the transmission time and timeout time separately, as in the
lecture slide. (So now we must think of S as being equal to T + t, rather than T.) Obtain an
expression for E[X], the expected time to transmit a packet successfully.
Note: For analysis like this, we always assume that the higher layers at the sender supplies SDUs to the DLC at a
high enough rate that the sending DLC always has frames to send, when the protocols and the channel rate allows it
to. This “high load” consideration gives us a true picture of the efficiency limitation of the ARQ protocol itself.
6. The analysis is exactly like SWP. As in the SWP efficiency analysis in the lecture, we count
the timeout T from the end of the packet transmission. Provided enough traffic always exists at
the sender (an assumption we always make, as noted in the question), in the absence of error a
new packet is transmitted every t units of time (for SWP this was t + 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 chance p
of succeeding, since the channel is memoryless. This situation repeats.
Thus the packet requires:
t time with probability p,
(t + T) + t time with probability (1 – p) p,
2(t + T) + t time with probability (1 – p)2 p,
… and so on.
Thus the expected value is E[X] = Si=0..inf (1 – p)i p ((t + T) i + t) = t + (t + T) (1 – p)/p.
Although the question does not ask this, but from this we can also obtain the efficiency of the
channel (the fraction of the time, over a long time, that the channel is engaged in transmissions
that are useful, i.e. ultimately successful in progressing the data transfer). The efficiency is easily
obtained now as t / E[X].

7. Which of the protocols specified in the text correspond most closely with each of the
following protocols (as discussed in lecutres)? When you cannot find an exact correspondence,
you should list the closest correspondence, and comment on the aspects that are different in the
two protocols.
(a) Stop-and-Wait (with ACK sequence numbers)
(b) GoBackN
(c) Selective Repeat
7. (a) Protocol 3 of the text is equivalent to Stop-and-Wait with ACK sequence numbers.
(Protocols 1 and 2 do not have sequence numbers; Protocol 3 uses no sequence numbers on the
ACK, and is therefore like the first version of the Stop-and-Wait we discussed in the lecture
Protocol 4 is similar except that we did not consider piggybacking on a bidirectional link in
class.)
(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 generally assumed
there is always data waiting to be sent.
(c) Protocol 6 is closest to Selective Repeat, again with the same distinctions.
Note: For the next few questions, you are asked to draw timing diagrams. There are several valid ways of drawing
them; however, please use the method specified in class in the first slide on this topic. In this method, you are
required to show the transmission and reception instants for the beginning and end of each frame, and connect them
with lines indicating propagation, unlike the more schematic (therefore less informative) method in later slides (and
different texts) of showing just one line of propagation for each frame. Maintain scale as far as possible, all events
must be correctly ordered. It is strongly suggested that you use the template supplied. Scanning hand-drawn
diagrams is not acceptable – you must produce an electronic document using some vector graphic application and
converting the result to PDF.
8. Consider a GoBackN ARQ system with W=5. Assume that the sender sends the first frame
(sequence numbered 0) at time 0. The transmission time for all frames is the same and is equal to
2t , r is the propagation delay for either frames or ACKs, and r = 4t. The transmission time is t
for ACKs. The sender uses a timeout of 12t starting from the end of the frame transmission.
Only ACKs are used, not NAKs.
Draw a timing diagram for this system, assuming that Frame #2 (the one with sequence number
2) is lost the first time it is transmitted, and Frame #3 is lost the second time it is transmitted. No
other frames and no ACKs are lost over the period of interest. Draw the diagram from time 0 to
the time that Frame #3 is correctly received and accepted at the receiver.
8. In the diagram shown below, some extra information has been added, which may help in
comprehension; specifically, it shows the times at which the sender’s buffer contents change, and
the times when frames are delivered up to the higher layer at the receiver. It also shows the
frame and ACK propagations as translucent; the colors have no significance, and are only there
to help distinguish between the times the channel is propagating different frames (and in the
reverse direction, ACKs).
The important parts of the diagram are easily seen. Every time an ACK is received that is not a
duplicate (requesting a frame that has not been requesting before), the sender’s window
advances, and the sender transmits any new frame brought in to the window at this time. At time
t=18t, Frame #2 times out, and the sender goes into Go-Back-N mode, and retransmits its entire
current window. At time 29, an ACK arrives for that moves the window forward, and puts the
transmitter back in original transmission mode, and the sender makes a new transmission of the
only frame that just came into its buffer. But at time 34, the oldest pending frame times out, and
the sender goes into retransmission mode again. At time 45, an ACK again starts moving the
window forward.
9. (Ungraded) Consider the same ARQ system as above, but now consider the following
scenario. The sender starts transmitting as before, and all frame transmissions are successful.
The first ACK transmitted by the receiver is completely lost – all other transmissions are
successful.
Draw a timing diagram for this system from the beginning until the time frame #5 is transmitted
for the first time.
9. The actual diagram is left as an exercise for the student – it is considerably simpler than the
one above. The key point is that in GBN, ACKs are cumulative, so in this case, the second ACK
(A2, sent in response to the correct reception of Frame #1), when received by the sender (at time
13t), will act as an acknowledgement of both Frames #0 and #1, so at this time the sender’s
window will move forward from [0, 1, 2, 3, 4] to [2, 3, 4, 5, 6]. At this time, the sender has not
yet timed out on Frame #0, so it is still in original transmission mode, so it will simply continue
with transmission of the frames that newly came into the window. So, Frame #5 will be first
transmitted at time 13t.

10. (Ungraded) Consider an SRP ARQ system, with frame transmission time 2t, ACK
transmission time t, symmetric propagation delay 3t. The sender and receiver have matched
buffers, each capable of holding 6 frames. Logical and actual frame sequence numbers both
begin at 0, and the sender transmits the frame with logical sequence number 0 at time 0. The
sender uses a timeout of 9t beginning from the end of frame.
The checksum computation algorithm at the sending DLC has an unsuspected bug that results in
a wrong checksum computed every third time that the algorithm is invoked. The algorithm is
invoked every time a transmission is attempted on the data link – retransmissions of the same
frame results in new invocations of the checksum algorithm. The receiving DLC implements the
same protocol, but does not contain the bug.
When is the frame with logical sequence number 7 delivered to the networking layer at the
receiver?
10. Again, added information should clarify the operation of the protocol. (If you have tried
doing these problems, you probably appreciate that it is impossible to implement such protocols
without internal memory states to maintain corresponding information.)
The key thing here is that each transmission or retransmission has its own timeout timer, and
different frames are re-transmitted independently based on these timers. However, the receiver
must maintain even frames that have been correctly received in its buffer until they can be
delivered to the higher layer, which must be done in order. So the receiver can only deliver (and
remove from its buffer) received frames that form a continuous sequence starting from the next
frame to be delivered to the higher layer. As long as the next frame to be delivered to the higher
layer has not been correctly received, later frames have to be held in the buffer, even if they have
been correctly received. (From this it can also be shown, through fairly simple logic, that if the
sender and receiver have equal sized buffers, then it is only useful for the sender to purge
acknowledged frames that similarly form a continuous sequence starting from the earliest frame
in the buffer.) The rest of the diagram should be self-explanatory.
An interesting feature is that Frame #2, in error the first time, also happens to be a “third frame”
in its first re-transmission, and is lost again. It is finally received in the second re-transmission.
Frame #7, together with Frames #2 through #6, is delivered to the upper layer at time 32t.
11. (Ungraded) Consider an SRP ARQ system with the same parameters as above (without any
bugs), which uses actual sequence numbers 0 through 10 only (one fewer than theory tells us is
required) and rolls around after 10 to 0. Draw a timing diagram exhibiting a situation where this
lack of sequence number space results in incorrect operation of the SRP protocol.
11. The timing diagram itself is straightforward once you identify the extreme cases in which the
full sequence number space is utilized in SRP operation. The idea of having the space of
sequence numbers include one more than the maximum number of frames that can be
outstanding at any time comes from the fact that this maximum number of outstanding frames
captures the maximum de-synchronization of sequence information between the sender and the
receiver. At the worst case, the sequence number to be used for the next frame expected to be
transmitted by the sender must still be distinct from the oldest frame the state for which the
sender and receiver may still disagree about.
In this case, W = 6, so both the sender and receiver have a buffer of 6 frames. Since at least one
frame must have a space assigned in both the sender and the receiver buffers (otherwise we
would have the situation that the sender is only in position to send frames that the receiver is not
in a position to accept, so the protocol would stall), the maximum number of distinct frames that
can be represented in the combined buffer of the sender and receiver is 2W-1 . Thus theory tells
us that we would need 2W sequence numbers at least, or in this case, 12. However, in the
scenario posed by the problem, only 11 distinct sequence numbers (0 through 10) are used.
To force a disagreement between the newest (next possible) and the oldest frames, consider a
receiver that has received (and ACK’d) frames 0 through 5, and now receives a frame numbered
0. Here are two possible interpretations for that frame:
• The frame is the old frame 0 . The ACK for the old frame 0 was lost, so the sender has
timed out and is retransmitting it.
• The frame is the new frame 0. All the ACKs for frames 0 through 5 were received at the
sender, and the sender moved its window to [6,7,8,9,10,0]. However, frames 6 through
10 were lost.
Since it is not possible for the receiver to distinguish between these two cases, the protocol is not
a correct one with this restricted sequence numbering space.

12. (Ungraded) In a GBN system, the sender has a buffer of 7 frames and uses a three-bit
sequence number, which should be enough to avoid ambiguity. This means that the receiver
should always be able to determine whether a frame it receives is the expected frame, or not. In
the latter case, the received frame may be (i) a duplicate of a frame previously received and
accepted, or (ii) a “future” out-of-order frame that should be discarded. We might consider using
this information to further streamline the operation of the protocol; for example, we could try to
design a receiver that sends an ACK only for duplicate frames but not for future frames. In this
question, we consider whether the receiver can always extract this information.
At a certain time, the receiver is expecting a frame sequence numbered 3.
(a) What are the possible states of the sender’s buffer at this moment, where each state is
specified by the sequence numbers of the frames, in order, that occupy the buffer)? (Assume that
the upper layer always supplies more SDUs to the sending DLC, so no place in the buffer will be
empty.)
(b) For each of the sequence numbers that a received frame may carry, state briefly in the table
below how the receiver will interpret the frame.
12. (a) First, consider the case that the sender always has frames to send and hence its buffer is
always full with exactly 7 frames. There are eight possible “state”s of the buffer:

State Frame numbers, in order from oldest to latest


0 0, 1, 2, 3, 4, 5, 6
1 1, 2, 3, 4, 5, 6, 7
2 2, 3, 4, 5, 6, 7, 0
3 3, 4, 5, 6, 7, 0, 1
4 4, 5, 6, 7, 0, 1, 2
5 5, 6, 7, 0, 1, 2, 3
6 6, 7, 0, 1, 2, 3, 4
7 7, 0, 1, 2, 3, 4, 5

The short answer is that all of these are possible. The key observation is that if a frame
numbered 3 is in the sender’s buffer, then it is the very frame that the receiver is expecting. It
cannot be the much older frame #3 one whole window back, because in that case the frame #2
which is the latest frame the receiver has acknowledged could not have been transmitted by the
sender yet. It cannot be the next frame #3, because “this” frame 3 has not yet been
acknowledged by the receiver so the sender’s window cannot have slid past it yet, and no valid
sender’s window can contain two frames both numbered 3. The only possible window without
any frame numbered 3, State 4, must be composed entirely of already acknowledged frames, by
the same logic. In the table above, for each state, the color red is used to indicate already
acknowledged (“old”) and the color blue to indicate not yet received/accepted (“future”) frames.
Now consider the case that the buffer may not be completely full. Then, in addition to the states
above, some prefixes of those states are possible. Any state which is obtained by taking one of
the above states and removing a suffix of only blue or blue+black frames is obviously possible,
because the “future” frames may not have been provided by higher layers yet, including frame
#3. Less obviously, any state that cannot be so described is not possible, because transmitted
frames must be purged from the buffer in order.
(b) As we see from above, the receiver can only make two strong determinations about a frame it
receives while in this state – (i) if it receives a frame numbered 3, it is the frame it is expecting,
and (ii) if it receives a frame numbered 2, it must be an old frame. All other frame sequence
numbers may either indicate an old or a future frame.
In this example, the sequence number space was fully utilized – it is instructive to reconsider the
above for the case when the sequence number space is larger, say using 4 or 5 bits, in the above
case.

S-ar putea să vă placă și