- TCP uses both go-back-N and selective repeat
- Uses positive ACKs
- Establishes connections upfront to establish initial sequence number
- Initial sequence number is random
- This is for
- Integrity — prevent confusion with old connection
- Security — harder for attacker to spoof packets
- Header contains:
- Source and destination ports
- Sequence number
- Acknowledgment number
- Receive window size
- Checksum
- Some bitwise flags, including commands to regulate connection
- Why a separate acknowledgment number?
- To allow us to piggyback data on packets flowing in opposite direction
- This part is a bit confusing — see this ChatGPT conversation for clarification
- Some notes from my own separate follow-up:
- Note that TCP is stream-oriented; it doesn’t care about distinct messages
- HTTP translates the TCP stream into discrete messages
- TCP keeps only one timer
- At the end, it transmitted next-lowest un-ACK’ed segment.
- This is based on the assumption that packets are rarely dropped
- TCP timeout is tuned based on a weighted average of round trip time, factoring in variance (“jitter”)
- RFC 1122: delayed ACKs preferred except in situations requiring minimum latency (eg SSH terminal)
- There are many different regimes and, in practice, the strategy is tunable according to the use case (RFC 1122, 2581)
- These decisions are part of TCP flow and congestion control (next lecture)
- There are also various optimizations around sending ACKs
- eg triple ACKs in certain situations
- TCP flow control is concerned specifically with preventing flooding the receiver
- TCP congestion control: prevent network from being flooded
- TCP handshake
- Initiator sends initial sequence number, window size, etc
- Listener sends ACK with its own params
- Initiator ACKs, and may send first portion of data in ACK
- TCP connection close:
- One end sends an EOF
- The other one acknowledges termination
- Then vice versa; failure to reciprocate means “half-closed”