Salta al contenuto
Note per Studenti Analytical Model of TCP Send Rate Report

Analytical Model of TCP Send Rate

In questa pagina 5
In questa pagina 3

The model answers: given packet loss probability pp and round-trip time RTT, how many segments per second does a TCP flow send on average at steady state? The result is a closed formula used to compute path throughput. It models TCP Reno (TCP Congestion ControlCongestion arises when fast links feed a slow one, router queues fill and packets are lost or delayed, possibly up to network collapse; TCP controls its congestion window cwnd using loss feedback (timeout or three duplicate ACKs): slow start doubles cwnd every RTT up to the threshold ssthresh, then congestion avoidance adds 1 MSS per RTT, and on a loss ssthresh becomes W/2; variants differ in reaction to three dupACKs: Tahoe restarts from cwnd=1, Reno uses fast recovery (ssthresh=cwnd/2, cwnd=ssthresh+3, +1 per further dupACK), NewReno handles partial ACKs and recovers several losses in one window, SACK acknowledges received blocks and resends only what is missing.TCP Congestion Control →); symbols as in TCP - Connection, Reliability and Flow ControlTCP is the connection-oriented, reliable transport protocol that turns IP's unreliable service into an ordered byte stream without errors or duplicates; the connection opens with a three-way handshake (SYN, SYN+ACK, ACK) and closes with FIN segments, bytes are numbered (sequence number = first byte of the segment, cumulative ACK = next byte expected), the sender may transmit min(rwnd, cwnd) unacknowledged bytes (rwnd, the receiver window in a 16-bit field, is flow control), errors are handled with checksum, ACKs, retransmission timeout and fast retransmit after three duplicate ACKs, and to fill the pipe the window must reach the bandwidth-delay product, with maximum throughput MSS times Wmax over RTT.TCP - Connection, Reliability and Flow Control →.

Assumptions

  • Rounds. Time is divided into rounds of duration RTT; in each round the sender transmits WW packets (the congestion window, which varies). RTT is constant and independent of WW.
  • Delayed ACKs. One ACK every bb packets (usually b=2b=2): WW packets in a round give W/bW/b ACKs, each growing the window by 1/W1/W in congestion avoidance, so the window grows by 1 every bb rounds.
  • Congestion avoidance only (slow start ignored: long flows).
  • Losses. Each packet is lost with probability pp; losses in different rounds are independent, but within a round they are correlated: if a packet is lost, all later packets of that round are lost too.
  • All packets have the same size (count packets, not bytes). Heavy traffic: the sender always has data. At first Wmax⁡W_{\max} is infinite.

Two steps: (1) losses signalled only by K=3K=3 duplicate ACKs; (2) losses signalled by three dupACKs and timeouts.

Definition (send rate). With NtN_t the number of packets sent in [0,t][0,t], the long-term send rate is B=lim⁡t→∞Nt/tB=\lim_{t\to\infty}N_t/t [packets/s]. It is the send rate (lost packets counted); goodput is B(1−p)B(1-p).

Step 1: only triple-duplicate losses

TDP cycles

The window is halved at each triple-dupACK event, producing a sawtooth. A TDP (triple duplicate period) is the period between two consecutive halvings. In the ii-th TDP: AiA_i is the duration, WiW_i the window at the end, YiY_i the number of packets sent. The sequence (Yi,Ai)(Y_i,A_i) is a renewal reward process, so

Formula. B=E[Y]E[A].B=\frac{E[Y]}{E[A]}.

Because after nn cycles N=∑YiN=\sum Y_i packets were sent in time t=∑Ait=\sum A_i, and by the law of large numbers the sample means converge to E[Y]E[Y] and E[A]E[A].

Geometry of a TDP

αi\alpha_i is the position of the first lost packet in the TDP (counting from 1). XiX_i is the round where the loss occurs (the second-to-last round); the next round is the last, in which βi\beta_i packets are sent. After the loss the sender does not yet know and sends more packets.

