My protocol consists of small variable-length structures (which I'll call "commands"). Each command contains a field indicating its length. Frequently, commands are sent individually, so one TCP packet contains one command. Sometimes, however, numerous commands may be sent in a single TCP packet, and sometimes one command can be split over two TCP packets, so I see something like this:
PKT 1:
len1 data1 len2 data2 len3 (part of data3)
PKT 2:
(rest of data3)
My original parser just described one command, so PKT 1 is shown as containing a single command (the rest is marked as TCP.UnhandledTCPData), and PKT 2 is shown as being corrupt. Then I added a "while [FrameOffset < FrameLength]" loop around the whole thing - now PKT 1 has 3 commands, though part of the third one is missing, but PKT 2 is still corrupt.
I believe I have to use the reassembly facility to deal with this, and I found some videos
here but the video on reassembly seemed to imply that this was used when one fragment was broken up into multiple TCP packets, and my problem is kind of the other way around.
How can my parser deal with this?