seq number assigned per byte (allows for packet sizes to change between transmissions)
3-Way Handhake
3-Way Handshake with nonce seq
We could abbreviate this setup, but it was chosen to be robust, especially against delayed duplicates
Three-way handshake first described inTomlinson 1975
Choice of changing initial sequence numbers (ISNs) minimizes the chance of hosts that crash getting confused by a previous incarnation of a connection
How to choose ISNs?
Maximize period between reuse
Minimize ability to guess (why?)
Random works OK, as in Project 2
Operation
Server: If in LISTEN and SYN arrives, then transition to SYN_RCVD state, replying with ACK+SYN.
Client: active open, send SYN segment and transition to SYN_SENT.
Arrival of SYN+ACK causes the client to move to ESTABLISHED and send an ack
When this ACK arrives the server finally moves to the ESTABLISHED state.
TCP Header
src dest identified by IP + PORT
TCP Disconnect
Need timers anyway to get rid of connection state to dead nodes.
However, timer should be large so that “keepalive” hello overhead is low.
If communication is working, would prefer graceful closing (so receiver process knows quickly) to long timers.
Hence 3 phase disconnect handshake After sending disconnect and receiving disconnect ack, both sender and receiver set short timers.
enter TIME_WAIT to handle very old packets that may not have been retransmit or have not been acked yet
We wait (maximum segment lifetime of 60 seconds) before completing the close
Why?
ACK might have been lost and so FIN will be resent
Could interfere with a subsequent connection
Real life: Abortive close
Don’t wait for , simply send Reset packet (RST)
TCP Reliability
Usual sequence numbers except:
Very large to deal with out of order (modulus > 2 W etc. only works on FIFO links). As in Project 2
TCP numbers bytes not segments: allows it to change packet size in the middle of a connection
The sequence numbers don’t start with 0 but with an ISN.
Reliable Mechanisms similar except:
TCP has a quicker way to react to lost messages
TCP does a crude form of selective reject not go-back N
TCP does flow control by allowing a dynamic window which receiver can set to reduce traffic rate (next lecture)
recall go-back-N: retransmit all packets from last ack
real timer for retransmit is based on calculated Round Trip Time (RTT)
TCP Fast Retransmit
like selective reject but immediate retransmit with sliding window buffer size
timer as backup, use 3 dup acks to identify
TCP SACK - Selective ACK
ack with last received in-order packet, BUT also send sack with received out of order packets
limitations: ack/sack info could be very long if many drops and many out of order packets
solution: limit to 3 sack blocks (ranges) - act like any out of order packets after reporting at most 3 sack ranges are considered to be lost
e.g., ACK 1, SACK 3-8, SACK 10-15, SACK 17-25 => packets 2,9,16 are lost and any after 25 are considered lost or not sent yet
Socket API
QUIC - Quick UDP Internet Connections
developed by google to make initial handshake faster with TLS
Runs on UDP
also adds other stuff like congestion and flow control for UDP
The trick to lower latency
Idea 1: Combine security handshake and sequence number handshake on first connection to server
Idea 2: If server remembers information about client, need 0 handshakes on later connections
Three way handshakes are required because server forgets info on client. Important in old days but no longer as severs have massive memory
A round trip is a big deal (several hundred msec across US) at today’s high speeds
Additional Stuff
Stream multiplexing: multiple streams in a single QUIC connection between client and server for HTTP/2
No head of line blocking: can do HTTP/2 over a single TCP connection but a single loss stalls all streams. Not so in QUIC
Shared congestion information: as we will see it takes TCP a long time to ramp up. In QUIC all congestion information is shared.
Wave of future: 9% of all websites use QUIC (4/2023). 40% of Chrome traffic uses QUIC 2
Congestion/Flow Control
Flow Control - Changing sender speed to match receiver speed
Congestion Control - Changing sender speed to match network speed
Flow Control
flow control - receiver sets the recv window size = 0, but then deadlock if window size = 0, so periodically receiver needs to send a packet or probe to maintain the connection
FREEZE - receiver could also send back a FREEZE message (wich contains a timeout) that keeps the connection open but stops the sender fro sending until it receives another packet from the node that sent the freeze - needs seq numbers for freeze because delayed duplicates may restart freeze timeout
Congestion Control
different connection bandwidths leads to congestion on high output senders