Práctica 4: End-to-End (Teoría de las Comunicaciones)
De Cuba-Wiki
Header
SrcPort
DestPort
SequenceNum
Acknowledgment
HdrLen
0
Flags
AdvertisedWindow
Checksum
UrgPtr
Options (variable)
Data
Connection Setup
SYN, SequenceNum = x
SYN + ACK, SequenceNum = y, Acknowledgment = x + 1
ACK, Acnkowledment = y + 1
Invariants
LastByteAcked LastByteSent
LastByteSent LastByteWritten
LastByteRead NextByteExpected
NextByteExpected LastByteRcvd + 1
Fórmulas
Flow Control
Invariants
LastByteRcvd - LastByteRead MaxRcvBuffer
EffectiveWindow = AdvertisedWindow - (LastByteSent - LastByteAcked)
LastByteWritten - LastByteAcked MaxSendBuffer
(LastByteWritten - LastByteAcked) + y MaxSendBuffer
Original Algorithm
Jacobson/Karels Algorithm
Actually:
Implementation:
{ SampleRTT -= (EsimatedRTT >> 3); EsimatedRTT += SampleRTT; if (SampleRTT < 0) { SampleRTT = -SampleRTT; } SampleRTT -= (Deviation >> 3); Deviation += SampleRTT; TimeOut = (EstimatedRTT >> 3) + (Deviation >> 1); }
Something
When the application produces data to send
if both the avaiable data and the window MSS
send a full segment
else
if there is unACKed data in flight
buffer the new data until an ACK arrives
else
send all the new data now
TCP Congestion Control
Formulas
Additive Increase / Multiplicative Decrease
Slow Start
{ int cw = state->CongestionWindow; int incr = state->maxseg; if (cw > state->CongestionThreshold) { incr = incr * incr / cw; } state->CongestionWindow = MIN(cw + incr, TCP_MAXWIN); }