add L2 reliability: seq + cumulative ACK + retransmit (protocol v2)
DATA frames now carry seq:4 and ack_seq:4 in a 16-byte extended header. Both sides maintain per-session send/recv state: Sender: - Monotonic seq counter, retransmit buffer (seq -> frame bytes) - Retransmit timer: 5ms timeout, 10 max retries -> CLOSE - Window advances on cumulative ACK Receiver: - In-order delivery to TCP socket (expected_seq) - Out-of-order buffering (SortedList by seq) - Duplicate detection (seq < expected -> discard + re-ACK) - Pure ACK frames (empty-payload DATA) for duplicate/OOO responses This prevents lost Ethernet frames from permanently corrupting TCP sessions, which was the key v1 limitation. The local kernel TCP stack ACKs data before we chunk it into DATA frames; without L2 reliability a dropped frame creates an unrecoverable gap. Version bumped to 2. Both sides must speak v2; no negotiation. Updated: PROTOCOL.md (full v2 spec), README.md, Rust frame.rs/ session.rs/main.rs, C# Frame.cs/SessionManager.cs/TunnelLink.cs.
This commit is contained in:
@@ -72,7 +72,9 @@ sealed class TunnelLink : IDisposable
|
||||
SendRaw(dstMac, FrameCodec.Encode(frame));
|
||||
}
|
||||
|
||||
void SendRaw(byte[] dstMac, byte[] payload)
|
||||
/// Send a pre-encoded protocol payload (for retransmit, where we already
|
||||
/// have the exact bytes and want to avoid re-encoding).
|
||||
public void SendRaw(byte[] dstMac, byte[] payload)
|
||||
{
|
||||
var frame = new byte[Proto.EthHeaderLen + payload.Length];
|
||||
Buffer.BlockCopy(dstMac, 0, frame, 0, 6);
|
||||
|
||||
Reference in New Issue
Block a user