Window relation. The window grows by 1 every bb rounds for XiX_i rounds starting from Wi−1/2W_{i-1}/2: Wi=Wi−12+Xib−1.(1)W_i=\frac{W_{i-1}}{2}+\frac{X_i}{b}-1.\tag{1} Example: Wi−1/2=3W_{i-1}/2=3, b=2b=2, Xi=10X_i=10: window values 3,3,4,4,5,5,6,6,7,73,3,4,4,5,5,6,6,7,7 and Wi=3+5−1=7W_i=3+5-1=7.

Packets sent. The lost packet is number αi\alpha_i; Wi−1W_i-1 more packets leave before the loss is detected (if the lost packet is the kk-th of the second-to-last round, Wi−kW_i-k follow it there and βi=k−1\beta_i=k-1 are sent in the last round): Yi=αi+Wi−1.(2)Y_i=\alpha_i+W_i-1.\tag{2}

First computation of E[Y]E[Y]. With independent losses the position of the first loss is geometric: P[α=k]=(1−p)k−1pP[\alpha=k]=(1-p)^{k-1}p, and with q=1−pq=1-p, E[α]=∑k≥1qk−1(1−q) k=∑k≥0qk=11−q=1p.E[\alpha]=\sum_{k\ge1}q^{k-1}(1-q)\,k=\sum_{k\ge0}q^k=\frac1{1-q}=\frac1p. From (2): E[Y]=E[α]−1+E[W]=1−pp+E[W].(3)E[Y]=E[\alpha]-1+E[W]=\frac{1-p}{p}+E[W].\tag{3}

Second computation of E[Y]E[Y] (from the shape of the TDP). The window takes values Wi−1/2+kW_{i-1}/2+k, each for bb rounds, k=0,…,Xi/b−1k=0,\dots,X_i/b-1; then βi\beta_i packets in the last round: Yi=∑k=0Xi/b−1(Wi−12+k)b+βi=Wi−12Xi+Xi2(Xib−1)+βi.Y_i=\sum_{k=0}^{X_i/b-1}\left(\frac{W_{i-1}}{2}+k\right)b+\beta_i=\frac{W_{i-1}}{2}X_i+\frac{X_i}{2}\left(\frac{X_i}{b}-1\right)+\beta_i. Using (1), Xi/b−1=Wi−Wi−1/2X_i/b-1=W_i-W_{i-1}/2, so Yi=Xi2(Wi−12+Wi)+βi.(4)Y_i=\frac{X_i}{2}\left(\frac{W_{i-1}}{2}+W_i\right)+\beta_i.\tag{4} Example (Wi−1/2=3W_{i-1}/2=3, Wi=7W_i=7, Xi=10X_i=10): 102(3+7)=50\tfrac{10}{2}(3+7)=50 packets plus βi\beta_i (directly: 2⋅(3+4+5+6+7)=502\cdot(3+4+5+6+7)=50). Assuming XiX_i and WiW_i independent and stationary, and βi\beta_i uniform on {0,…,Wi−1}\{0,\dots,W_i-1\} so E[β]=E[W]/2E[\beta]=E[W]/2: E[Y]=E[X]2⋅32E[W]+E[β].(5)E[Y]=\frac{E[X]}{2}\cdot\frac32E[W]+E[\beta].\tag{5} From (1) with stationarity, E[W]=E[W]/2+E[X]/b−1E[W]=E[W]/2+E[X]/b-1: E[X]=b2E[W]+b.(6)E[X]=\frac b2E[W]+b.\tag{6}

Equation for E[W]E[W]

Equate (3) and (5) with x=E[W]x=E[W], (6) and E[β]=x/2E[\beta]=x/2: 1−pp+x=(b2x+b)3x4+x2 ⟹ 3b x2+2(3b−2) x−8(1−p)p=0.\frac{1-p}{p}+x=\left(\frac b2x+b\right)\frac{3x}{4}+\frac x2\ \Longrightarrow\ 3b\,x^2+2(3b-2)\,x-\frac{8(1-p)}{p}=0. The positive root is the mean window:

