Every octet in a TCP stream gets a number. Then TCP quietly hands out two more numbers to things that are not octets at all: the opening handshake and the closing goodbye. That small act of accounting is why a zero-byte SYN still moves the sequence space forward, why a retransmitted FIN cannot end the stream twice, and why the popular slogan that "TCP flags consume sequence numbers" is only about one-fifth true.

RFC 793 wrote the rule in 1981. RFC 9293, the standard in force today, kept the rule and kept the reasoning behind it. SYN and FIN each occupy exactly one position in TCP's sequence space — not as payload, but as ordered, reliability-relevant events. Every other flag in the header, ACK, PSH and RST included, gets no such privilege.

The short version

  • TCP implicitly gives SYN and FIN one position each in sequence space, so those control events can be acknowledged, ordered and retransmitted without ever being acted upon twice.
  • SYN is ordered before the first data octet in its segment; FIN is ordered after the last data octet in its segment.
  • Those occupied positions are protocol bookkeeping, not application bytes, and the other flags — ACK, PSH, RST — do not receive the same one-position treatment.
  • Because each direction owns its own sequence space, a FIN ends only its sender's stream direction and consumes a number only there.

Why TCP numbers events, not just bytes

TCP's reliable service begins with a deceptively simple instrument: number the octets, acknowledge the next one expected, retransmit whatever remains unacknowledged. Opening and closing create a harder problem. SYN and FIN are control events rather than payload, yet losing one or duplicating one changes the meaning of the connection.

RFC 793 solved that problem by widening the numbering scheme to cover selected control information. Its rationale is explicit: a sequenced control can be retransmitted and acknowledged without confusion, so one and only one copy is ever acted upon. RFC 9293 preserves both the mechanism and the reason.

The result is not that a SYN or FIN becomes an octet. The flag stays in the TCP header, outside the segment's data space. TCP merely reserves a logical position for it in the arithmetic that orders arrivals, advances acknowledgments and retires entries from the retransmission queue.

SYN sits before the first byte

In an ordinary data segment, the sequence-number field identifies the first data octet. SYN is the exception. When SYN is set, the field carries the initial sequence number, and the first data octet is numbered ISN+1.

That ordering matters even when a SYN carries application data, which TCP permits. The control event takes the first position; the data follows it. A receiver acknowledging the SYN advances its next-expected boundary by one before counting a single attached byte. A retransmitted SYN reuses the same position rather than announcing a second opening event.

This is not the place to relitigate how the ISN is chosen, or why an off-path attacker must find it hard to predict. Those are separate questions. The point here is what comes immediately after the chosen ISN: the sequence space advances because the SYN itself has to be reliably ordered.

FIN sits after the last byte

FIN works the opposite edge. TCP considers it to occur after the last actual data octet in the segment that carries it. If a segment begins at sequence number S, contains N application octets and also carries FIN, its logical sequence length is N+1 — the FIN takes the position immediately after those N bytes.

That placement stops the close event from overtaking data travelling in the same direction. The receiver acknowledges through the bytes and then through FIN using a single cumulative boundary. If FIN must be retransmitted, the repeated copy points at the same sequence position and does not manufacture a second end of stream.

FIN means its sender has no more data to send. It does not by itself close the reverse direction, whose sequence space and closing event belong to the other endpoint. Counting FIN therefore supports TCP's directional close semantics; it never collapses them into one shared switch.

What SEG.LEN really counts

Both specifications define SEG.LEN so that it counts the data octets and also counts SYN and FIN. The formula for the last occupied sequence number, the receive-window tests and the rule for deciding when a retransmission-queue entry is fully acknowledged all run on that logical length.

So a packet capture can look wrong if you treat payload length as the whole sequence-space advance. A zero-data SYN or FIN still pushes the next expected number up by one. A segment carrying N data octets plus one of those flags pushes it up by N+1. Were SYN and FIN ever considered together in the arithmetic, each would contribute its own position, though their normal roles remain opening and closing.

That gap between logical length and physical payload is the central design move. TCP did not slip a synthetic byte into the application stream. It made its accounting wide enough to hold the two control events that needed reliable, ordered treatment.

Why ACK, PSH and RST stay out of the ledger

RFC 9293 says plainly that SYN and FIN are the only controls requiring this protection. ACK makes the acknowledgment field significant; PSH expresses a push function; RST deletes connection state when accepted. None of them, merely by being set, adds one to SEG.LEN.

The asymmetry follows the job the sequence space is doing. SYN establishes the starting edge of a stream and FIN establishes its ending edge; both must occupy an ordered point relative to data. An acknowledgment instead reports the receiver's boundary. PSH asks for progress without defining any boundary. RST is expressly described as occupying no sequence space at all.

So the rule is far narrower than the slogan. Most flags consume nothing. The accurate statement is that TCP implicitly numbers SYN and FIN because these opening and closing controls need the duplicate protection, ordering and acknowledgment machinery of the stream itself.

What to inspect in a trace or implementation

When sequence arithmetic looks off by one, separate payload length from logical segment length first. Record SEG.SEQ, the number of data octets, the SYN and FIN bits, and the acknowledgment the peer returned. The expected advance is the data length plus one for each sequence-space-occupying control present.

Useful implementation checks: do retransmissions reuse the original SYN or FIN position; does data accompanying SYN begin at ISN+1; is FIN ordered after every preceding byte; and are zero-payload ACK, PSH or RST segments mistakenly treated as consuming a position?

The sources define protocol arithmetic, not the way a modern packet capture renders it or the way a socket API behaves. A diagnostic tool may display relative sequence numbers or hide details entirely. Verify those interface choices separately before drawing conclusions from the screen.

The control boundary

TCP's sequence space is usually described as a ledger of bytes. Its treatment of SYN and FIN shows what it really is: a ledger of ordered, reliability-relevant positions. Most positions correspond to application octets; exactly two correspond to the events that create and finish one direction of the stream.

That design concentrates authority in a single cumulative mechanism. The same next-expected number can prove receipt of data, of opening control and of closing control without a parallel acknowledgment system for connection edges. Retransmission repeats the evidence while the stable sequence position stops the repetition from becoming a new event.

The boundary matters just as much: sequence-space inclusion does not turn header control into payload, does not authenticate the peer, does not guarantee application completion and does not close both directions. It solves the narrow problem of reliable ordering. TCP's enduring choice was to spend two logical positions so that the beginning and end of a byte stream could survive loss without ever becoming ambiguous.

Sources