Reliable Transport Protocol Design
- Goal: Deliver a reliable, in-order byte stream over an unreliable IP network
- Key mechanisms:
- Checksums → detect bit errors
- Sequence numbers (byte offsets)
- Sliding window for flow control
- Cumulative acknowledgements (like GBN)
- Receiver buffers out-of-sequence packets (like SR)
- Single retransmission timer
- Extra features: fast retransmit, timeout estimation algorithms
TCP Abstraction
- Reliable: Retransmits lost packets until acknowledged or connection shutdown
- In-order delivery: Only delivers contiguous byte sequences to applications
- Byte-stream service: Treats data as a continuous stream, not discrete messages
- Minimum 20 bytes, fields include:
- Source port, Destination port
- Sequence number (first byte offset in the segment)
- Acknowledgement number (next expected byte)
- Header length (in 4-byte words)
- Flags: SYN, ACK, FIN, RST, PSH, URG
- Checksum (over pseudo-header and data)
- Urgent pointer (optional)
- Options: e.g., MSS, window scaling
Segmentation
- IP Packet: Cannot exceed MTU (1500B for Ethernet, 9000B for jumbo frames)
- TCP Segment: IP packet containing TCP header + TCP data
- MSS = MTU – IP header – TCP header
- Typically ≈ 1460B data payload
Sequence Numbers & Acknowledgements
- Sequence number = first byte in segment
- Acknowledgement number = next expected byte
- Cumulative ACKs:
- If all bytes up to X are received, ACK = X+1
- If a packet is missing, ACK “stalls” at the missing sequence
Example of Cumulative ACKs
Sent sequence numbers: 100, 200, 300, 400, 500, 600...
- If segment with seqno 500 is lost:
- ACKs received: 200, 300, 400, 500, 500, 500...
Fast Retransmit
- Triggered after 3 duplicate ACKs
- Retransmits missing packet early (before timeout)
- After retransmission:
- Option 1: Advance window by number of dup ACKs (faster, riskier)
- Option 2: Wait for ACK of retransmitted packet (slower, correct)
- TCP chooses correctness (Option 2)
Retransmission Timeout (RTO)
- Challenges:
- Too long → low throughput
- Too short → redundant retransmissions
- Solution: RTO proportional to measured RTT
RTT Estimation
Karn/Partridge Algorithm
- Ignore SampleRTT for retransmitted packets
- Use exponential backoff on timeout
- RTO = 2 × EstimatedRTT
- On repeated timeouts: RTO ← 2 × RTO (up to ≥ 60s)
Jacobson/Karels Algorithm
TCP Connection Establishment
- Initial Sequence Number (ISN): Avoids old packet confusion, helps prevent spoofing
- Three-Way Handshake:
- Client → Server: SYN(ISN_A)
- Server → Client: SYN(ISN_B), ACK(ISN_A+1)
- Client → Server: ACK(ISN_B+1)
SYN Loss
- If SYN lost → no SYN-ACK arrives
- Client retransmits after default timeout (3–6 seconds)
- User may perceive delay (slow web page load)
TCP Connection Teardown
- Graceful (FIN):
- One side sends FIN (consumes 1 sequence number)
- Other side ACKs
- Other side sends FIN
- First side ACKs → enters TIME_WAIT to avoid packet reincarnation
- Simultaneous FIN: Both send FIN nearly together → both close
- Abrupt termination (RST):
- Sent when application crashes or rejects connection
- Not acknowledged; any further traffic elicits another RST
Comparison: Go-Back-N (GBN) vs Selective Repeat (SR) vs TCP
| Feature |
GBN |
SR |
TCP |
| Sequence numbers |
Per packet |
Per packet |
Per byte offset |
| Acknowledgement |
Cumulative ACK only |
Selective ACK |
Cumulative ACK (default); optional SACK |
| Receiver buffering |
No (discards out-of-order) |
Yes (stores out-of-order) |
Yes (stores out-of-order like SR) |
| Retransmission timer |
Conceptually one per packet |
One per packet |
Single timer (for oldest unACKed packet) |
| Retransmission strategy |
Lost packet → retransmit that + all subsequent |
Retransmit only lost packet |
Retransmit like GBN, but adds Fast Retransmit |
| Efficiency |
Low (1 loss = many retransmits) |
High |
Balanced: cumulative ACK + buffering + fast retransmit |
| Use case |
Theory model |
Theory model |
Practical protocol |
Why GBN Needs a Timer for Each Packet
- GBN uses cumulative ACKs and does not buffer out-of-order packets
- If a packet in the middle is lost:
- Receiver discards later packets
- Sender cannot rely on ACK progress to detect which one was lost
- Therefore, conceptually, each unACKed packet requires a timer
- TCP optimization:
- Uses cumulative ACKs + buffers out-of-order packets
- Adds fast retransmit (dup ACKs indicate which packet is lost)
- Thus, TCP only needs one timer (for the oldest unACKed packet)
Summary
- TCP combines ideas from GBN and SR, plus its own enhancements:
- Like GBN: cumulative ACKs
- Like SR: receiver buffers out-of-order packets
- Unique: one retransmission timer, fast retransmit, adaptive timeout algorithms
- Connection establishment: three-way handshake
- Connection termination: FIN (graceful), RST (abrupt)
- Next topics: Flow control and Congestion control