Formula (mean window). E[W]=2−3b3b+(3b−23b)2+8(1−p)3bp → p→0  83bp.E[W]=\frac{2-3b}{3b}+\sqrt{\left(\frac{3b-2}{3b}\right)^2+\frac{8(1-p)}{3bp}}\ \xrightarrow{\,p\to0\,}\ \sqrt{\frac{8}{3bp}}.

Example. b=2b=2, p=0.01p=0.01: E[W]=−0.667+0.444+132=10.84E[W]=-0.667+\sqrt{0.444+132}=10.84 packets (the approximation gives 11.5511.55). For p→0p\to0, E[X]≃2b/(3p)E[X]\simeq\sqrt{2b/(3p)}.

Duration and square-root formula

Formula (mean duration). E[A]=(E[X]+1) RTT≃RTT2b3pE[A]=(E[X]+1)\,\text{RTT}\simeq\text{RTT}\sqrt{\dfrac{2b}{3p}}.

With TD only: B=E[Y]E[A]=1−pp+E[W]RTT(b2E[W]+b+1).B=\frac{E[Y]}{E[A]}=\frac{\frac{1-p}{p}+E[W]}{\text{RTT}\left(\frac b2E[W]+b+1\right)}. For p→0p\to0 the numerator is dominated by 1/p1/p and B≃1/pRTT2b/(3p)B\simeq\dfrac{1/p}{\text{RTT}\sqrt{2b/(3p)}}, giving the square-root formula:

Formula (square root). B(p,b,RTT)=1RTT32bp.(7)B(p,b,\text{RTT})=\frac1{\text{RTT}}\sqrt{\frac{3}{2bp}}.\tag{7}

For b=1b=1 the coefficient is 3/2=1.22\sqrt{3/2}=1.22: B≈1.22/(RTTp)B\approx1.22/(\text{RTT}\sqrt p); for b=2b=2 it is 3/4=0.87\sqrt{3/4}=0.87.

Example. b=2b=2, RTT=100\text{RTT}=100 ms, p=10−4p=10^{-4}: B=10⋅3/(4⋅10−4)=10⋅86.6=866B=10\cdot\sqrt{3/(4\cdot10^{-4})}=10\cdot86.6=866 segments/s. Halving RTT doubles BB; reducing pp by a factor 100 multiplies BB by 10. For p=10−2p=10^{-2} formula (7) gives 86.686.6 seg/s while the exact E[Y]/E[A]E[Y]/E[A] gives 79.479.4: for larger pp the square root overestimates.

Step 2: timeouts as well

With a small window there are not enough packets after the lost one to generate three dupACKs, and a timeout occurs. At timeout W=1W=1 and the first unacknowledged packet is resent; if a timeout follows immediately the timer doubles (up to 64 T064\,T_0), T0T_0 being the first timeout duration.

A cycle consists of a sequence of mim_i TDPs and a timeout sub-cycle: Mi=∑jYij+RiM_i=\sum_jY_{ij}+R_i packets (with RiR_i packets in the timeout sub-cycle) and Si=∑jAij+ZiTOS_i=\sum_jA_{ij}+Z_i^{TO} seconds. So B=E[M]/E[S]B=E[M]/E[S]; with Q=1/E[m]Q=1/E[m]:

Formula (general form). B=E[Y]+Q E[R]E[A]+Q E[ZTO].(8)B=\frac{E[Y]+Q\,E[R]}{E[A]+Q\,E[Z^{TO}]}.\tag{8}

QQ is the probability that a loss indication at the end of a TDP is a timeout (mm is geometric with parameter QQ).

Probability QQ

