Salta al contenuto
Note per Studenti ARQ Protocols - Stop-and-Wait, Go-Back-N and Selective Repeat Report

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 (ACKiACK_i): frame ii 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 N+1N+1 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-NN header then contains fields such as: type, SN, ACK, and the CRC at the end.

Quantities used in the formulas

Symbol Meaning
CC link-layer bitrate [bit/s]
F=H+IF=H+I frame size: header HH + payload II [bit]
tF=F/Ct_F=F/C frame transmission time
tI=I/Ct_I=I/C transmission time of the data only
tAt_A ACK transmission time
τp\tau_p propagation delay (one way)
tG=tF+2τp+tAt_G=t_F+2\tau_p+t_A time to transmit a packet and receive the ACK (one cycle, i.e. the time of a successful transmission)
tTt_T total transmission time of the frame (including retransmissions)
pp probability that a transmission (frame or ACK) fails
ρ\rho utilization factor
η\eta efficiency

The time tGt_G coincides with the RTTRTT of 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 → (frame and ACK included).

Definition (utilization and efficiency). With E[tT]E[t_T] the mean time to successfully deliver a frame: ρ=tFE[tT],η=tIE[tT]=ρ tItF=ρ IF.\rho=\frac{t_F}{E[t_T]},\qquad \eta=\frac{t_I}{E[t_T]}=\rho\,\frac{t_I}{t_F}=\rho\,\frac IF. ρ\rho is the fraction of time the sender is sending frames, η\eta the fraction in which it is sending useful data (without header).

If retransmissions are independent, each with failure probability pp, the number XX of failures before the first success is a geometric variable with P(X=k)=pk(1−p)P(X=k)=p^k(1-p) and mean E[X]=p1−p.E[X]=\frac p{1-p}. Derivation: E[X]=∑k=0∞k pk(1−p)=(1−p) p∑k=1∞k pk−1E[X]=\sum_{k=0}^{\infty}k\,p^k(1-p)=(1-p)\,p\sum_{k=1}^{\infty}k\,p^{k-1}, and the sum is the derivative of the geometric series ∑k≥0pk=11−p\sum_{k\ge0}p^k=\frac1{1-p}, i.e. 1(1−p)2\frac1{(1-p)^2}. So E[X]=(1−p) p⋅1(1−p)2=p1−pE[X]=(1-p)\,p\cdot\frac1{(1-p)^2}=\frac p{1-p}. Check: with p=0.1p=0.1 there are on average 0.1/0.9=0.110.1/0.9=0.11 failures per delivered frame; with p=0.5p=0.5, 11 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 ii arrives from above: it sends it, keeps a copy, starts the timer) and waiting (if the timeout expires it resends frame ii and restarts the timer; if ACKiACK_i 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-22 arithmetic). ACK number x+1x+1 announces that packet x+1x+1 is expected: the ACK number always announces the sequence number of the next expected packet. If packet 00 arrived fine the receiver sends ACK 1ACK\,1 (it expects 11); if 11 arrived it sends ACK 0ACK\,0.

Example (lost ACK). The sender sends frame SN 00; the receiver gets it and generates ACK 1ACK\,1, which is lost. The timeout expires, the sender resends frame SN 00. The receiver expects 11 but receives 00: it recognizes a duplicate, does not deliver it upward, but resends ACK 1ACK\,1 (it keeps waiting for 11). The sender finally receives ACK 1ACK\,1 and can send frame 11.

Efficiency of Stop-and-Wait

A successful transmission occupies tG=tF+2τp+tAt_G=t_F+2\tau_p+t_A: the frame (tFt_F), its propagation (τp\tau_p), the ACK (tAt_A) and its return propagation (τp\tau_p). Each failure costs exactly tGt_G if the timeout is the minimum possible (t0=tGt_0=t_G). Hence E[tT]=tG+E[X] tG=tG+p1−p tG=tG1−p=tF+2τp+tA1−p.E[t_T]=t_G+E[X]\,t_G=t_G+\frac p{1-p}\,t_G=\frac{t_G}{1-p}=\frac{t_F+2\tau_p+t_A}{1-p}.

Formula (Stop-and-Wait). ρSW=tFE[tT]=tF(1−p)tF+2τp+tA=tF(1−p)tG,ηSW=ρSWIF.\rho_{SW}=\frac{t_F}{E[t_T]}=\frac{t_F(1-p)}{t_F+2\tau_p+t_A}=\frac{t_F(1-p)}{t_G},\qquad \eta_{SW}=\rho_{SW}\frac IF.

