Operation
Sender Operation
The sender maintains a window of unacknowledged packets. Each packet in the window is in one of two states:
- Pending Transmit: Queued but not yet sent, or marked for retransmission
- Awaiting ACK: Transmitted and waiting for acknowledgment
Send Flow
- Application submits a message to send
- If message exceeds MTU, segment it into multiple packets (FIRST/CONTINUATION/LAST)
- For each packet:
- Assign the next sequence number
- Store packet in send buffer
- Mark as Pending Transmit
- Transmit Pending Transmit packets up to the window limit — if the window is full, remaining packets stay queued until ACKs free window slots
- Start retransmission timer for each transmitted packet
- Mark transmitted packets as Awaiting ACK
ACK Processing
When an ACK arrives:
- For each packet covered by the cumulative ACK (seq ≤ cumulative_ack):
- Stop its retransmission timer
- Remove from send buffer
- For each bit set in the selective bitmap: bit N means the receiver has packet N positions beyond the cumulative ACK (i.e., sequence number cumulative_ack + 1 + N). For each such packet:
- Stop its retransmission timer
- Remove from send buffer
- Slide the window forward
Timeout Handling
When a retransmission timer expires:
- If retransmit count has not reached the maximum:
- Increment retransmit count
- Mark packet as Pending Transmit
- Retransmit the packet
- Restart timer
- Otherwise:
- Declare packet lost
- Remove from send buffer
- Signal error to application
Stream Termination
To signal end of transmission:
- Application requests stream close
- Send EOS packet with next sequence number
- Wait for ACK covering the EOS sequence
- Transfer is complete when EOS is acknowledged
The EOS is retransmitted like DATA if no ACK arrives.
Receiver Operation
The receiver maintains the expected sequence number and a reorder buffer for out-of-order packets.
Receive Flow
When a DATA or EOS packet arrives:
- Compare packet sequence to expected sequence
- If sequence matches expected (in-order):
- If DATA: deliver payload to reassembly
- If EOS: signal stream complete to application
- Advance expected sequence
- Check reorder buffer for now-deliverable packets
- Repeat until no more consecutive packets
- If sequence is ahead of expected but within the window (out-of-order):
- Store in reorder buffer
- Set corresponding bit in selective bitmap
- If sequence is behind expected (duplicate):
- Ignore
- Schedule or send ACK (see ACK Generation)
Reassembly
As packets are delivered in order:
- Check sequence flag:
- UNSEGMENTED: Complete message, deliver to application
- FIRST: Start new reassembly buffer
- CONTINUATION: Append to reassembly buffer
- LAST: Append and deliver complete message to application
ACK Generation
After processing each DATA packet:
- If immediate_ack mode:
- Send ACK immediately
- If delayed_ack mode:
- If no ACK timer running, start one
- When timer expires, send ACK
The ACK contains:
- Cumulative ACK = expected_seq - 1 (highest in-order seq received)
- Selective bitmap = bits for each buffered out-of-order packet
Version Handling
The SRSPP header includes a 2-bit version field. When a packet arrives with an unrecognized version:
- Discard the packet silently
- Do not send an ACK (sender will retransmit or timeout)
- Optionally log the event for diagnostics
This allows future protocol versions to coexist during transitions. Endpoints should be upgraded to matching versions for reliable communication.
Error Handling
Sender Errors
- Send buffer full — block or reject new messages until space is available
- Window full — block until ACKs free window slots
- Packet lost (max retransmits exceeded) — signal error to the application and remove the packet
Receiver Errors
- Reorder buffer full — drop the out-of-order packet (the sender will retransmit)
- Message too large for REASM — discard segments and signal reassembly error to the application
- CONTINUATION without FIRST — discard the segment and signal reassembly error
- Unknown packet type — discard silently
- Unknown version — discard silently
Receiver errors do not generate negative acknowledgments. The sender retransmits based on timeouts.