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

Cap Module ignores TCP segment of Reassembled PDU #54

Closed
dheerajreddy1 opened this issue Oct 31, 2017 · 6 comments
Closed

Cap Module ignores TCP segment of Reassembled PDU #54

dheerajreddy1 opened this issue Oct 31, 2017 · 6 comments

Comments

@dheerajreddy1
Copy link

Since the chuck of data is reassembled into two packets. Cap module is not capturing the first reassembled TCP packet. It is capturing only the second packet. How to capture both the packets ?

@mscdex
Copy link
Owner

mscdex commented Oct 31, 2017

Can you provide details on how to reproduce the issue?

@dheerajreddy1
Copy link
Author

dheerajreddy1 commented Nov 3, 2017 via email

@wyxcoder
Copy link

Right, why this is closed? is it solved? I am facing the same problem

@mscdex
Copy link
Owner

mscdex commented Mar 28, 2020

@wyxcoder libpcap (and thus cap) operates at a lower level than Wireshark and thus does not process packets, including reassembly. This is up to cap users if they wish to reassemble packets.

@Supamiu
Copy link

Supamiu commented Jan 13, 2021

Hi,

I saw this issue while trying to udnerstand why reassembly wasn't done and I understand your choice as Cap must stay as flexible as possible. However, I'm thinking maybe you could provide an example of how one would do that.

As someone who is inexperienced with TCP reassembly, this seems very complex to do and I'm surprised nobody provided a nodejs example before, and I'm currently just lost in the RFC, trying to understand how this should be implemented in nodejs.

@guyharris
Copy link

If by "the RFC" you mean RFC 793, that's not sufficient to figure out what to do.

TCP (and, for another example, TLS) is a byte-stream protocol, meaning it transports a sequence of bytes, with no packet boundary indications. Protocols running atop TCP have to indicate packet/message boundaries themselves, and there's one fashion that is used by all protocols.

This means that reassembly has to be done cooperatively between the code that dissects TCP and the code that dissects the higher-level protocol, as packet boundaries cannot be discovered purely at the TCP layer.

One common way to indicate packet boundaries is to have, in the packet header, a length indication from which the total length of the packet in bytes, including the header, can be calculated. Text-based protocols such as HTTP might use other mechanisms; in the case of HTTP, the header of a request or response is terminated by a blank line, and, by parsing the header fields, the presence of and, if present, the end of the body can be determined.

Note also that this also means that a single TCP segment can contain parts of more than one higher-level packet, so you will also have to carve a single TCP segment into pieces. A single segment might, for example, contain the last part of one higher-level packet, one or more full higher-level packets, and the first part of an additional higher-level packet.

(And, yes, this means that the receiving side of an implementation of a protocol that runs atop a byte-stream transport layer has to do the same sort of work. A single read from a TCP socket, for example, is not guarantee to contain all of one and only one higher-level packet.)

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

5 participants