-
Notifications
You must be signed in to change notification settings - Fork 48
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
Socket recvfrom buffer too small for receiving responses to large ICMP echo requests #40
Comments
Hi @sjaddd, Thank you for your very detailed issue! A fix will be released in the next version. I think the buffer size should depend on the size of the request sent to avoid unnecessary memory consumption. Alternatively, I can also offer users the option to set the buffer size. I have to do some tests. |
Great, thanks - looking forward to the next release 😃 |
Hi @ValentinBELYN, great library! There have been multiple releases since. Is the issue fixed? |
Hi @pyfisch, Unfortunately this issue is not fixed. I haven't had time to take care of this project lately but I plan to resume development this weekend for a release next week at the latest. |
No problem. I planned to use the library to send large pings but now I don't need to do that anymore. |
@ValentinBELYN Can you please let me know if there is a plan to add buffer size to the receive api ? We need this for one of our use case. |
Issue
In
icmplib/sockets.py
, the response buffer allocated by thereceive
method isn't big enough, when the echo requestpayload_size
is greater than996
bytes.Using
examples/ping.py
for testing:On Ubuntu (root), the calculated
bytes_received
value is incorrect, asresponse
is truncated.On Windows 10, the
self._sock.recvfrom(1024)
triggers the below exception, which is swallowed within theicmplib/ping.py
ping
method by:ICMPLibError: [WinError 10040] A message sent on a datagram socket was larger than the internal message buffer or some other network limit, or the buffer used to receive a datagram into was smaller than the datagram itself
The flow on effect is that RTTs aren't calculated, and the
host.is_alive
is incorrectly set toFalse
,Fix
Simply allocating a buffer that can hold the max possible ICMP packet size (i.e. IPv4 max packet size) seems to work:
Example
(Windows), sending 3 pings:
This is a nice tool, hope this helps!
The text was updated successfully, but these errors were encountered: