How to reassemble TCP packets in Python?

Tianyang Li picture Tianyang Li · Mar 7, 2011 · Viewed 7.6k times · Source

How to reassemble TCP packets in Python? Is there any existing tools for this?

Thanks! :-)

Answer

Justin picture Justin · Mar 27, 2011

To do perform TCP reassembly you'll need to use something like pynids http://jon.oberheide.org/pynids/.

You can also build your own using pylibpcap, dpkt or scapy.

TCP reassembly is very tricky with a LOT of edge cases. I wouldn't recommend doing it yourself if you need a robust solution.