Let ww be the window in the second-to-last round. The first kk packets arrive, the (k+1)(k+1)-th is lost (and the rest of the round). The kk ACKs allow kk packets in the last round, each generating a dupACK if it arrives: TD if at least 3 dupACKs, timeout otherwise. Define A(w,k)=(1−p)kp1−(1−p)wA(w,k)=\dfrac{(1-p)^kp}{1-(1-p)^w} (first kk correct, given the round has an error) and C(n,m)C(n,m) the probability that the first mm of nn packets in the last round are correct: (1−p)mp(1-p)^mp for m<nm<n and (1−p)n(1-p)^n for m=nm=n. A timeout occurs if k≤2k\le2 or if k≥3k\ge3 but fewer than 3 of the kk last-round packets arrive: Q^(w)=∑k=02A(w,k)+∑k=3w−1A(w,k)∑m=02C(k,m).\hat Q(w)=\sum_{k=0}^{2}A(w,k)+\sum_{k=3}^{w-1}A(w,k)\sum_{m=0}^{2}C(k,m). Summing the geometric series:

Formula. Q^(w)=min⁡{1, 1−(1−p)31−(1−p)w[1+(1−p)3(1−(1−p)w−3)]} → p→0  min⁡{1,3w}.\hat Q(w)=\min\left\{1,\ \frac{1-(1-p)^3}{1-(1-p)^w}\Big[1+(1-p)^3\big(1-(1-p)^{w-3}\big)\Big]\right\}\ \xrightarrow{\,p\to0\,}\ \min\left\{1,\frac3w\right\}.

(The limit follows from (1−p)n≃1−np(1-p)^n\simeq1-np.) Example: w=10w=10, p=0.01p=0.01: Q^=0.331\hat Q=0.331 (versus 3/w=0.303/w=0.30); for w≤3w\le3, Q^=1\hat Q=1. Use Q≃Q^(E[W])Q\simeq\hat Q(E[W]).

Timeout sub-cycle

E[R]E[R]. Each timeout resends one packet; if lost (probability pp) another timeout follows: P[R=i]=pi−1(1−p)P[R=i]=p^{i-1}(1-p) and E[R]=11−p.E[R]=\frac1{1-p}. E[ZTO]E[Z^{TO}]. ii consecutive timeouts last Li=(2i−1)T0L_i=(2^i-1)T_0 for i≤6i\le6 and (63+64(i−6))T0(63+64(i-6))T_0 for i≥7i\ge7 (values 1,3,7,15,31,63,127,191,…1,3,7,15,31,63,127,191,\dots times T0T_0). Averaging: E[ZTO]=T0 f(p)1−p,f(p)=1+p+2p2+4p3+8p4+16p5+32p6.E[Z^{TO}]=T_0\,\frac{f(p)}{1-p},\qquad f(p)=1+p+2p^2+4p^3+8p^4+16p^5+32p^6. (The jj-th timeout happens with probability pj−1p^{j-1} and lasts min⁡{2j−1,64}T0\min\{2^{j-1},64\}T_0; the tail is the geometric series 1/(1−p)1/(1-p).)

Full and approximate models

Formula (full model). B(p,b,RTT,T0)=1−pp+E[W]+Q^(E[W])11−pRTT(b2E[W]+b+1)+Q^(E[W]) T0 f(p)1−p.(9)B(p,b,\text{RTT},T_0)=\frac{\dfrac{1-p}{p}+E[W]+\hat Q(E[W])\dfrac1{1-p}}{\text{RTT}\left(\dfrac b2E[W]+b+1\right)+\hat Q(E[W])\,\dfrac{T_0\,f(p)}{1-p}}.\tag{9}

For small pp, with E[W]≃8/(3bp)E[W]\simeq\sqrt{8/(3bp)}, Q^≃min⁡{1,3/E[W]}=min⁡{1,33bp/8}\hat Q\simeq\min\{1,3/E[W]\}=\min\{1,3\sqrt{3bp/8}\}, numerator ≃1/p\simeq1/p, and f(p)/(1−p)≃1+2p+4p2f(p)/(1-p)\simeq1+2p+4p^2:

