2. Data Link Layer (DLL): Flow & Error Control

This chapter covers Lectures 3 (flow control) and 4 (error control). Both look at one link between two nodes: a sender and a receiver. They answer two questions:

  1. Flow control: how does the sender avoid sending faster than the receiver can store the frames?
  2. Error control: what does the sender do when a frame is lost or damaged?

These topics carry most of the calculations in Part I: link utilisation, window size, and how fast a middle node must send so that its buffer does not overflow. Section 6 shows how to use the formulas for each of these.


1. Where This Fits

The data link layer (DLL) moves frames across one link. Its jobs are framing, link access, flow control and reliable delivery. IEEE splits the DLL into two sub-layers: LLC (Logical Link Control, which faces the network layer) and MAC (Medium Access Control, which faces the medium).

The DLL and its two sub-layers

Not examinable (slide labels): the list of DLL roles, framing (byte-oriented and bit-oriented), asynchronous start/stop bits, and link configuration (topology and duplex). Everything about flow control and ARQ is examinable.


2. The Four Times You Need

Every calculation in this chapter uses these quantities. Get the units right first.

Symbol Name Formula What it depends on
LL Frame length given, in bits Convert bytes to bits: ×8\times 8.
RR Data rate given, in bit/s
TframeT_{\text{frame}} Transmission time Tframe=L/RT_{\text{frame}} = L / R The time to push all bits of one frame onto the link.
TpropT_{\text{prop}} Propagation time Tprop=d/vT_{\text{prop}} = d / v The time for one bit to travel the distance dd at speed vv (often 2×1082\times10^8 m/s). Some questions give a delay per km instead.
aa Normalised propagation delay a=Tprop/Tframea = T_{\text{prop}} / T_{\text{frame}} How long the link is, measured in frame times.

Think of aa like this: if a=3a = 3, the first bit of a frame arrives at the receiver only after the sender has sent 3 frames’ worth of time.


3. Flow Control

3.1 The problem

The receiver keeps each arriving frame in a buffer (a small memory) until it can process the frame. If the sender sends too fast, the buffer fills and new frames are lost. Flow control makes the sender wait for permission from the receiver.

In this section we assume that no frame has errors. Section 4 adds errors.

3.2 Stop-and-wait

The simplest method:

  1. The source sends one frame.
  2. The destination receives the frame.
  3. The destination sends back an acknowledgement (ACK) when it is ready for the next frame.
  4. The source waits until the ACK arrives.
  5. The source sends the next frame.

The receiver can stop the flow at any time. It simply does not send the ACK.

Sequence numbers. Stop-and-wait only needs a 1-bit number: frames alternate 0, 1, 0, 1, …. The ACK carries the number of the frame that the receiver expects next. So “ACK1” means “I have frame 0, now send frame 1”.

Stop-and-wait timing: one cycle runs from the first bit of f_0 until the sender can start f_1

Link utilisation UU is the fraction of time the link carries useful data:

U=time spent sending datatotal time of one cycle=TframeTcycleU = \frac{\text{time spent sending data}}{\text{total time of one cycle}} = \frac{T_{\text{frame}}}{T_{\text{cycle}}}

One cycle has these parts:

Tcycle=Tframe+Tprop+Tproc+TACK+Tprop+TprocT_{\text{cycle}} = T_{\text{frame}} + T_{\text{prop}} + T_{\text{proc}} + T_{\text{ACK}} + T_{\text{prop}} + T_{\text{proc}}

The ACK is very short and processing is fast, so we ignore TACKT_{\text{ACK}} and TprocT_{\text{proc}}:

Tcycle≈Tframe+2Tprop⇒US&W=TframeTframe+2Tprop=11+2aT_{\text{cycle}} \approx T_{\text{frame}} + 2T_{\text{prop}} \quad\Rightarrow\quad \boxed{U_{\text{S\&W}} = \frac{T_{\text{frame}}}{T_{\text{frame}} + 2T_{\text{prop}}} = \frac{1}{1 + 2a}}

Worked example (lecture). R=2.4R = 2.4 Mbit/s, d=50d = 50 km, v=2×108v = 2\times10^8 m/s, L=300L = 300 bytes.

Lecture example for stop-and-wait

3.4 What is wrong with stop-and-wait

3.5 Sliding window

The idea. The receiver has buffers for NN frames. So the sender may send up to NN frames before it gets an ACK.

Rules:

The window covers N = 3 frames out of the numbers 0 to 7 (k = 3)
Sliding window in operation with N = 3, k = 3

Two extra controls:

Window size limit for pure flow control. With kk bits there are 2k2^k different numbers, so the window can hold at most 2k2^k frames:

N≤2kN \le 2^k

The ARQ methods in Section 4 need a smaller limit. Use the ARQ limit when the question includes errors.

