Click here to Skip to main content
15,884,838 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I know that TCP packets being sniffed are packets in a stream.

How can I reassemble these TCP packets?.. I am using winsock. Plenty on sniffing out there but nothing on reassembly!!!!!!

Thanks!
Posted
Comments
Emilio Garavaglia 12-Oct-11 3:44am    
If you sniff on a switched network, where no span has been configured, you get only broadcasts and unknown destinations.

If you see a flow, you can resemble them by taking packets belonging to the same sorce-address&port-to-destination-address&port quartet by sorting in respect to their sequence.
But that "flow" may be its not a "flow of data": depending on what the application is, may be the flow of its own session protocol (eventually including data) ...
Member 7766180 12-Oct-11 12:15pm    
Thank you. I am getting sources and destinations, sequence number and control bits. I have no idea what an assembled packet looks like. I only know that for me to read http headers that I was told to reassembly the packets. Can't find any examples though.
Chuck O'Toole 12-Oct-11 13:39pm    
Back at your previous attempt at this same question (see link in solution 1 below), you claimed to have code to do the reassembly and you even posted the source in a reply to solution 1 in that question. So what is different now?
Member 7766180 12-Oct-11 14:03pm    
Oh I see. But tell me Chuck what exactly will the result look like of an assembled packet. I think thats where my confusion lies/ Thank you.
Chuck O'Toole 12-Oct-11 15:25pm    
Updated Solution 1

1 solution

maybe this can help, there were answers in here:

How to Reassemble TCP Packets[^]

Based on your replies to other messages:

Google "TCP Packet Format" and you'll find all you ever wanted to know about packets.

If you are wanting to look at the content on packets going between a browser and a web server (other questions you've asked said you want to reassemble packets to see the HTTP Headers / Mime Types), then you are in for some fun decoding.

You are looking into the topmostlayer of a standard OSI 7 Layer Network module. That is, you are wanting to look at the content of a message between two cooperating applications (Browser - Web Server).

You are observing, using the sniffer you found, the bottom-most layer of that model, the datalink layer (bits on the wire).

Each layer as it passes from the wire, through the routing layer, through the session layer, yada, yada, wraps (going down) or unwraps (going up) the data from the previous layer with its own protocol. It's how, for example, one browser in your PC might have two active links to two different web servers and overlapping the activity yet the packets are not intermixed in the application. The various layers allow them to share the same wire, through a common gateway, and into the amorphous cloud that is the internet without messing up the sequence and flow of the data.

If you want to reverse engineer that so you can see the files being downloaded or the web pages being displayed, you need to do a lot of research and work.

Start here: --> TCP/IP Model[^] or here: --> OSI Model[^] and then head off to the protocol documents to find out how to unwrap the bits.
 
Share this answer
 
v2
Comments
Member 7766180 12-Oct-11 15:38pm    
This is a very good thought out answer! Thank you!

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900