TCP Segment & State Machine
Read this concept as one more decision made about a packet in flight. The widget below lets you change the inputs and watch the consequence instead of memorising the rule.
Why it matters
TCP presents a reliable byte stream, but on the wire it is a sequence of segments with flags, sequence numbers, and window fields. Knowing the state machine explains why a connection can appear open yet carry no data.
On the wire
A TCP segment has a 20-byte base header with ports, sequence and acknowledgment numbers, data offset, flags, window, checksum, and urgent pointer. Flags such as SYN, ACK, FIN, and RST drive transitions between states like LISTEN, ESTABLISHED, TIME_WAIT, and CLOSED.
When it breaks
A segment arriving in the wrong state is reset or ignored, so an application sees a broken pipe rather than a protocol error. An attacker who guesses sequence numbers can inject a RST and tear down a connection, which is why initial sequence numbers must be unpredictable.
TCP state machine
Send protocol events one at a time; only events valid in the current state are offered.
Available events in CLOSED
Choose an event to drive the connection forward.