Time starts when the sender sends the first bit of frame 0. The ACK for frame 0 comes back at time Tframe+2Tprop=Tframe(1+2a)T_{\text{frame}} + 2T_{\text{prop}} = T_{\text{frame}}(1 + 2a). In that time the sender can send (1+2a)(1 + 2a) frames. There are two cases:

USW={1N≥1+2aN1+2aN<1+2a\boxed{U_{\text{SW}} = \begin{cases} 1 & N \ge 1 + 2a \\[4pt] \dfrac{N}{1 + 2a} & N < 1 + 2a \end{cases}}

Case 2: the window runs out before the first ACK returns
Utilisation against a for N = 1 (stop-and-wait), N = 7 and N = 127

Stop-and-wait is the special case N=1N = 1.

Smallest window for a target throughput. A 100 kbit/s link carries 1000-bit frames. Tprop=25T_{\text{prop}} = 25 ms. No errors. What is the smallest window that gives at least 50 kbit/s?


4. Error Control (ARQ)

4.1 Two kinds of frame error

4.2 Two ways to deal with errors

ARQ turns an unreliable link into a reliable one. Each flow-control method has an ARQ version:

Flow control ARQ version
Stop-and-wait Stop-and-wait ARQ
Sliding window Go-back-N ARQ, or Selective-reject ARQ

Not examinable (slide labels): parity check, the “seven prisoners” puzzle, and CRC.

4.3 Stop-and-wait ARQ

The source keeps a copy of the frame and starts a timer when it sends.

Event What happens
Frame is lost No ACK comes. The timer runs out. The source sends the frame again.
Frame is damaged The destination discards it. It may also send a NAK. The source sends the frame again (after the NAK, or after the timeout).
ACK is lost The timer runs out. The source sends the frame again. The destination now has two copies. The sequence number (0 or 1) shows that the second one is a duplicate. The destination discards it and sends the ACK again.
ACK is damaged The source ignores it. The timer runs out, and the case is the same as a lost ACK.
Stop-and-wait ARQ: a lost frame, a lost ACK (duplicate discarded) and a damaged frame (NAK)

Utilisation. Let PP be the probability that a frame is in error. On average a frame needs 1/(1−P)1/(1-P) attempts. So:

US&W ARQ=1−P1+2a\boxed{U_{\text{S\&W ARQ}} = \frac{1 - P}{1 + 2a}}

Lecture example: with a=0.25a = 0.25 and P=0.1P = 0.1, U=0.9/1.5=0.6U = 0.9 / 1.5 = 0.6.

Lecture example worked in full: D = 50 km, R = 2.4 Mbps, L = 300 bytes gives a = 0.25, U = 66.7\% without errors and 0.6 with P = 0.1

4.4 Go-back-N ARQ (the “cautious” method)

The receiver accepts frames only in order.

Go-back-N: F1 is lost, so F2 is discarded and the sender resends from F1

Maximum window for Go-back-N:

NGBN≤2k−1\boxed{N_{\text{GBN}} \le 2^k - 1}

Why not 2k2^k? Take k=3k = 3, so the numbers are 0 to 7.

Go-back-N fails with N = 8 (k = 3)
Go-back-N works with N = 7 (k = 3)

Utilisation. The exact Go-back-N formula is not required. The lecture says: use the selective-reject formula for Go-back-N too.

4.5 Selective-reject ARQ (the “efficient” method)

Also called selective repeat. The receiver accepts frames out of order if they fall inside its window.

Selective-reject: only the lost F1 is sent again. F2 and F3 wait in the buffer.

Maximum window for selective-reject:

NSR≤2k−1\boxed{N_{\text{SR}} \le 2^{k-1}}

Why half? Take k=3k = 3.

The rule: the old window and the new window must not share any number. Two windows of size NN must fit inside 2k2^k numbers, so 2N≤2k2N \le 2^k.

Selective-reject fails with N = 5 and works with N = 4 (k = 3)

Utilisation:

USR={1−PN≥1+2aN(1−P)1+2aN<1+2a\boxed{U_{\text{SR}} = \begin{cases} 1 - P & N \ge 1 + 2a \\[4pt] \dfrac{N(1 - P)}{1 + 2a} & N < 1 + 2a \end{cases}}

4.6 Go-back-N versus selective-reject

Go-back-N Selective-reject
What is resent The bad frame and all frames after it Only the bad frame
Receiver buffer One frame (accepts in order only) A full window (stores out-of-order frames)
Receiver logic Simple Complex: must buffer and reorder
Bandwidth wasted on errors More (good frames are sent again) Less
Maximum window 2k−12^k - 1 2k−12^{k-1}
Best for Low error rates, simple hardware High error rates, long links (large aa)

5. Formula Summary

Method Max window UU when N≥1+2aN \ge 1+2a UU when N<1+2aN < 1+2a
Stop-and-wait (no error) 1 — 11+2a\dfrac{1}{1+2a}
Sliding window (no error) 2k2^k 11 N1+2a\dfrac{N}{1+2a}
Stop-and-wait ARQ 1 — 1−P1+2a\dfrac{1-P}{1+2a}
Go-back-N ARQ 2k−12^k - 1 use SR use SR
Selective-reject ARQ 2k−12^{k-1} 1−P1-P N(1−P)1+2a\dfrac{N(1-P)}{1+2a}

Throughput (in bit/s) =U×R= U \times R.

If the question gives a bit error probability pbp_b instead of a frame error probability, the frame is good only if every bit is good:

P=1−(1−pb)LP = 1 - (1 - p_b)^{L}


6. Using the Formulas

Every calculation in this chapter starts the same way. Write these four lines first, in one unit of time:

  1. Tframe=L/RT_{\text{frame}} = L / R
  2. Tprop=d/vT_{\text{prop}} = d / v (or distance × delay per km)
  3. a=Tprop/Tframea = T_{\text{prop}} / T_{\text{frame}}
  4. 1+2a1 + 2a

Then compare the window NN with 1+2a1 + 2a to choose the case. The rest of this section shows the kinds of question this leads to.

6.1 Utilisation, the best window, and the sequence bits

Setup. R=1R = 1 Mbit/s, L=500L = 500 bytes, d=1000d = 1000 km at 5 µs/km, frame error probability P=0.1P = 0.1, selective-reject.

Utilisation for a given window, N=2N = 2. 2<3.52 < 3.5, so the window runs out before the first ACK returns:

U=N(1−P)1+2a=2×0.93.5=0.514U = \frac{N(1-P)}{1+2a} = \frac{2 \times 0.9}{3.5} = 0.514

The throughput is 0.514×1 Mbit/s=5140.514 \times 1 \text{ Mbit/s} = 514 kbit/s.

The smallest window that gives the maximum utilisation. The sender never stops when N≥1+2a=3.5N \ge 1 + 2a = 3.5. The window must be a whole number, so N=⌈3.5⌉=𝟒N = \lceil 3.5 \rceil = \mathbf{4}. Then U=1−P=0.9U = 1 - P = 0.9. A larger window cannot do better, because errors still cost 10%.

The fewest sequence bits for that window. Each method has its own limit, so the answer depends on the method:

Method Limit Smallest kk for N=4N = 4
Sliding window, no errors N≤2kN \le 2^k k=2k = 2
Go-back-N N≤2k−1N \le 2^k - 1 k=3k = 3
Selective-reject N≤2k−1N \le 2^{k-1} k=3k = 3

Header overhead. The sequence number sits in the frame header, so it carries no user data. If the question says that the frame length LL includes the kk sequence bits, only (L−k)/L(L - k)/L of each frame is useful. Multiply the utilisation by this fraction to get the useful utilisation.

6.2 Frame errors from bit errors

Sometimes the question gives a bit error probability pbp_b, not a frame error probability PP. A frame is good only if every one of its LL bits is good:

P=1−(1−pb)LP = 1 - (1 - p_b)^{L}

For L=2000L = 2000 bits and pb=10−4p_b = 10^{-4}: P=1−0.99992000≈0.181P = 1 - 0.9999^{2000} \approx 0.181. Longer frames have a higher PP.

6.3 A middle node must not overflow its buffer

The problem. Frames go A → B → C. B stores each frame from A in its buffer, then sends it on to C. If frames arrive at B faster than B can send them on, the buffer fills and frames are lost. So B’s outgoing throughput must be at least its incoming throughput. The question usually asks for the slowest data rate on link B–C that achieves this.

Method:

  1. Find the incoming throughput at B: throughputAB=UAB×RAB\text{throughput}_{AB} = U_{AB} \times R_{AB}, with the correct UU formula for link A–B.
  2. Write the outgoing throughput of link B–C in terms of the unknown rate RR. For stop-and-wait, B sends one frame per cycle: LTframe+2Tprop\dfrac{L}{T_{\text{frame}} + 2T_{\text{prop}}}, with Tframe=L/RT_{\text{frame}} = L/R.
  3. Set outgoing ≥\ge incoming. Solve for TframeT_{\text{frame}}, then R=L/TframeR = L / T_{\text{frame}}.

Example. All frames are 2000 bits, with no errors.

Step 1. On A–B, Tframe=10T_{\text{frame}} = 10 ms and a=1.5a = 1.5, so 1+2a=41 + 2a = 4. Since 2<42 < 4, U=2/4=0.5U = 2/4 = 0.5. The incoming throughput is 0.5×200=1000.5 \times 200 = 100 kbit/s. In time: A sends 2 frames every 40 ms.

Step 2. On B–C, one cycle takes Tframe+2×5=Tframe+10T_{\text{frame}} + 2 \times 5 = T_{\text{frame}} + 10 ms.

Step 3. Solve:

2000 bitsTframe+10 ms≥100 bit/ms⇒Tframe≤10 ms⇒R≥2000 bits10 ms=𝟐𝟎𝟎𝒌𝒃𝒊𝒕/𝒔\frac{2000 \text{ bits}}{T_{\text{frame}} + 10\text{ ms}} \ge 100 \text{ bit/ms} \;\Rightarrow\; T_{\text{frame}} \le 10 \text{ ms} \;\Rightarrow\; R \ge \frac{2000 \text{ bits}}{10 \text{ ms}} = \mathbf{200\ kbit/s}

The same chain with ARQ on A–B. Now let link A–B have P=0.1P = 0.1 and a 2-bit sequence number, and let A use the largest window that its method allows. Link B–C stays the same.

Go-back-N on A–B Selective-reject on A–B
Largest window 22−1=32^2 - 1 = 3 22−1=22^{2-1} = 2
Compare with 1+2a=41 + 2a = 4 3<43 < 4 2<42 < 4
UABU_{AB} (SR formula) 3×0.9/4=0.6753 \times 0.9 / 4 = 0.675 2×0.9/4=0.452 \times 0.9 / 4 = 0.45
Incoming at B 135 kbit/s 90 kbit/s
TframeT_{\text{frame}} on B–C ≤2000/135−10=4.81\le 2000/135 - 10 = 4.81 ms ≤2000/90−10=12.22\le 2000/90 - 10 = 12.22 ms
Smallest RBCR_{BC} 416 kbit/s 164 kbit/s

Go-back-N allows a larger window for the same kk, so A sends faster, and B–C must be faster too.

Sanity check. Stop-and-wait can never carry more than L/(2Tprop)L / (2T_{\text{prop}}), even with an infinite data rate, because every cycle includes the round trip. Here that is 2000/10 ms=2002000 / 10 \text{ ms} = 200 kbit/s. If the incoming throughput is larger than this, no rate on B–C works. Say so in your answer.


7. HDLC Time-Sequence Diagrams

HDLC (High-level Data Link Control) is a standard data link protocol that uses sliding windows. A time-sequence diagram shows the frames that two stations, A and B, send to each other over time. You must be able to label every frame in such a diagram.

7.1 The three frame types

Frame Meaning
I(ii, jj) An information (data) frame. ii = the sequence number of this frame. jj = a piggybacked ACK: “I have your frames up to j−1j-1; I expect your frame jj next.”
RR(jj) Receive Ready (an ACK with no data): “I have your frames up to j−1j-1; send jj next.”
SREJ(jj) Selective Reject (a NAK): “Send your frame jj again.”

All numbers are modulo 2k2^k. With 3 bits, the number after 7 is 0.

7.2 Method

  1. Treat the two directions separately. Each side has its own sequence counter.
  2. For each sender, number its I-frames one after another: i,i+1,i+2,…i, i+1, i+2, \dots (mod 8).
  3. For the second number jj in an I-frame, look at the frames that this side has received so far from the other side. jj = (last in-order frame received) + 1.
  4. A lost frame does not move the receiver’s counter. When a later frame arrives, the receiver sees the gap and sends SREJ for the missing number.
  5. After the missing frame arrives, the next RR or jj value jumps to one past the highest frame received.

7.3 Example trace

k=3k = 3. A’s next frame number is 6. B’s next frame number is 0. Neither side has received anything yet.

Step Frame Why
1 A → B: I(6, 0) A’s frame 6. A has nothing from B, so it expects B’s frame 0.
2 A → B: I(7, 0) A’s next number.
3 B → A: I(0, 0) B’s frame 0. B has A’s 6 and 7, so it expects 7+1=8≡0(mod⁡8)7 + 1 = 8 \equiv 0 \pmod 8.
4 A → B: I(0, 1) A’s numbers wrap to 0. A now has B’s frame 0, so it expects 1.
5 A → B: I(1, 1), lost B never sees it. B still expects A’s frame 1.
6 A → B: I(2, 1) B receives frame 2, but frame 1 is missing.
7 B → A: SREJ(1) B asks for frame 1 only. It keeps frame 2 in its buffer.
8 A → B: I(1, 1) A resends frame 1. B has sent no new data, so jj stays 1.
9 B → A: RR(3) B now holds 0, 1 and 2 in order, so it expects 3.

In step 3, the two zeros mean different things. The first 0 is B’s own frame number. The second 0 is the next frame B expects from A.


8. Common Traps