What is sequencing and why is it important?
Sequencing numbers each segment so the destination can reassemble them in the correct order even if they arrive out of order; TCP handles this.
Sequencing is the process of numbering each segment so the message can be reassembled correctly at the destination. It matters because once a large message is segmented and the pieces are sent across a packet-switched network, they can take different paths and arrive out of order — or some may need retransmission and show up late. Without sequence numbers the receiver would have no way to know the original order.
How it works:
- TCP stamps each segment with a sequence number as it sends it.
- The receiver uses those numbers to put the pieces back in the right order, regardless of arrival order, before handing the data to the application.
- The same numbers also let TCP spot a missing segment and request just that one again.
Gotcha: sequencing is a TCP feature. UDP does not sequence, which is one reason UDP is faster but unreliable — the application must handle ordering itself if it needs it.
Go deeper:
TCP — sequence numbers and reliable, ordered delivery — how TCP numbers bytes to reorder and detect missing segments.