Note: only the last (successful) transmission counts as "useful"; this is why a single tFt_F appears in the numerator.

Example. C=1C=1 Mbit/s, F=10F=10 kbit (tF=10t_F=10 ms), τp=25\tau_p=25 ms, tA≈0t_A\approx0: tG=10+50=60t_G=10+50=60 ms. Without errors (p=0p=0): ρ=10/60=16.7 %\rho=10/60=16.7\,\%: the link is used one sixth of the time. With p=0.1p=0.1: E[tT]=60/0.9=66.7E[t_T]=60/0.9=66.7 ms, ρ=0.9⋅10/60=15 %\rho=0.9\cdot10/60=15\,\%. The bottleneck is the pipe capacity: tG/tF=6t_G/t_F=6 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 NN: [SNmin,SNmax][SN_{min},SN_{max}] with

  • SNminSN_{min}: SN of the first unacknowledged packet;
  • SNnxtSN_{nxt}: SN of the next packet that can be sent;
  • SNmax=SNmin+N−1SN_{max}=SN_{min}+N-1: SN of the last packet sendable with the current window;
  • SNnxt−SNminSN_{nxt}-SN_{min} packets are in flight (sent but not yet acknowledged; kept in the sender buffer), at most NN.

Receiver. It has a reception window of size MM: [RNmin,RNmin+M−1][RN_{min},RN_{min}+M-1], the SNs it can accept (depends on the buffer).

  • RNminRN_{min}: SN of the next packet expected in order;
  • MM: 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 SN=RNminSN=RN_{min} arrives.

