JarryShaw / PyPCAPKit

Python-based Comprehensive Network Packet Analysis Library

Home Page:https://jarryshaw.github.io/PyPCAPKit/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Defragmentaion of IPv4/IPv6 Pakets..

mkrase opened this issue · comments

Describe the bug
Not working defragmentation of IP Pakets...

System information

  • OS Version: Windows 10
  • Python Version: 3.8
  • Python Implementation: CPython

Traceback stack

testpacks = pcapkit.foundation.extraction.Extractor(r'test_ipv4.pcap',engine=pcapkit.DPKT,ipv4=True,verbose=True,nofile=True,store=False)
 - Frame   1: Ethernet:IP:UDP
Traceback (most recent call last):
  File "C:\Program Files\Python38\lib\code.py", line 90, in runcode
    exec(code, self.locals)
  File "<input>", line 1, in <module>
UnboundLocalError: local variable 'TDL' referenced before assignment

For ipv6:
testpacks = pcapkit.foundation.extraction.Extractor(r'ipv6_test.pcap',engine=pcapkit.DPKT,ipv6=True,verbose=True,nofile=True,store=False) 
 - Frame   1: Ethernet:IP6:UDP
 - Frame   2: Ethernet:IP6:UDP
Traceback (most recent call last):
  File "C:\Program Files\Python38\lib\code.py", line 90, in runcode
    exec(code, self.locals)
  File "<input>", line 1, in <module>
AttributeError: 'IP6FragmentHeader' object has no attribute 'nh'


```**Expected behavior**
dict with defragmented packets

Hi there, could u pls kindly provide the source PCAP file and the version of PyPCAPKit & DPKT?

Hi.
The PyPCAPKit Version is 0.15.5 and DPKT is 1.9.5. (also tried 1.9.4).
25Hz_Aufnahme_10s_anon.zip IPv4
state_machine_cmds_first20.zip IPv6

I have adopted the algorithm in my programme with the pypacker package and I have noticed that the variable "TDL" must be initialised with "0" at the beginning, in case the first fragment is not read first and after passing on the complete package, if a larger package comes afterwards. Otherwise it doesn't work for me, I guess that would have to be implemented here as well.

Thanks for the info. Yes, TDL should be initialised under all circumstances. But my IP reassembly algorithm implementation seems to fail on reassmbling the actual payload. I'm still working on debugging.

Bug fixed. Thanks for reporting @mkrase