Formula (approximate model). B≃1RTT2bp3+T0min⁡{1, 33bp8}p (1+2p+4p2)[seg/s].(10)B\simeq\frac1{\text{RTT}\sqrt{\dfrac{2bp}3}+T_0\min\left\{1,\,3\sqrt{\dfrac{3bp}8}\right\}p\,(1+2p+4p^2)}\quad[\text{seg/s}].\tag{10}

The factor p(1+2p+4p2)p(1+2p+4p^2) is the one used in the course; the original work has p(1+32p2)p(1+32p^2) (similar results: 20.2420.24 versus 20.5620.56 seg/s in the example below). If the window cannot exceed Wmax⁡W_{\max}:

Formula (window cap). BWmax⁡=min⁡{Wmax⁡RTT, B(p,b,RTT,T0)}[packets/s].(11)B^{W_{\max}}=\min\left\{\frac{W_{\max}}{\text{RTT}},\ B(p,b,\text{RTT},T_0)\right\}\quad[\text{packets/s}].\tag{11}

For throughput in bit/s multiply by the payload size in bits.

Accuracy

For b=2b=2, RTT=100\text{RTT}=100 ms, T0=1T_0=1 s (seg/s):

pp square root (7) TD only full (9) approximate (10)
10−410^{-4} 866.0 858.6 856.6 864.1
10−310^{-3} 273.9 266.5 260.6 267.8
10−210^{-2} 86.6 79.4 64.8 70.4
3⋅10−23\cdot10^{-2} 50.0 42.8 25.9 29.1
10−110^{-1} 27.4 20.2 7.1 7.2

For p≲10−3p\lesssim10^{-3} the formulas agree within about 5%. For p≳10−2p\gtrsim10^{-2} the square root overestimates heavily because it ignores timeouts.

Complete example

