On 1/17/25 13:42, Lukas Tribus wrote:
Does anyone know of a good way to simulate oddball TCP happenings like:

* Out of order delivery
* Variable delivery delays
I would suggest to take a look at linux tc-netem

Yeah, tc will do most of this without too much fuss.

* (Especially) Unusual segmentation e.g. splitting part of a stream that
would and should normally be sent in a single segment into several
smaller segments sent back-to-back

And especially doing so with traffic from an existing TCP-speaking
application i.e. something like a TCP proxy that lets you deliberately
mess with the segmentation and delivery order.

This is more difficult because a TCP proxy (as in a userspace
application) does not do the TCP segmenting, the kernel does. Sure the
application may set flags like TCP_NODELAY to toggle Nagle, but beyond
that the application has not really control over TCP segmentation. So
a tool like this would basically need to reimplement TCP in userspace.

Not sure something like this is out there.

Not only is it more difficult, it's the part that I think is causing me problems. The thing talking to me is segmenting its TCP stream in a way that I suspect is due to setting TCP_NODELAY but then feeding messages piecemeal (e.g. as they're generated by some state machine) into send/write syscalls. The segments are usually sent back-to-back with no meaningful delay and are of consistent layout, but they're tiny - one is only 4 bytes, and they're not all the same size.

I suspect I have an issue somewhere with my buffer handling, TCP re-assembly, etc. but don't have a good place to look without being able to re-create it while speaking a protocol that I actually speak (which precludes some common things like HTTP, in this case). I may end up modifying an open-source implementation of the protocol (which thankfully exists) to basically do the same thing by the same means.

--
Brandon Martin

Reply via email to