TCP
# Overview
- Stream of bytes
- In sequence
- Congestion Control (BBR)
- Networking Flow Control Algorithm to stop the overflow at the receiver’s end
- Provides reliable, ordered, and error-checked delivery of a stream of bytes.
IP is a connectionless protocol, which means that each unit of data is individually addressed and routed from the source device to the target device, and the target does not send an acknowledgement back to the source.
That’s where protocols such as TCP come in. TCP is used in conjunction with IP in order to maintain a connection between the sender and the target and to ensure packet order.
# 3-way Handshake
# Setup
- C2S: “Synchronize”, “SYN” with sequence number $S_A$ . We do this rather than assume 0 for security and reliability reason (no overlay window).
- S2C: “Synchronize and Acknowledge”, “SYN/ACK”. “SYN” with a sequence number $S_P$ and set the “ACK” bit to 1, ACK $S_{A} + 1$. which indicate the passive side has acknowledged that it received the “SYN”
- C2S: “Acknowledge”, “ACK” $S_{P} + 1$. Send a 0-length $S_{A} + 1$.
# Connection Teardown
A -> A: FIN, seq $S_A$, ACK $S_B$B -> A: (Data+) ACK $S_{A} + 1$, continue sending unfinished packetsB -> A: FIN, seq $S_B$, ACK $S_{A} + 1$A - > B: ACK $S_{B} + 1$
Problems with closed socket
- What if final ack is lost in the network?
- What if the same port pair is immediately reused for a new connection?
Solution:“active” closer goes into TIME WAIT
- Active close is sending FIN before receiving one
- Keep socket around for 2MSL (twice the “maximum segment lifetime")
Can pose problems with servers
TCP FSM

# Header
