ARQ Protocols - Stop-and-Wait, Go-Back-N and Selective Repeat
In questa pagina 9
In questa pagina 8
The problem and the terminology
One of the link-layer services is error control (Data Link Layer and FramingThe data link layer (DLL) delivers a frame from a node to an adjacent node over a link. Services: framing, medium access (MAC) with 48-bit MAC addresses, flow control, error detection and correction. It splits into DLC (framing, error and flow control) and MAC (shared medium access). Framing delimits frames with a flag: byte-oriented protocols (8-bit flag, ESC) use byte stuffing, bit-oriented ones (flag 01111110) use bit stuffing, which inserts a 0 after every five consecutive 1s.Data Link Layer and Framing →), in two forms:
- correction with FEC codes (Forward Error Correction), i.e. block codes;
- detection with a CRC (Cyclic Redundancy Check, a block code that can only detect errors) combined with ARQ (Automatic Repeat reQuest): if a frame arrives wrong it is sent again.
Definition (ARQ). Error control method using acknowledgments (ACK) to obtain reliable transmission over an unreliable service. If the sender does not receive the ACK, it retransmits the packet until it receives it or exceeds a maximum number of retransmissions.
Terminology:
- ACK (acknowledgment): the receiver tells the sender that a frame was received correctly.
- Selective ACK (SACK): indicates the set of frames received correctly (e.g. with a bit mask).
- Cumulative ACK (): frame was received correctly and so were all the previous ones.
- NACK (negative acknowledgment): the receiver refuses the frame for now (e.g. buffer overflow).
Scheme: the sender has a transmission buffer (TX) and a retransmission buffer (RETX); the channel may err; the receiver checks the frame (error?) and sends back ACK or NACK after a feedback delay; a resequencing buffer puts packets that arrived out of sequence back in order before delivering them to the upper layers.
Property (requirements of an ARQ protocol). Accuracy: packets must be delivered to layer of the receiver without errors, once and only once (no duplicates). Efficiency: avoid capacity loss from useless retransmissions and time wasted waiting for packets or ACKs.
Deadlock and timeout
Problem (deadlock): the sender waits for a positive ACK. If the frame does not arrive, the receiver cannot send any ACK and the sender may wait forever. This violates the efficiency requirement. Solution: ACK timeout. After sending the frame the sender starts a countdown within which the ACK must arrive; if the timer expires first, it retransmits.
Duplicates and sequence numbers
Problem (duplicates): the frame arrives fine and is delivered upward; the ACK is lost before reaching the sender; the timeout expires and the sender resends the same frame; the receiver again receives it correctly and delivers it again: duplicate. This violates the accuracy requirement. Solution: sequence number (SN). Each new frame sent carries an identifier; the receiver discards consecutive frames with the same SN (but still answers with the ACK). The layer- header then contains fields such as: type, SN, ACK, and the CRC at the end.
Quantities used in the formulas
| Symbol | Meaning |
|---|---|
| link-layer bitrate [bit/s] | |
| frame size: header + payload [bit] | |
| frame transmission time | |
| transmission time of the data only | |
| ACK transmission time | |
| propagation delay (one way) | |
| time to transmit a packet and receive the ACK (one cycle, i.e. the time of a successful transmission) | |
| total transmission time of the frame (including retransmissions) | |
| probability that a transmission (frame or ACK) fails | |
| utilization factor | |
| efficiency |
Definition (utilization and efficiency). With the mean time to successfully deliver a frame: is the fraction of time the sender is sending frames, the fraction in which it is sending useful data (without header).
If retransmissions are independent, each with failure probability , the number of failures before the first success is a geometric variable with and mean Derivation: , and the sum is the derivative of the geometric series , i.e. . So . Check: with there are on average failures per delivered frame; with , failure.
Stop-and-Wait (S&W-ARQ)
Definition (Stop-and-Wait). The simplest ARQ protocol: the sender sends one frame at a time and waits for the acknowledgment before sending the next. Simple does not mean ineffective: on a point-to-point link, where the pipe capacity is close to 1, it is optimal.
Sender states: ready (a frame arrives from above: it sends it, keeps a copy, starts the timer) and waiting (if the timeout expires it resends frame and restarts the timer; if arrives with a correct checksum it stops the timer, discards the copy and goes back to ready).
Sequence and ACK numbers. One bit is enough (modulo- arithmetic). ACK number announces that packet is expected: the ACK number always announces the sequence number of the next expected packet. If packet arrived fine the receiver sends (it expects ); if arrived it sends .
Example (lost ACK). The sender sends frame SN ; the receiver gets it and generates , which is lost. The timeout expires, the sender resends frame SN . The receiver expects but receives : it recognizes a duplicate, does not deliver it upward, but resends (it keeps waiting for ). The sender finally receives and can send frame .
Efficiency of Stop-and-Wait
A successful transmission occupies : the frame (), its propagation (), the ACK () and its return propagation (). Each failure costs exactly if the timeout is the minimum possible (). Hence
Formula (Stop-and-Wait).
Note: only the last (successful) transmission counts as "useful"; this is why a single appears in the numerator.
Example. Mbit/s, kbit ( ms), ms, : ms. Without errors (): : the link is used one sixth of the time. With : ms, . The bottleneck is the pipe capacity: packets could be in flight, but one is sent.
Sliding window
S&W allows one frame at a time. The solution is pipelining: send several unacknowledged frames one after the other. How many depends on the bandwidth-delay product (Network Performance AnalysisNetwork performance is measured by traffic metrics (bitrate R0, the link maximum; throughput S <= R0, data delivered successfully; goodput at the application layer), delay (end-to-end d = d_proc + d_queue + d_trans + d_prop with d_trans = L/R and d_prop = d/v; jitter; RTT), pipe capacity (BDP = rate times delay) and reliability (PER, PDR, PLR). The throughput of a path is that of its bottleneck link, the minimum bitrate, remembering that shared links split their capacity.Network Performance Analysis →). These are sliding window protocols: Go-Back-N and Selective Repeat.
Sender. It has a transmission window of size : with
- : SN of the first unacknowledged packet;
- : SN of the next packet that can be sent;
- : SN of the last packet sendable with the current window;
- packets are in flight (sent but not yet acknowledged; kept in the sender buffer), at most .
Receiver. It has a reception window of size : , the SNs it can accept (depends on the buffer).
- : SN of the next packet expected in order;
- : maximum number of packets that can be held in the buffer;
- packets go to the upper layer only in sequence, without gaps: those in the window wait until the packet with arrives.
Operations.
- If the sender receives with the window slides: (cumulative ACK) and .
- When the packet with arrives at the receiver: if is outside the reception window it is discarded; if it is stored in the buffer; if , moves to the SN of the first missing packet of the sequence and the receiver delivers upward the packets up to the new .
- The receiver answers with (the ACK of the next expected in-order packet).
Problem: what if a frame of the sequence is corrupted? Many frames reach the receiver before the sender notices. The receiver discards the corrupted frame: what does it do with the following ones? Two solutions.
Go-Back-N (GBN-ARQ)
Definition (Go-Back-N). Transmission window , reception window (the receiver can store a single packet, so no out-of-order reception). Receiver: discards all out-of-order packets. Sender: when a timeout expires it retransmits all frames from the first unacknowledged one onward (the whole window). It was the old version of TCP.
Example (, packet SN 3 lost). The sender sends SN 1-5. The receiver gets 1 and 2 and answers and (i.e. "I expect 3"); frame 3 is lost. The sender, having received the ACKs, slides the window and sends SN 6 and 7. But the receiver waits for 3: it discards 4, 5, 6, 7 (each triggers a repeated , which some texts call NACK(3)). The timeout for SN 3 expires: the sender goes back and resends 3, 4, 5, 6, 7. The receiver now gets them in order and answers ,... Total: packets retransmitted, even though 4-7 had arrived correctly (inefficient).
Efficiency. For transmission to be continuous (the sender never idles waiting), the ACK of the first packet of the window must return while it is still transmitting the packets: , i.e. The timeout must also be at least (but not less than ).
If a packet fails, recovering it costs . Reason: after sending the faulty frame the sender keeps sending the following ones (the window has frames, so seconds of transmission); only when the timeout expires does it notice the error and restart from the faulty frame, resending the whole window. The time spent for each failed attempt is therefore , not , while the last, successful, transmission counts only . With failures on average:
Formula (Go-Back-N, window ).
Step: divide numerator and denominator by , , and multiply top and bottom by : . Without errors () : GBN is efficient even on links with a large pipe capacity; with errors it is inefficient because it retransmits packets that already arrived correctly.
Example. (pipe of packets), : . In time: , of which are retransmissions of whole windows.
Selective Repeat (SR-ARQ)
Definition (Selective Repeat). Reception window equal to the transmission window (): the receiver accepts and stores also out-of-order packets (up to ) and delivers them to the upper layers only when it has a consecutive sequence. For every frame received correctly (new or duplicate) it sends the ACK with the SN of the first missing packet (cumulative ACK). When a timeout expires it retransmits only the corresponding frame. One timeout (RTO) can be kept for each packet in flight, or a single one for the whole window, restarted at each retransmission.
Example (same scenario, ). SN 3 lost. The receiver stores 4, 5, 6, 7 and keeps answering . At the timeout the sender resends only SN 3. As soon as 3 arrives, the receiver has 3-7 consecutive: it reorders and delivers them all, and answers . Total: packet retransmitted.
Efficiency. A retransmission lasts only (the window is not resent): each failure costs rather than , i.e. in the GBN formula set in the cost term:
Formula (Selective Repeat).
With , SR GBN and is maximum. With and SR has higher throughput than GBN, because correctly received PDUs are never retransmitted.
Example. Same case (): against for GBN and for S&W (: ).
Comparison
With pipe capacity packets, neglecting :
| Protocol | |
|---|---|
| S&W | |
| GBN () | |
| SR |
Grafico interattivo: Efficiency rho versus error probability p, pipe capacity C = 10 packets (S&W, GBN with N = 10, SR)
The role of the window shows even without errors (): transmission is continuous only if . For the sender sends frames, waits for the ACK for the rest of the cycle and so works for the fraction of the time; from on and no more window is needed ( is Stop-and-Wait, ).
Grafico interattivo: Utilization rho = min(1, N/C) without errors, with pipe capacity C = 10 packets: grows linearly up to N = C, then stays 1
Conclusions:
- performance depends on the pipe capacity;
- SR is always the best; S&W is the simplest and degrades quickly as the pipe grows, but it is optimal if the pipe capacity is close to 1; on point-to-point links it is often , so S&W is common at the link layer;
- ARQs are also used at other layers (transport with TCP, application): there the pipe may be much larger and GBN and SR are preferred;
- in window protocols the optimal transmission window equals the pipe capacity (in packets); a larger window is fine if the sending pace is regulated by the arrival of ACKs;
- for SR the reception window should be as large as possible, but large (costly) buffers are needed.
Optimal frame size in Selective Repeat
So far the frame size was a given. In reality it can be chosen, and there is a trade-off:
- a long frame has few headers per data bit (low relative overhead), but is more likely to contain at least one wrong bit, and so to be retransmitted entirely;
- a short frame is lost more rarely, but header and CRC weigh heavily on the total.
A value exists that maximizes the useful throughput. It is computed for Selective Repeat (where the only cost of an error is retransmitting the wrong frame).
Quantities. : bitrate available at the link layer [bit/s]; : frame length (data plus overhead) [bit]; : frame overhead (header plus CRC ) [bit]; : bit error probability (bit errors assumed independent and identically distributed, i.i.d.); : frame error probability.
A frame of bits is correct if all its bits are; with independent bit errors the probability is . For small , : With Selective Repeat the utilization factor is and the fraction of useful bits is : the goodput is
Formula (goodput of Selective Repeat as a function of ).
The first factor grows with (less relative overhead); the second decreases (more errors). The product has a maximum. To find it, differentiate with respect to . With , ; by the product rule, and ( natural logarithm): The sign is that of the numerator, because and . Setting (negative, since ) and imposing : , i.e. . Dividing by : and the quadratic formula gives Since , and the root exceeds : the solution with is negative and discarded, the remains. It is a maximum: the numerator is at and is a parabola with negative coefficient; it is positive up to the positive root and negative after. The derivative changes sign from to : rises and then falls, and is the maximum.
Formula (optimal frame size).
Approximation step: for , gives , huge compared with (for and : against ). Then and, dividing by , remains.
Example. Overhead bit.
- : , , bit. The approximation gives . Maximum efficiency: .
- : bit (approximation: ), maximum efficiency .
Grafico interattivo: Selective Repeat efficiency eta(x) = (x - o)/x * (1 - Pb)^x with overhead o = 50 bit: maximum 0.62 at x = 250 bit for Pb = 0.001 and 0.18 at x = 100 bit for Pb = 0.01
Remarks: ARQ performance depends on packet size; the choice can be adaptive with the BER; short packets are preferable when the channel is error-prone (high BER), long ones when the channel is good.
Other formulas for stop-and-wait. With as frame error probability, data , header and ACK of bits (so ): For GBN with a "tight" timeout (i.e. ) the earlier formula can be rewritten , which tends to as , while for S&W even without errors. For SR: and .
Example. Mbit/s, bit, bit, bit, ms, : bit, (). Stop-and-wait: (the denominator is the in bits: bit weigh more than the frame). Selective Repeat: . The link is the same, the difference is all in waiting for ACKs.
Where they are used. Selective Repeat: link layer of mobile systems (5G and earlier generations 4G, LTE, UMTS). Modern TCP (NewReno): Go-Back-N with selective ACKs (SACK) to recover several errors in the same RTT; the newer Wi-Fi (802.11ax, Wi-Fi 6) uses S&W plus SR (LAN - Ethernet and Wi-FiA LAN covers a limited area and is defined by the IEEE 802.x family (802.3 Ethernet, 802.11 Wi-Fi), which splits the link layer into LLC and MAC. Ethernet is connectionless, with no flow control and no ACK; it uses 1-persistent CSMA/CD; the frame is 64 to 1518 bytes (6-byte addresses, type/length, data 46-1500, 4-byte CRC) and the 64 B minimum comes from t_F >= 2 tau_p. From 10 Mbit/s on coax up to 10 Gbit/s on fibre, with full-duplex switches removing collisions. Wi-Fi (802.11) uses CSMA/CA, has BSS (with access point) and ad hoc modes, EBSS with a distribution system, adapts its bitrate to the SNR, and has hidden and exposed terminal problems, partly solved by RTS/CTS and NAV.LAN - Ethernet and Wi-Fi →). TCP uses cumulative ACKs in normal operation and a congestion window that varies dynamically (never beyond a design-fixed ).
Sequence numbers and window size
With bits for the SN there are numbers (reused cyclically). The receiver must not confuse a new packet with an old retransmitted one: for GBN the transmission window can reach at most ; for SR (in some texts the reception window is ). For S&W suffices.
Versione ripasso
- Error control. The CRC detects the error, ARQ (Automatic Repeat reQuest) makes the link reliable with acknowledgments: if the sender receives no ACK, it retransmits (Data Link Layer and FramingThe data link layer (DLL) delivers a frame from a node to an adjacent node over a link. Services: framing, medium access (MAC) with 48-bit MAC addresses, flow control, error detection and correction. It splits into DLC (framing, error and flow control) and MAC (shared medium access). Framing delimits frames with a flag: byte-oriented protocols (8-bit flag, ESC) use byte stuffing, bit-oriented ones (flag 01111110) use bit stuffing, which inserts a 0 after every five consecutive 1s.Data Link Layer and Framing →). Alternative: FEC, which corrects without retransmitting.
- Acknowledgments. ACK, NACK (refusal for now, e.g. full buffer). Cumulative ACK : frame and all previous ones received. Selective ACK (SACK): the set of those received, e.g. with a bit mask.
- Requirements. Accuracy: correct delivery, once and only once, in order (resequencing buffer). Efficiency: no useless retransmissions and no idle time.
- Deadlock. If the frame is lost, the receiver sends no ACK and the sender would wait forever: solution, the timeout.
- Duplicates. If the ACK is lost, the frame is resent and delivered twice: solution, the sequence number (SN). The receiver discards the duplicate but resends the ACK.
Quantities
- frame (header + payload), , ACK time, one-way propagation, (one cycle, ), failure probability, utilization, efficiency.
- Failures before the first success: geometric, (e.g. : failures per delivered frame).
Stop-and-Wait
- One frame at a time, wait for the ACK. States: ready (send, copy, timer) and waiting (timeout: resend; : stop timer, go ready). SN and ACK numbers modulo ; the ACK number announces the next expected packet.
- Example (lost ACK). SN 0 sent, lost, timeout, SN 0 resent; the receiver recognizes the duplicate, does not deliver it, resends ; the sender goes on with frame 1.
- Efficiency. A failure costs (with ): , so , .
- Example. Mbit/s, kbit, ms: ms; : ; : . The pipe holds packets, but one is sent.
Sliding window
- Sender. Window : , ; packets in flight. with slides the window: .
- Receiver. Window : ; delivers upward only in sequence; outside window: discard; : store; : deliver up to the first gap; always answers .
Go-Back-N
- Window , reception window : the receiver discards every out-of-order packet; at the timeout the sender resends from the first unacknowledged frame onward.
- Example (, SN 3 lost). 4-7 discarded (repeated ); timeout; 3-7 resent: packets retransmitted although 4-7 had arrived.
- Continuous transmission: (window pipe capacity); the timeout is at least . Each failed attempt costs : .
- Formula. , . With , .
- Example. , : .
Selective Repeat
- Reception window : the receiver stores out-of-order packets and delivers them when the sequence is consecutive; at the timeout only the missing frame is resent. One RTO per packet or one per window.
- Example (same scenario). 4-7 stored, only 3 resent, then 3-7 delivered and : packet retransmitted.
- Formula. A failure costs : , so , .
- Example (, pipe of 10). SR , GBN , S&W .
Comparison
- Pipe capacity : S&W ; GBN () ; SR .
- Without errors continuous transmission needs : for , ( is S&W, ).
- SR is always the best; S&W is simplest and degrades as the pipe grows, but is optimal when (point-to-point links), hence common at the link layer. At transport (TCP) the pipe is larger and GBN and SR are preferred. Optimal window = pipe capacity in packets; SR wants a large reception window (costly buffers).
Optimal frame size in SR
- A long frame has low relative overhead but is more likely to contain an error; a short one is the opposite. With frame length , overhead , bit error probability (i.i.d.): .
- Goodput: . Setting gives and, with the positive root,
- Examples ( bit). : bit, efficiency . : bit, efficiency .
- Conclusion: short packets are better when the channel errs (high BER), long ones when it is good; the choice can be adaptive.
- Stop-and-wait in bits: . Example ( Mbit/s, , bit, ms, ): , , .
- Use. SR in the link layer of mobile systems (5G, 4G, LTE, UMTS); modern TCP (NewReno): GBN with SACK; Wi-Fi 6 uses S&W plus SR (LAN - Ethernet and Wi-FiA LAN covers a limited area and is defined by the IEEE 802.x family (802.3 Ethernet, 802.11 Wi-Fi), which splits the link layer into LLC and MAC. Ethernet is connectionless, with no flow control and no ACK; it uses 1-persistent CSMA/CD; the frame is 64 to 1518 bytes (6-byte addresses, type/length, data 46-1500, 4-byte CRC) and the 64 B minimum comes from t_F >= 2 tau_p. From 10 Mbit/s on coax up to 10 Gbit/s on fibre, with full-duplex switches removing collisions. Wi-Fi (802.11) uses CSMA/CA, has BSS (with access point) and ad hoc modes, EBSS with a distribution system, adapts its bitrate to the SNR, and has hidden and exposed terminal problems, partly solved by RTS/CTS and NAV.LAN - Ethernet and Wi-Fi →).
Sequence numbers
- With bits: numbers, reused cyclically. GBN: . SR: . S&W: .
- Typical mistakes: counting per failure in GBN (it is ); forgetting that the ACK number is the next expected packet; using a window smaller than the pipe capacity and expecting continuous transmission; forgetting that a higher bit error probability calls for shorter frames.