pydivert
pydivert copied to clipboard
OSError: [WinError 87] for inbound packet
I got a lot of WinError 87 exceptions for this code in windows 10. any one could help me please?
with pydivert.WinDivert("inbound and ip") as wd:
for pkt in wd:
wd.send(pkt)
Traceback (most recent call last):
File "C:/cygwin64/code/python/pydivert_reset/test_pydivert.py", line 78, in
I got this error a lot and found out that it was an issue with my filter. I would check there first.
The error is created by packets with larger than the DEFAULT_PACKET_BUFFER_SIZE=1500.
Example receiving some fragments that get reassembled into a large packet. Or trying to send a packet that will fragment. (if you put 'outbound' in your filter) ping -l 1600 google.com
The maximum packet size for IPv4 is 65535 and for IPv6 is 65535+40.
You could change the constant I mentioned above to 65575 and be safe for ever in the file C:\Program Files\Python36\Lib\site-packages\pydivert\windivert.py
Or you could add to your filter "((ip and ip.Length<=1500) or (ipv6 and ipv6.Length<=1500))".
Or instead of using the for loop iterator you could use the .recv(<buff_size>) method just pass it a large enough buffer size. 5000 is probably fine and 65575 would be the maximum needed as i said before.