Operations.

  • If the sender receives ACK(n)ACK(n) with SNmin<n≤SNmaxSN_{min}<n\le SN_{max} the window slides: SNmin=nSN_{min}=n (cumulative ACK) and SNmax=SNmin+N−1SN_{max}=SN_{min}+N-1.
  • When the packet with SN=xSN=x arrives at the receiver: if xx is outside the reception window it is discarded; if x>RNminx>RN_{min} it is stored in the buffer; if x=RNminx=RN_{min}, RNminRN_{min} moves to the SN of the first missing packet of the sequence and the receiver delivers upward the packets up to the new RNminRN_{min}.
  • The receiver answers with ACK(RNmin)ACK(RN_{min}) (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 NN, reception window M=1M=1 (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 (N=5N=5, packet SN 3 lost). The sender sends SN 1-5. The receiver gets 1 and 2 and answers ACK(2)ACK(2) and ACK(3)ACK(3) (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 ACK(3)ACK(3), 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 ACK(4)ACK(4),... Total: 5=N5=N 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 NN packets: N tF≥tGN\,t_F\ge t_G, i.e. N≥tGtF(window at least the pipe capacity in packets).N\ge\frac{t_G}{t_F}\quad(\text{window at least the pipe capacity in packets}). The timeout must also be at least t0≥N tFt_0\ge N\,t_F (but not less than tGt_G).

If a packet fails, recovering it costs N tFN\,t_F. Reason: after sending the faulty frame the sender keeps sending the following ones (the window has NN frames, so N tFN\,t_F seconds of transmission); only when the timeout t0=N tFt_0=N\,t_F 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 N tFN\,t_F, not tFt_F, while the last, successful, transmission counts only tFt_F. With E[X]E[X] failures on average: E[tT]=tF+E[X] N tF=tF+p1−p N tF.E[t_T]=t_F+E[X]\,N\,t_F=t_F+\frac p{1-p}\,N\,t_F.

Formula (Go-Back-N, window N≥tG/tFN\ge t_G/t_F). ρGBN=tFE[tT]=1−p1+(N−1) p,ηGBN=ρGBNIF=I(1−p)F[(N−1)p+1].\rho_{GBN}=\frac{t_F}{E[t_T]}=\frac{1-p}{1+(N-1)\,p},\qquad \eta_{GBN}=\rho_{GBN}\frac IF=\frac{I(1-p)}{F[(N-1)p+1]}.

Step: divide numerator and denominator by tFt_F, ρ=11+pN1−p\rho=\frac{1}{1+\frac{pN}{1-p}}, and multiply top and bottom by (1−p)(1-p): ρ=1−p(1−p)+pN=1−p1+(N−1)p\rho=\frac{1-p}{(1-p)+pN}=\frac{1-p}{1+(N-1)p}. Without errors (p=0p=0) ρ=1\rho=1: 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. N=10N=10 (pipe of 1010 packets), p=0.1p=0.1: ρGBN=0.9/(1+9⋅0.1)=0.9/1.9=47.4 %\rho_{GBN}=0.9/(1+9\cdot0.1)=0.9/1.9=47.4\,\%. In time: E[tT]=tF (1+0.10.9⋅10)=2.11 tFE[t_T]=t_F\,(1+\frac{0.1}{0.9}\cdot10)=2.11\,t_F, of which 1.11 tF1.11\,t_F are retransmissions of whole windows.

Selective Repeat (SR-ARQ)

Definition (Selective Repeat). Reception window equal to the transmission window (M=NM=N): the receiver accepts and stores also out-of-order packets (up to MM) 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, N=5N=5). SN 3 lost. The receiver stores 4, 5, 6, 7 and keeps answering ACK(3)ACK(3). 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 ACK(8)ACK(8). Total: 11 packet retransmitted.

Efficiency. A retransmission lasts only tFt_F (the window is not resent): each failure costs tFt_F rather than N tFN\,t_F, i.e. in the GBN formula set N=1N=1 in the cost term: E[tT]=tF+p1−p tF=tF1−p.E[t_T]=t_F+\frac p{1-p}\,t_F=\frac{t_F}{1-p}.

Formula (Selective Repeat). ρSR=tFE[tT]=1−p,ηSR=ρSRIF=I(1−p)F.\rho_{SR}=\frac{t_F}{E[t_T]}=1-p,\qquad \eta_{SR}=\rho_{SR}\frac IF=\frac{I(1-p)}{F}.

With p=0p=0, SR == GBN and η\eta is maximum. With N>1N>1 and p>0p>0 SR has higher throughput than GBN, because correctly received PDUs are never retransmitted.

Example. Same case (p=0.1p=0.1): ρSR=90 %\rho_{SR}=90\,\% against 47.4 %47.4\,\% for GBN and 9 %9\,\% for S&W (tG/tF=10t_G/t_F=10: ρSW=0.9/10\rho_{SW}=0.9/10).

Comparison

With pipe capacity C=tG/tFC=t_G/t_F packets, neglecting tAt_A:

Protocol ρ\rho
S&W 1−pC\dfrac{1-p}{C}
GBN (N=CN=C) 1−p1+(C−1)p\dfrac{1-p}{1+(C-1)p}
SR 1−p1-p

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 (p=0p=0): transmission is continuous only if N≥CN\ge C. For N<CN<C the sender sends NN frames, waits for the ACK for the rest of the cycle tGt_G and so works for the fraction N tF/tG=N/CN\,t_F/t_G=N/C of the time; from N=CN=C on ρ=1\rho=1 and no more window is needed (N=1N=1 is Stop-and-Wait, ρ=1/C\rho=1/C).

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 ≈1\approx1, 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 FF 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. RLLR_{LL}: bitrate available at the link layer [bit/s]; xx: frame length (data plus overhead) [bit]; oo: frame overhead (header HH plus CRC CC) [bit]; PbP_b: bit error probability (bit errors assumed independent and identically distributed, i.i.d.); pp: frame error probability.

A frame of xx bits is correct if all its bits are; with independent bit errors the probability is (1−Pb)x(1-P_b)^x. For small xPbxP_b, (1−Pb)x≃1−xPb(1-P_b)^x\simeq1-xP_b: p=1−(1−Pb)x  (≃xPb if xPb≪1).p=1-(1-P_b)^x\ \ (\simeq xP_b\ \text{if}\ xP_b\ll1). With Selective Repeat the utilization factor is ρ=1−p\rho=1-p and the fraction of useful bits is x−ox\frac{x-o}{x}: the goodput is

Formula (goodput of Selective Repeat as a function of xx). g(x)=RLL η(x)=RLL x−ox (1−p)=RLL x−ox (1−Pb)x.g(x)=R_{LL}\,\eta(x)=R_{LL}\,\frac{x-o}{x}\,(1-p)=R_{LL}\,\frac{x-o}{x}\,(1-P_b)^x.

The first factor (x−o)/x(x-o)/x grows with xx (less relative overhead); the second (1−Pb)x(1-P_b)^x decreases (more errors). The product has a maximum. To find it, differentiate gg with respect to xx. With a=1−Pba=1-P_b, g(x)=RLL(1−ox)axg(x)=R_{LL}\bigl(1-\frac ox\bigr)a^x; by the product rule, ddx(1−ox)=ox2\frac d{dx}\bigl(1-\frac ox\bigr)=\frac o{x^2} and ddxax=axln⁡a\frac{d}{dx}a^x=a^x\ln a (ln⁡\ln natural logarithm): dgdx=RLL[ox2 ax+(1−ox)axln⁡a]=RLL ax o+x(x−o)ln⁡ax2.\frac{dg}{dx}=R_{LL}\Bigl[\frac o{x^2}\,a^x+\Bigl(1-\frac ox\Bigr)a^x\ln a\Bigr]=R_{LL}\,a^x\,\frac{o+x(x-o)\ln a}{x^2}. The sign is that of the numerator, because x>0x>0 and ax>0a^x>0. Setting ξ≜ln⁡(1−Pb)\xi\triangleq\ln(1-P_b) (negative, since 1−Pb<11-P_b<1) and imposing dg/dx=0dg/dx=0: o+ξx(x−o)=0o+\xi x(x-o)=0, i.e. ξx2−ξo x+o=0\xi x^2-\xi o\,x+o=0. Dividing by ξ\xi: x2−o x+oξ=0x^2-o\,x+\frac o\xi=0 and the quadratic formula gives x1,2=o±o2−4oξ2.x_{1,2}=\frac{o\pm\sqrt{o^2-\dfrac{4o}{\xi}}}{2}. Since ξ<0\xi<0, −4o/ξ>0-4o/\xi>0 and the root exceeds oo: the solution with −- is negative and discarded, the ++ remains. It is a maximum: the numerator o+ξx(x−o)o+\xi x(x-o) is o>0o>0 at x=0x=0 and is a parabola with negative x2x^2 coefficient; it is positive up to the positive root and negative after. The derivative changes sign from ++ to −-: gg rises and then falls, and xoptx_{opt} is the maximum.

Formula (optimal frame size). xopt=o+o2−4oln⁡(1−Pb)2 ≃ o2+oPb(Pb≪1).x_{opt}=\frac{o+\sqrt{o^2-\dfrac{4o}{\ln(1-P_b)}}}{2}\ \simeq\ \frac o2+\sqrt{\frac o{P_b}}\quad(P_b\ll1).

Approximation step: for Pb≪1P_b\ll1, ln⁡(1−Pb)≃−Pb\ln(1-P_b)\simeq-P_b gives −4oξ≃4oPb-\frac{4o}{\xi}\simeq\frac{4o}{P_b}, huge compared with o2o^2 (for o=50o=50 and Pb=10−3P_b=10^{-3}: 2⋅1052\cdot10^5 against 25002500). Then o2+4oPb≃2oPb\sqrt{o^2+\frac{4o}{P_b}}\simeq2\sqrt{\frac o{P_b}} and, dividing by 22, o2+oPb\frac o2+\sqrt{\frac o{P_b}} remains.

Example. Overhead o=50o=50 bit.

  • Pb=10−3P_b=10^{-3}: ln⁡(1−Pb)=−1.0005⋅10−3\ln(1-P_b)=-1.0005\cdot10^{-3}, −4o/ξ=1.9990⋅105-4o/\xi=1.9990\cdot10^{5}, xopt=50+2500+199 9002=50+449.92≃250x_{opt}=\dfrac{50+\sqrt{2500+199\,900}}{2}=\dfrac{50+449.9}{2}\simeq250 bit. The approximation gives 25+50 000=248.625+\sqrt{50\,000}=248.6. Maximum efficiency: 200250⋅0.999250=0.8⋅0.779=0.62\frac{200}{250}\cdot0.999^{250}=0.8\cdot0.779=0.62.
  • Pb=10−2P_b=10^{-2}: xopt≃100x_{opt}\simeq100 bit (approximation: 25+5000=95.725+\sqrt{5000}=95.7), maximum efficiency 50100⋅0.99100=0.5⋅0.366=0.18\frac{50}{100}\cdot0.99^{100}=0.5\cdot0.366=0.18.

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 pp as frame error probability, data II, header HH and ACK of AA bits (so F=I+HF=I+H): ηSW=IFρ=I(1−p)I+H+A+2RLLτp ≃ I [1−(I+H)Pb]I+H+A+2RLLτp.\eta_{SW}=\frac IF\rho=\frac{I(1-p)}{I+H+A+2R_{LL}\tau_p}\ \simeq\ \frac{I\,[1-(I+H)P_b]}{I+H+A+2R_{LL}\tau_p}. For GBN with a "tight" timeout to=NtFt_o=N t_F (i.e. NtF≈RTTN t_F\approx RTT) the earlier formula can be rewritten ρGBN=F(1−p)F+(A+2RLLτp) p\rho_{GBN}=\dfrac{F(1-p)}{F+(A+2R_{LL}\tau_p)\,p}, which tends to 11 as p→0p\to0, while for S&W ρ→tF/RTT<1\rho\to t_F/RTT<1 even without errors. For SR: ρ=1−p≃1−(I+H)Pb\rho=1-p\simeq1-(I+H)P_b and η=IF(1−p)\eta=\frac IF(1-p).

Example. RLL=1R_{LL}=1 Mbit/s, I=1000I=1000 bit, H=100H=100 bit, A=100A=100 bit, τp=1\tau_p=1 ms, Pb=10−5P_b=10^{-5}: F=1100F=1100 bit, p=1−(1−10−5)1100=0.01094p=1-(1-10^{-5})^{1100}=0.01094 (≃FPb=0.011\simeq FP_b=0.011). Stop-and-wait: η=1000⋅0.989061000+100+100+2000=0.309\eta=\dfrac{1000\cdot0.98906}{1000+100+100+2000}=0.309 (the denominator is the RTTRTT in bits: 2RLLτp=20002R_{LL}\tau_p=2000 bit weigh more than the frame). Selective Repeat: η=10001100⋅0.98906=0.899\eta=\frac{1000}{1100}\cdot0.98906=0.899. 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 cwndcwnd that varies dynamically (never beyond a design-fixed WmaxW_{max}).

Sequence numbers and window size

With kk bits for the SN there are 2k2^k 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 N≤2k−1N\le2^k-1; for SR N=M≤2k−1N=M\le2^{k-1} (in some texts the reception window is 2m−12^{m-1}). For S&W k=1k=1 suffices.

For medium access on shared links see Multiple Access Protocols - ALOHA and CSMAWhen several stations share a medium a medium access (MAC) protocol must decide who transmits. Random access: pure ALOHA (transmit immediately, vulnerable time 2 t_F), slotted ALOHA (start only at slot boundaries, vulnerable t_F), CSMA (listen before talking, vulnerable tau_p) with 1-persistent, non-persistent and p-persistent variants, CSMA/CD (detects collisions while transmitting: needs t_F >= 2 tau_p, hence a minimum frame) and the Wi-Fi CSMA/CA (IFS, contention window with backoff, ACK, RTS/CTS and NAV). Controlled access: reservation, polling, token. Channelization: FDMA, TDMA, OFDMA, CDMA, SDMA.Multiple Access Protocols - ALOHA and CSMA →.

Versione ripasso

Quantities

  • F=H+IF=H+I frame (header + payload), tF=F/Ct_F=F/C, tAt_A ACK time, τp\tau_p one-way propagation, tG=tF+2τp+tAt_G=t_F+2\tau_p+t_A (one cycle, =RTT=RTT), pp failure probability, ρ=tFE[tT]\rho=\frac{t_F}{E[t_T]} utilization, η=ρIF\eta=\rho\frac{I}{F} efficiency.
  • Failures before the first success: geometric, E[X]=p1−pE[X]=\frac{p}{1-p} (e.g. p=0.1p=0.1: 0.110.11 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; ACKiACK_i: stop timer, go ready). SN and ACK numbers modulo 22; the ACK number announces the next expected packet.
  • Example (lost ACK). SN 0 sent, ACK 1ACK\,1 lost, timeout, SN 0 resent; the receiver recognizes the duplicate, does not deliver it, resends ACK 1ACK\,1; the sender goes on with frame 1.
  • Efficiency. A failure costs tGt_G (with t0=tGt_0=t_G): E[tT]=tG1−pE[t_T]=\frac{t_G}{1-p}, so ρSW=tF(1−p)tG\rho_{SW}=\frac{t_F(1-p)}{t_G}, ηSW=ρSWIF\eta_{SW}=\rho_{SW}\frac IF.
  • Example. C=1C=1 Mbit/s, F=10F=10 kbit, τp=25\tau_p=25 ms: tG=60t_G=60 ms; p=0p=0: ρ=16.7 %\rho=16.7\,\%; p=0.1p=0.1: ρ=15 %\rho=15\,\%. The pipe holds tG/tF=6t_G/t_F=6 packets, but one is sent.

Sliding window

  • Sender. Window NN: [SNmin,SNmax][SN_{min},SN_{max}], SNmax=SNmin+N−1SN_{max}=SN_{min}+N-1; SNnxt−SNminSN_{nxt}-SN_{min} packets in flight. ACK(n)ACK(n) with SNmin<n≤SNmaxSN_{min}<n\le SN_{max} slides the window: SNmin=nSN_{min}=n.
  • Receiver. Window MM: [RNmin,RNmin+M−1][RN_{min},RN_{min}+M-1]; delivers upward only in sequence; outside window: discard; x>RNminx>RN_{min}: store; x=RNminx=RN_{min}: deliver up to the first gap; always answers ACK(RNmin)ACK(RN_{min}).

Go-Back-N

  • Window NN, reception window M=1M=1: the receiver discards every out-of-order packet; at the timeout the sender resends from the first unacknowledged frame onward.
  • Example (N=5N=5, SN 3 lost). 4-7 discarded (repeated ACK(3)ACK(3)); timeout; 3-7 resent: 5=N5=N packets retransmitted although 4-7 had arrived.
  • Continuous transmission: N≥tGtFN\ge\frac{t_G}{t_F} (window ≥\ge pipe capacity); the timeout is at least N tFN\,t_F. Each failed attempt costs N tFN\,t_F: E[tT]=tF+p1−pN tFE[t_T]=t_F+\frac{p}{1-p}N\,t_F.
  • Formula. ρGBN=1−p1+(N−1)p\rho_{GBN}=\dfrac{1-p}{1+(N-1)p}, ηGBN=ρGBNIF\eta_{GBN}=\rho_{GBN}\frac IF. With p=0p=0, ρ=1\rho=1.
  • Example. N=10N=10, p=0.1p=0.1: ρ=0.9/1.9=47.4 %\rho=0.9/1.9=47.4\,\%.

Selective Repeat

  • Reception window M=NM=N: 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 ACK(8)ACK(8): 11 packet retransmitted.
  • Formula. A failure costs tFt_F: E[tT]=tF1−pE[t_T]=\frac{t_F}{1-p}, so ρSR=1−p\rho_{SR}=1-p, ηSR=(1−p)IF\eta_{SR}=(1-p)\frac IF.
  • Example (p=0.1p=0.1, pipe of 10). SR 90 %90\,\%, GBN 47.4 %47.4\,\%, S&W 9 %9\,\%.

Comparison

  • Pipe capacity C=tG/tFC=t_G/t_F: S&W 1−pC\frac{1-p}{C}; GBN (N=CN=C) 1−p1+(C−1)p\frac{1-p}{1+(C-1)p}; SR 1−p1-p.
  • Without errors continuous transmission needs N≥CN\ge C: for N<CN<C, ρ=N/C\rho=N/C (N=1N=1 is S&W, ρ=1/C\rho=1/C).
  • SR is always the best; S&W is simplest and degrades as the pipe grows, but is optimal when C≈1C\approx1 (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 xx, overhead oo, bit error probability PbP_b (i.i.d.): p=1−(1−Pb)xp=1-(1-P_b)^x.
  • Goodput: g(x)=RLLx−ox(1−Pb)xg(x)=R_{LL}\frac{x-o}{x}(1-P_b)^x. Setting dgdx=0\frac{dg}{dx}=0 gives o+x(x−o)ln⁡(1−Pb)=0o+x(x-o)\ln(1-P_b)=0 and, with the positive root,

xopt=o+o2−4oln⁡(1−Pb)2≃o2+oPb(Pb≪1).x_{opt}=\frac{o+\sqrt{o^2-\frac{4o}{\ln(1-P_b)}}}{2}\simeq\frac o2+\sqrt{\frac o{P_b}}\quad(P_b\ll1).

Sequence numbers

  • With kk bits: 2k2^k numbers, reused cyclically. GBN: N≤2k−1N\le2^k-1. SR: N=M≤2k−1N=M\le2^{k-1}. S&W: k=1k=1.
  • Typical mistakes: counting tFt_F per failure in GBN (it is N tFN\,t_F); 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.

Teoria collegata