oskarnie14 / lidgren-network-gen3

Automatically exported from code.google.com/p/lidgren-network-gen3
0 stars 0 forks source link

Erroneous negative sequence numbers when resending packets #146

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
When resending packets in NetReliableSenderChannel.SendQueuedMessages, the 
sequence number often ends up being negative.

I don't think this is supposed to happen (I think it should always be in the 
0-1023 range since NumSequenceNumbers = 1024, right?), and since I'm 
experiencing time outs when sending lots of data / packets, I suspect this 
might be at least one of the root causes.

You can check that this is happening by adding:

    if( seqNr < 0 )
    {
        Console.WriteLine( "Negative sequence number" );
    }

right after the while() loop in SendQueuedMessages and then use the 
FileStreamSample and simulate some packet loss on the server side.

When printing sequence numbers client-side, I get something like:

 0, 1, 2, 3, 4, 32713 (ignoring duplicate), 32714 (ignoring duplicate)

Which doesn't look right either.

Original issue reported on code.google.com by elise...@gmail.com on 17 Jan 2013 at 3:27

GoogleCodeExporter commented 9 years ago
I fixed the issue in my own copy of Lidgren by applying the attached patch. 
Instead of deducing the sequence number, I just cache it along with the stored 
message when it's first sent.

I can confirm that it fixes at least some cases of having a connection stuck in 
a loop of message resending (although I suspect that there might be another bug 
somewhere in the resending logic because I still have other similar issues. 
I'll submit an issue / patch if and when I figure it out)

Original comment by elise...@gmail.com on 17 Jan 2013 at 5:17

Attachments:

GoogleCodeExporter commented 9 years ago
The above attached patch uncomments the LogWarning line, you probably don't 
want that. Here's an updated patch which doesn't do that.

Original comment by elise...@gmail.com on 17 Jan 2013 at 5:21

Attachments:

GoogleCodeExporter commented 9 years ago
I haven't seen this problem myself, but those numbers do indeed look mysterious 
- it probably only happens under certain circumstances. The patch looks good 
and I've integrated it in revision 330. Thanks!

Original comment by lidg...@gmail.com on 18 Jan 2013 at 7:19

GoogleCodeExporter commented 9 years ago
Cool, thanks :)

Original comment by elise...@gmail.com on 20 Jan 2013 at 1:25