Ack Cut 3 F1: the 4 MiB flow bound counts acknowledged bytes above the lowest unacknowledged sequence
The bound summed only packets still awaiting an ack. Once frames above a lost packet were acknowledged they stopped counting, so a receiver could be made to hold more than 4 MiB behind one loss, and its hold buffer ended the session. The sender now keeps the payload size of each acknowledged sequence above the lowest pending one until the lowest advances past it, in Rust, TypeScript, Python and C#. Tests per runtime: one lost packet, four acknowledged 1 MiB frames, the fifth refused until the gap closes; and the floor moving to a new lowest sequence. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
0996fc96f5
commit
d7eacd1011
8 changed files with 249 additions and 10 deletions
|
|
@ -1265,6 +1265,46 @@ namespace GameCult.Networking.Tests
|
|||
Assert.That(promoted.Select(packet => packet.Sequence), Is.EqualTo(new[] { g.Sequence + 2, g.Sequence + 3 }));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void RudpSession_AcknowledgedBytesAboveALostPacketStillCountAgainst4MiB()
|
||||
{
|
||||
var sender = ConnectedFlowSession(1);
|
||||
var g = FlowSend(sender, 1).Single();
|
||||
// g is lost. Each 1 MiB frame above it is delivered and acknowledged, and the receiver still holds it
|
||||
// behind the gap, so it keeps counting.
|
||||
for (uint offset = 1; offset <= 4; offset++)
|
||||
{
|
||||
Assert.That(FlowSend(sender, Mib).Select(packet => packet.Sequence), Is.EqualTo(new[] { g.Sequence + offset }));
|
||||
sender.Receive(FlowAck(g.Sequence + offset), 1);
|
||||
}
|
||||
Assert.That(FlowSend(sender, Mib), Is.Empty);
|
||||
Assert.That(sender.QueuedReliablePacketCount, Is.EqualTo(1));
|
||||
Assert.Throws<InvalidOperationException>(() => sender.Send("state", new byte[Mib], new CultNetRudpSendOptions { Reliable = true }));
|
||||
|
||||
// g arrives: nothing is held behind a gap any more, and the queue drains.
|
||||
var promoted = sender.Receive(FlowAck(g.Sequence), 2).ReadyToSend;
|
||||
Assert.That(promoted.Select(packet => packet.Sequence), Is.EqualTo(new[] { g.Sequence + 5 }));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void RudpSession_AcknowledgedBytesCountAgainstTheLowestUnackedSequenceAsItAdvances()
|
||||
{
|
||||
var sender = ConnectedFlowSession(1);
|
||||
var g = FlowSend(sender, 1).Single();
|
||||
var h = FlowSend(sender, 1).Single();
|
||||
for (var index = 0; index < 3; index++)
|
||||
FlowSend(sender, Mib);
|
||||
// g and the 3 MiB above h are acknowledged; h is lost.
|
||||
foreach (uint offset in new uint[] { 2, 3, 4, 0 })
|
||||
sender.Receive(FlowAck(g.Sequence + offset), 1);
|
||||
Assert.That(FlowSend(sender, Mib).Select(packet => packet.Sequence), Is.EqualTo(new[] { g.Sequence + 5 }));
|
||||
// 4 MiB sit above h, acknowledged or not: one more byte does not fit.
|
||||
Assert.That(FlowSend(sender, 1), Is.Empty);
|
||||
// h arrives, the floor moves to g + 5, and the byte fits.
|
||||
var promoted = sender.Receive(FlowAck(h.Sequence), 2).ReadyToSend;
|
||||
Assert.That(promoted.Select(packet => packet.Sequence), Is.EqualTo(new[] { g.Sequence + 6 }));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void RudpSocketTransport_HandshakesAndCarriesReliableOrderedSchemaFrames()
|
||||
{
|
||||
|
|
|
|||
Loading…
Reference in a new issue