Fish Touching🐟🎣

TCP

Jun 18, 2023

# Overview

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

  1. C2S: “Synchronize”, “SYN” with sequence number $S_A$ . We do this rather than assume 0 for security and reliability reason (no overlay window).
  2. 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”
  3. C2S: “Acknowledge”, “ACK” $S_{P} + 1$. Send a 0-length $S_{A} + 1$.

# Connection Teardown

  1. A -> A: FIN, seq $S_A$, ACK $S_B$
  2. B -> A: (Data+) ACK $S_{A} + 1$, continue sending unfinished packets
  3. B -> A: FIN, seq $S_B$, ACK $S_{A} + 1$
  4. A - > B: ACK $S_{B} + 1$

image.png