TCP Streams and Application Record Boundaries
Reason about an ordered byte stream without assigning a transport meaning to each individual application write.
- Source
- Anbloq
- Language
- English
- Created
- Updated
- Chapters
- 2
- Reading time
- 1 min
In this article2 chapters
Bytes are ordered independently of packet boundaries
TCP provides an ordered byte stream. A program writing “red” and then “blue” may be read as “re” followed by “dblue”, or in other chunks, depending on buffering and availability. TCP sequence positions identify bytes, not application records. Segmentation and retransmission can change the packets while preserving the transport’s intended stream behavior.
The application must frame its own records
A length prefix or carefully defined delimiter can mark boundaries. A reader must accumulate enough bytes for a complete record and retain any following bytes for the next parse. Closing with an incomplete record should have an explicit application meaning. Application framing covers bounded incomplete state. Sliding windows explain how the sender can keep several stream ranges outstanding before acknowledgment.[1][2]