Packet Reassembly
Client-side stream reconstruction — from fragments to data
TCP Stream Reassembly RFC 9293
TCP segments may arrive out of order. The client uses sequence numbers to reconstruct the original byte stream.
| Field | Size | Purpose |
|---|---|---|
Sequence Number | 32 bits | Byte position in stream |
Acknowledgment | 32 bits | Next expected byte |
Window Size | 16 bits | Receive buffer space |
Checksum | 16 bits | Data integrity |
IP Fragment Reassembly RFC 791
Large IP datagrams are fragmented to fit MTU. The receiver reassembles using identification and fragment offset.
| Field | Bits | Description |
|---|---|---|
Identification | 16 | Groups fragments together |
DF (Don't Fragment) | 1 | Fragmentation forbidden |
MF (More Fragments) | 1 | More fragments follow |
Fragment Offset | 13 | Position in 8-byte units |
TLS Decryption RFC 8446
After TCP reassembly, encrypted TLS records are decrypted using session keys established during handshake.
| Record Type | Value | Content |
|---|---|---|
change_cipher_spec | 0x14 | Legacy (TLS 1.2) |
alert | 0x15 | Error notifications |
handshake | 0x16 | Key exchange |
application_data | 0x17 | Encrypted payload |
Buffer Management Receive Buffer
The receive buffer holds out-of-order segments until gaps are filled and data can be delivered to the application.
| Buffer State | Action |
|---|---|
| Contiguous data at head | Deliver to application |
| Out-of-order segment | Store, wait for missing bytes |
| Duplicate segment | Discard |
| Buffer full | Advertise zero window |
Flow Control Sliding Window
The receiver advertises available buffer space. The sender limits in-flight data to prevent overflow.
| Parameter | Typical Value | Notes |
|---|---|---|
Initial Window | 65535 bytes | Without window scaling |
Window Scale | 0-14 | Multiplier: 2^scale |
Max Window | 1 GB | With scale=14 |
Zero Window | 0 | Receiver buffer full |
Congestion Control RFC 5681
Slow start probes network capacity by doubling congestion window until loss or threshold.
Slow Start: cwnd = cwnd + MSS (per ACK) Cong. Avoid: cwnd = cwnd + MSS/cwnd (per ACK) Fast Recovery: cwnd = ssthresh + 3*MSS
| Algorithm | Trigger | Action |
|---|---|---|
| Slow Start | cwnd < ssthresh | Double cwnd per RTT |
| Congestion Avoidance | cwnd >= ssthresh | Linear increase |
| Fast Retransmit | 3 duplicate ACKs | Retransmit lost segment |
| Fast Recovery | After retransmit | Halve ssthresh, inflate cwnd |
Reassembly Complete Application Delivery
| Layer | Reassembly Unit | Identifier |
|---|---|---|
| IP | Datagram | ID + Fragment Offset |
| TCP | Byte Stream | Sequence Number |
| TLS | Record | Implicit sequence |
| HTTP/2 | Stream | Stream ID |