TCP Sequence Number Utility

TCP Sequence Number Calculator

Calculate the next TCP sequence number, expected acknowledgment number, sequence-space consumption, payload byte range and 32-bit wraparound from SEQ, payload length, SYN and FIN flags.

✓ Next SEQ ✓ ACK Number ✓ SYN / FIN ✓ Payload Range ✓ 32-bit Wraparound ✓ Hex + Decimal
SEQ
TCP Sequence Calculation
● Ready
Enter decimal or hexadecimal with a 0x prefix. Valid TCP range is 0 through 4,294,967,295.
Application-data bytes carried by this TCP segment.
A SYN consumes one position in TCP sequence space.
A FIN also consumes one position in TCP sequence space.
Optional existing ACK field for display. It does not change the sender’s next sequence number.
TCP rule: the next sequence number is SEQ + payload bytes + SYN + FIN, calculated modulo 2^32. The ACK flag itself consumes no sequence number.
TCP Sequence Calculation Result Calculated
Next TCP Sequence Number
Starting SEQ
Payload Bytes
SYN Consumption
FIN Consumption
Total Consumed
Next SEQ
Expected ACK
Current ACK
Payload First SEQ
Payload Last SEQ
Wraparound
Sequence Space
Sequence-Space Layout
Calculation Breakdown
Validation

What Is a TCP Sequence Number?

TCP assigns sequence numbers to bytes in its reliable byte stream. The Sequence Number field in the TCP header identifies the sequence-space position associated with the segment.

Sequence numbers are 32 bits wide, so they range from 0 through 4,294,967,295 before wrapping back to zero.

TCP Next Sequence Number Formula

Sequence Space Consumed = Payload Length + SYN + FIN Next SEQ = (Starting SEQ + Sequence Space Consumed) mod 2^32

SYN and FIN are counted as one sequence-space position each. Other ordinary TCP flags such as ACK, PSH and RST do not add payload sequence bytes by themselves.

TCP Payload Sequence Number Example

Suppose a segment starts with sequence number 1000 and carries 500 bytes with no SYN or FIN.

Starting SEQ: 1000 Payload: 500 bytes Payload sequence numbers: 1000 through 1499 Next SEQ: 1500 Receiver ACK: 1500

Why Does SYN Consume One Sequence Number?

Although SYN is a control flag rather than application payload, TCP assigns it one position in sequence space. This is why the first data byte following an initial SYN normally starts at ISN + 1.

SYN Segment: SEQ = 1000 SYN = 1 Payload = 0 Next SEQ: 1001 Expected ACK: 1001

Why Does FIN Consume One Sequence Number?

FIN also occupies one sequence-space position. A receiver acknowledges the FIN by advancing its acknowledgment number by one after all preceding payload bytes.

SEQ: 5000 Payload: 100 bytes FIN: 1 Sequence consumption: 100 + 1 = 101 Expected ACK: 5101

TCP SYN with Payload

If SYN and payload occur in the same segment, the SYN consumes the first sequence-space position and payload begins immediately after it.

SEQ = 1000 SYN = 1 Payload = 10 bytes SYN occupies: 1000 Payload occupies: 1001 through 1010 Next SEQ: 1011

TCP Sequence Number Wraparound

TCP sequence arithmetic operates in a 32-bit space. When addition exceeds 4,294,967,295, the result wraps modulo 2^32.

Starting SEQ: 4294967290 Payload: 10 Calculation: 4294967290 + 10 = 4294967300 2^32: 4294967296 Wrapped Next SEQ: 4

TCP Acknowledgment Number

A TCP acknowledgment number normally identifies the next sequence number the receiver expects from the other endpoint.

Received segment: SEQ = 2000 Payload = 100 bytes Bytes received: 2000–2099 Expected ACK: 2100

If the segment contains SYN or FIN, their sequence-space consumption must also be included when calculating the acknowledgment.

TCP Sequence Number vs ACK Number

Field Meaning
Sequence Number Position of the segment in the sender’s TCP sequence space
Acknowledgment Number Next sequence-space position expected from the peer
Payload Length Number of application-data bytes consuming sequence space
SYN Consumes one sequence number
FIN Consumes one sequence number
ACK Flag Does not itself consume sequence space

TCP Initial Sequence Number

When a TCP connection begins, each endpoint selects an Initial Sequence Number, or ISN. During the three-way handshake the SYN consumes one position, so the next sequence number used by that endpoint is ISN + 1 modulo 2^32.

TCP Three-Way Handshake Example

Client → Server SYN SEQ = 1000 Server expects: ACK = 1001 Server → Client SYN, ACK SEQ = 5000 ACK = 1001 Client expects: ACK = 5001 Client → Server ACK SEQ = 1001 ACK = 5001

TCP Sequence Number Calculator FAQs

How do I calculate the next TCP sequence number?
Add the TCP payload length plus one for SYN if present and plus one for FIN if present, then apply modulo 2^32 arithmetic.
Does the TCP ACK flag consume a sequence number?
No. The ACK flag itself does not consume sequence space.
Does SYN consume a sequence number?
Yes. SYN consumes one TCP sequence-space position.
Does FIN consume a sequence number?
Yes. FIN consumes one sequence-space position.
What is the maximum TCP sequence number?
A TCP Sequence Number field is 32 bits, so its maximum unsigned value is 4,294,967,295, or 0xFFFFFFFF.
What happens after TCP sequence number 0xFFFFFFFF?
Sequence arithmetic wraps modulo 2^32, so the value following 0xFFFFFFFF is 0x00000000.
How do I calculate the expected TCP ACK number?
For an in-order segment, add the number of sequence-space positions consumed by its payload, SYN and FIN to its starting sequence number.
Does PSH consume a TCP sequence number?
No. PSH does not independently consume sequence space. Any payload carried in the segment does consume sequence numbers.
Scroll to Top