Path with RTT=27\text{RTT}=27 ms, b=2b=2, T0=1T_0=1 s (T0=max⁡{RTO,1 s}T_0=\max\{\text{RTO},1\text{ s}\}: TCP Retransmission Timeout EstimationTCP retransmits a segment when its ACK does not arrive within the retransmission timeout RTO, which must track the round-trip time: too short causes spurious retransmissions, too long slows recovery; the RTT is measured with one timer per connection, smoothed with an exponential moving average SRTT = (1-alpha) SRTT + alpha rtt with alpha = 1/8, the mean deviation MAD = (1-rho) MAD + rho |rtt - SRTT| with rho = 1/4 is added four times, RTO = SRTT + 4 MAD with a minimum of 1 s, Karn's algorithm ignores samples of retransmitted segments and doubles the RTO at each consecutive timeout up to 64 times, and for a Gaussian RTT the mean deviation equals sigma times the square root of 2 over pi, about 0.797 sigma.TCP Retransmission Timeout Estimation →), Wmax⁡=200W_{\max}=200 segments, TCP payload 14401440 bytes, path loss probability p=0.058740p=0.058740 (from p=1−∏(1−pn)p=1-\prod(1-p_n) over the links crossed).

  1. Cap. Wmax⁡/RTT=200/0.027=7407W_{\max}/\text{RTT}=200/0.027=7407 seg/s: not the limit.
  2. First denominator term. 2bp/3=0.078322bp/3=0.07832, square root 0.279860.27986; RTT2bp/3=0.027⋅0.27986=0.007556\text{RTT}\sqrt{2bp/3}=0.027\cdot0.27986=0.007556 s.
  3. Timeout term. 3bp/8=0.0440553bp/8=0.044055, root 0.209890.20989, triple 0.62970.6297: min⁡{1,0.6297}=0.6297\min\{1,0.6297\}=0.6297 (about 63% of losses end in timeout); p(1+2p+4p2)=0.05874⋅1.13128=0.066451p(1+2p+4p^2)=0.05874\cdot1.13128=0.066451; product with T0=1T_0=1: 0.0418430.041843 s.
  4. Rate. B=1/(0.007556+0.041843)=1/0.049399=20.24B=1/(0.007556+0.041843)=1/0.049399=20.24 seg/s, below the cap.
  5. Throughput. 20.2435⋅1440⋅8=233.220.2435\cdot1440\cdot8=233.2 kbit/s (14401440 bytes =11 520=11\,520 bits per segment).

For comparison, the square root (7) would give 132.3132.3 seg/s (hugely overestimated, no timeouts); the full model (9) gives E[W]=4.003E[W]=4.003, Q^=0.8096\hat Q=0.8096, B=18.88B=18.88 seg/s.

Limits

Valid for steady-state long flows in congestion avoidance (slow start not modelled); RTT assumed constant; losses with fixed probability pp, independent across rounds and correlated within a round (drop-tail); some approximations hold for small pp (XiX_i and WiW_i independent, βi\beta_i uniform); variants such as SACK recover better and exceed the Reno prediction.

Versione ripasso

Setup

Triple-duplicate cycles (TDP)

B=E[Y]/E[A]B=E[Y]/E[A] (renewal reward). Wi=Wi−1/2+Xi/b−1W_i=W_{i-1}/2+X_i/b-1; Yi=αi+Wi−1Y_i=\alpha_i+W_i-1; E[α]=1/pE[\alpha]=1/p (geometric).

  • Two counts of E[Y]E[Y]: E[Y]=1−pp+E[W]E[Y]=\frac{1-p}{p}+E[W] and E[Y]=E[X]2⋅32E[W]+E[W]2E[Y]=\frac{E[X]}{2}\cdot\frac32E[W]+\frac{E[W]}{2}, with E[X]=b2E[W]+bE[X]=\frac b2E[W]+b.
  • Quadratic 3b x2+2(3b−2)x−8(1−p)/p=03b\,x^2+2(3b-2)x-8(1-p)/p=0:

E[W]=2−3b3b+(3b−23b)2+8(1−p)3bp→83bpE[W]=\dfrac{2-3b}{3b}+\sqrt{\left(\dfrac{3b-2}{3b}\right)^2+\dfrac{8(1-p)}{3bp}}\to\sqrt{\dfrac8{3bp}}; E[A]=(E[X]+1)RTT≃RTT2b/(3p)E[A]=(E[X]+1)\text{RTT}\simeq\text{RTT}\sqrt{2b/(3p)}.

Square root: B=1RTT32bpB=\dfrac1{\text{RTT}}\sqrt{\dfrac3{2bp}} (1.22/(RTTp)1.22/(\text{RTT}\sqrt p) for b=1b=1; 0.87/(RTTp)0.87/(\text{RTT}\sqrt p) for b=2b=2). b=2b=2, RTT 100100 ms, p=10−4p=10^{-4}: 866866 seg/s. Overestimates for p≳10−2p\gtrsim10^{-2}.

With timeouts

B=E[Y]+Q E[R]E[A]+Q E[ZTO]B=\dfrac{E[Y]+Q\,E[R]}{E[A]+Q\,E[Z^{TO}]}; E[R]=11−pE[R]=\dfrac1{1-p}; E[ZTO]=T0f(p)1−pE[Z^{TO}]=T_0\dfrac{f(p)}{1-p}, f(p)=1+p+2p2+4p3+8p4+16p5+32p6f(p)=1+p+2p^2+4p^3+8p^4+16p^5+32p^6; Q≃min⁡{1,3/E[W]}Q\simeq\min\{1,3/E[W]\}.

  • Timeout durations T0,2T0,…,64T0T_0,2T_0,\dots,64T_0 (Li=(2i−1)T0L_i=(2^i-1)T_0 for i≤6i\le6). Full model (9) with Q^(w)\hat Q(w).

Approximate model: B≃1RTT2bp/3+T0min⁡{1,33bp/8} p(1+2p+4p2)B\simeq\dfrac1{\text{RTT}\sqrt{2bp/3}+T_0\min\{1,3\sqrt{3bp/8}\}\,p(1+2p+4p^2)}. Cap: B≤Wmax⁡/RTTB\le W_{\max}/\text{RTT}. Throughput in bit/s =B×=B\times payload in bits.

Teoria collegata