Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FIXME: we don't handle rolling sequence numbers properly in here #37

Open
Tiax opened this issue Oct 4, 2021 · 3 comments
Open

FIXME: we don't handle rolling sequence numbers properly in here #37

Tiax opened this issue Oct 4, 2021 · 3 comments

Comments

@Tiax
Copy link

Tiax commented Oct 4, 2021

I've been looking into problems with (seemingly random) receiving only "OutOfSequence" packets after a while (and usually only when lots of packets went over the wire), when I found this comment in TcpStreamGenerator.cs#L235:

//FIXME: we don't handle rolling sequence numbers properly in here
// so after 4GB of packets we will have issues

Which might explain my problem: when the initial Seq number is already a big number, we'd probably reach the uint32 limit rather quickly, causing it to not recognize the packet sequence anymore after it rolled over?

I'm not too familiar with TCP internas - How hard would this be to address? I naively imagine it's just a couple modulo operations here and there, or is there more to it?

@Tiax
Copy link
Author

Tiax commented Oct 6, 2021

        private static bool SeqLT(uint a, uint b) => ((int)a - (int)b) < 0;
        private static bool SeqGT(uint a, uint b) => ((int)a - (int)b) > 0;

Looks like using those for seq number comparison may be all it needed, since C# rolls over uint32 anyway, so no need for any modulos (unchecked by default).

@chmorgan
Copy link
Collaborator

chmorgan commented Feb 4, 2023

@Tiax not sure how hard it is to address, I'm guessing it's just a handful of changes where we care about sequence number comparison. Do you have a fix for the comparisons? I've been pretty inactive with the library for a while now since I'm not actively using it but would appreciate a PR if you do fix it.

@Tiax
Copy link
Author

Tiax commented Feb 16, 2023

It worked for me with using the snippet above for lesser/greater than comparisons for the Sequence. Ended up using a different library though in the end, so cannot really tell.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants