-
Notifications
You must be signed in to change notification settings - Fork 57
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
Destination unreachible causes AttributeError in DestinationUnreachible #52
Comments
Hi @drisen , Sorry for the inconvenience. I'll look into the bug. Is it possible to have the debug outputs for such a case? Just turn on Thanks. |
I'll do a diagnostic run with DEBUG later today.
I notice that ping3 uses time.time() to measure relative time. time.time()
references the system clock, which is not guaranteed to be monotonic. When
measuring timeout and round-trip delay, it's better to use
time.monotonic(). The difference in the results can be astonishing when a
system is adjusting its system clock.
As an example, consider a Windows laptop that is a member of a Microsoft
domain. Microsoft's recommended domain settings do not allow the laptop to
synchronize time to anything except its Microsoft domain controller through
a secure Microsoft protocol. For security reasons, domain controllers are
often within the enterprise intranet and not accessible from the public
internet. While such a laptop is away from the enterprise intranet, its
system clock drifts slowly relative to the domain controller's clock. When
it reconnects to the enterprise intranet, Windows slews its system clock to
match the domain controller's clock.
The slew rate that I've seen is about 5X realtime. If you calculate elapsed
real time using time.time(), during such system clock synchronization
you'll calculate values that may be 5X actual, or even negative!
…On Tue, Mar 29, 2022 at 9:52 PM Kyan ***@***.***> wrote:
Hi @drisen <https://github.com/drisen> ,
Sorry for the inconvenience. I'll look into the bug. Is it possible to
have the debug outputs for such a case? Just turn on ping3.DEBUG = True
right after import ping3. It would be a great help to address the problem.
Thanks.
—
Reply to this email directly, view it on GitHub
<#52 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/ABBKAPHGUNUN7DPXOAE53ZDVCO6U7ANCNFSM5SAOJMQA>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
--
Dennis Risen
University Technology, [U]Tech
Case Western Reserve University
Cleveland, OH 44106-7072
(216)798-9086 (cell)
|
Hi, I noticed the same under Linux.
This is the content of
where X.X.X.X is my IP address |
I think it can be resolved by changing line 30 (and possibly the same lines doing the same) with:
|
P.S. The system clock slewing is extreme in the above example, but also
occurs with every OS in response to manual time setting or synchronization
with an external time standard.
Here's stdout+stderr from a run with ping3.DEBUG=True and my WiFi
disconnected. Your DEBUG output is interleaved with output from my
exception handling in my following wrapper around ping3.ping.
def ping_wrapped(*args, **kwargs) -> Union[float, bool, str, None]:
try: # wrap to capture ping3 bug
return ping3.ping(*args, **kwargs)
except AttributeError as e:
print(f"{datetime.datetime.fromtimestamp(time.time()).strftime(fmt)}:
{e}")
traceback.print_exc()
return "Unreachable"
[DEBUG] Ping3 Version: 4.0.0
[DEBUG] LOGGER: <Logger ping3 (DEBUG)>
[DEBUG] Function called: ping('1.0.0.1', {'timeout': 2, 'unit': 'ms',
'size': 56})
[DEBUG] Function called: send_one_ping({'sock': <socket.socket fd=656,
family=AddressFamily.AF_INET, type=SocketKind.SOCK_RAW, proto=1>,
'dest_addr': '1.0.0.1', 'icmp_id': 636, 'seq': 0, 'size': 56})
[DEBUG] Destination address: '1.0.0.1'
[DEBUG] Destination IP address: 1.0.0.1
[DEBUG] Sent ICMP header: {'type': 8, 'code': 0, 'checksum': 40940, 'id':
636, 'seq': 0}
[DEBUG] Sent ICMP payload:
b'A\xd8\x91$\x99\xeeI\x0cQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQ'
[DEBUG] Function returned: send_one_ping -> None
[DEBUG] Function called: receive_one_ping({'sock': <socket.socket fd=656,
family=AddressFamily.AF_INET, type=SocketKind.SOCK_RAW, proto=1,
laddr=('0.0.0.0', 0)>, 'icmp_id': 636, 'seq': 0, 'timeout': 2})
[DEBUG] Timeout time: Wed Mar 30 12:24:57 2022 (1648661097.7244103)
[DEBUG] Timeout left: 2.00s
[DEBUG] Request timeout for ICMP packet. (Timeout=2s)
[DEBUG] Function returned: ping -> None
[DEBUG] Function called: ping('192.168.0.1', {'timeout': 2, 'unit': 'ms',
'size': 504})
[DEBUG] Function called: send_one_ping({'sock': <socket.socket fd=656,
family=AddressFamily.AF_INET, type=SocketKind.SOCK_RAW, proto=1>,
'dest_addr': '192.168.0.1', 'icmp_id': 636, 'seq': 0, 'size': 504})
[DEBUG] Destination address: '192.168.0.1'
[DEBUG] Destination IP address: 192.168.0.1
[DEBUG] Sent ICMP header: {'type': 8, 'code': 0, 'checksum': 6401, 'id':
636, 'seq': 0}
[DEBUG] Sent ICMP payload:
b'A\xd8\x91$\x9an\xa8PQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQ'
[DEBUG] Function returned: send_one_ping -> None
[DEBUG] Function called: receive_one_ping({'sock': <socket.socket fd=656,
family=AddressFamily.AF_INET, type=SocketKind.SOCK_RAW, proto=1,
laddr=('0.0.0.0', 0)>, 'icmp_id': 636, 'seq': 0, 'timeout': 2})
[DEBUG] Timeout time: Wed Mar 30 12:24:59 2022 (1648661099.7296977)
[DEBUG] Timeout left: 2.00s
2022-03-30 12:24:58: 'str' object has no attribute 'get'
[DEBUG] Received time: Wed Mar 30 12:24:58 2022 (1648661098.564356))
[DEBUG] Received IP header: {'version': 69, 'tos': 0, 'len': 560, 'id':
587, 'flags': 0, 'ttl': 128, 'protocol': 1, 'checksum': 0, 'src_addr':
'192.168.0.41', 'dest_addr': '192.168.0.41'}
[DEBUG] Received ICMP header: {'type': 3, 'code': 1, 'checksum': 5454,
'id': 0, 'seq': 0}
[DEBUG] Received ICMP payload:
b'E\x00\x02\x14\x9f\x1f\x00\x00\x80\x01\x00\x00\xc0\xa8\x00)\xc0\xa8\x00\x01\x08\x00\x19\x01\x02|\x00\x00A\xd8\x91$\x9an\xa8PQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQ'
Traceback (most recent call last):
File "G:/My Drive/Case/PyCharm/netstats/ping_stats.py", line 30, in
ping_wrapped
return ping3.ping(*args, **kwargs)
File
"C:\Users\dar5\AppData\Local\Programs\Python\Python38\lib\site-packages\ping3\__init__.py",
line 83, in wrapper
func_return = func(*args, **kwargs)
File
"C:\Users\dar5\AppData\Local\Programs\Python\Python38\lib\site-packages\ping3\__init__.py",
line 311, in ping
delay = receive_one_ping(sock=sock, icmp_id=icmp_id, seq=seq,
timeout=timeout) # in seconds
File
"C:\Users\dar5\AppData\Local\Programs\Python\Python38\lib\site-packages\ping3\__init__.py",
line 83, in wrapper
func_return = func(*args, **kwargs)
File
"C:\Users\dar5\AppData\Local\Programs\Python\Python38\lib\site-packages\ping3\__init__.py",
line 240, in receive_one_ping
raise errors.DestinationHostUnreachable(ip_header=ip_header,
icmp_header=icmp_header)
File
"C:\Users\dar5\AppData\Local\Programs\Python\Python38\lib\site-packages\ping3\errors.py",
line 30, in __init__
super().__init__(self.message)
File
"C:\Users\dar5\AppData\Local\Programs\Python\Python38\lib\site-packages\ping3\errors.py",
line 21, in __init__
self.message = message if self.ip_header is None else message + "
(Host='{}')".format(self.ip_header.get("src_addr"))
AttributeError: 'str' object has no attribute 'get'
[DEBUG] Function called: ping('192.168.0.1', {'timeout': 2, 'unit': 'ms',
'size': 504})
[DEBUG] Function called: send_one_ping({'sock': <socket.socket fd=656,
family=AddressFamily.AF_INET, type=SocketKind.SOCK_RAW, proto=1>,
'dest_addr': '192.168.0.1', 'icmp_id': 636, 'seq': 0, 'size': 504})
[DEBUG] Destination address: '192.168.0.1'
[DEBUG] Destination IP address: 192.168.0.1
[DEBUG] Sent ICMP header: {'type': 8, 'code': 0, 'checksum': 8081, 'id':
636, 'seq': 0}
[DEBUG] Sent ICMP payload:
b'A\xd8\x91$\x9a\xa4\xa1\x8aQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQ'
[DEBUG] Function returned: send_one_ping -> None
[DEBUG] Function called: receive_one_ping({'sock': <socket.socket fd=656,
family=AddressFamily.AF_INET, type=SocketKind.SOCK_RAW, proto=1,
laddr=('0.0.0.0', 0)>, 'icmp_id': 636, 'seq': 0, 'timeout': 2})
[DEBUG] Timeout time: Wed Mar 30 12:25:00 2022 (1648661100.5733593)
[DEBUG] Timeout left: 2.00s
[DEBUG] Request timeout for ICMP packet. (Timeout=2s)
[DEBUG] Function returned: ping -> None
[DEBUG] Function called: ping('192.168.0.1', {'timeout': 2, 'unit': 'ms',
'size': 504})
[DEBUG] Function called: send_one_ping({'sock': <socket.socket fd=656,
family=AddressFamily.AF_INET, type=SocketKind.SOCK_RAW, proto=1>,
'dest_addr': '192.168.0.1', 'icmp_id': 636, 'seq': 0, 'size': 504})
[DEBUG] Destination address: '192.168.0.1'
[DEBUG] Destination IP address: 192.168.0.1
[DEBUG] Sent ICMP header: {'type': 8, 'code': 0, 'checksum': 32093, 'id':
636, 'seq': 0}
[DEBUG] Sent ICMP payload:
b'A\xd8\x91$\x9b%C=QQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQ'
[DEBUG] Function returned: send_one_ping -> None
[DEBUG] Function called: receive_one_ping({'sock': <socket.socket fd=656,
family=AddressFamily.AF_INET, type=SocketKind.SOCK_RAW, proto=1,
laddr=('0.0.0.0', 0)>, 'icmp_id': 636, 'seq': 0, 'timeout': 2})
[DEBUG] Timeout time: Wed Mar 30 12:25:02 2022 (1648661102.582229)
[DEBUG] Timeout left: 2.00s
2022-03-30 12:25:01: 'str' object has no attribute 'get'
[DEBUG] Received time: Wed Mar 30 12:25:01 2022 (1648661101.5628836))
[DEBUG] Received IP header: {'version': 69, 'tos': 0, 'len': 560, 'id':
588, 'flags': 0, 'ttl': 128, 'protocol': 1, 'checksum': 0, 'src_addr':
'192.168.0.41', 'dest_addr': '192.168.0.41'}
[DEBUG] Received ICMP header: {'type': 3, 'code': 1, 'checksum': 5452,
'id': 0, 'seq': 0}
[DEBUG] Received ICMP payload:
b'E\x00\x02\x14\x9f!\x00\x00\x80\x01\x00\x00\xc0\xa8\x00)\xc0\xa8\x00\x01\x08\x00}]\x02|\x00\x00A\xd8\x91$\x9b%C=QQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQ'
Traceback (most recent call last):
File "G:/My Drive/Case/PyCharm/netstats/ping_stats.py", line 30, in
ping_wrapped
return ping3.ping(*args, **kwargs)
File
"C:\Users\dar5\AppData\Local\Programs\Python\Python38\lib\site-packages\ping3\__init__.py",
line 83, in wrapper
func_return = func(*args, **kwargs)
File
"C:\Users\dar5\AppData\Local\Programs\Python\Python38\lib\site-packages\ping3\__init__.py",
line 311, in ping
delay = receive_one_ping(sock=sock, icmp_id=icmp_id, seq=seq,
timeout=timeout) # in seconds
File
"C:\Users\dar5\AppData\Local\Programs\Python\Python38\lib\site-packages\ping3\__init__.py",
line 83, in wrapper
func_return = func(*args, **kwargs)
File
"C:\Users\dar5\AppData\Local\Programs\Python\Python38\lib\site-packages\ping3\__init__.py",
line 240, in receive_one_ping
raise errors.DestinationHostUnreachable(ip_header=ip_header,
icmp_header=icmp_header)
File
"C:\Users\dar5\AppData\Local\Programs\Python\Python38\lib\site-packages\ping3\errors.py",
line 30, in __init__
super().__init__(self.message)
File
"C:\Users\dar5\AppData\Local\Programs\Python\Python38\lib\site-packages\ping3\errors.py",
line 21, in __init__
self.message = message if self.ip_header is None else message + "
(Host='{}')".format(self.ip_header.get("src_addr"))
AttributeError: 'str' object has no attribute 'get'
…On Wed, Mar 30, 2022 at 11:06 AM Dennis Risen ***@***.***> wrote:
I'll do a diagnostic run with DEBUG later today.
I notice that ping3 uses time.time() to measure relative time. time.time()
references the system clock, which is not guaranteed to be monotonic. When
measuring timeout and round-trip delay, it's better to use
time.monotonic(). The difference in the results can be astonishing when a
system is adjusting its system clock.
As an example, consider a Windows laptop that is a member of a Microsoft
domain. Microsoft's recommended domain settings do not allow the laptop to
synchronize time to anything except its Microsoft domain controller through
a secure Microsoft protocol. For security reasons, domain controllers are
often within the enterprise intranet and not accessible from the public
internet. While such a laptop is away from the enterprise intranet, its
system clock drifts slowly relative to the domain controller's clock. When
it reconnects to the enterprise intranet, Windows slews its system clock to
match the domain controller's clock.
The slew rate that I've seen is about 5X realtime. If you calculate
elapsed real time using time.time(), during such system clock
synchronization you'll calculate values that may be 5X actual, or even
negative!
On Tue, Mar 29, 2022 at 9:52 PM Kyan ***@***.***> wrote:
> Hi @drisen <https://github.com/drisen> ,
>
> Sorry for the inconvenience. I'll look into the bug. Is it possible to
> have the debug outputs for such a case? Just turn on ping3.DEBUG = True
> right after import ping3. It would be a great help to address the
> problem.
>
> Thanks.
>
> —
> Reply to this email directly, view it on GitHub
> <#52 (comment)>, or
> unsubscribe
> <https://github.com/notifications/unsubscribe-auth/ABBKAPHGUNUN7DPXOAE53ZDVCO6U7ANCNFSM5SAOJMQA>
> .
> You are receiving this because you were mentioned.Message ID:
> ***@***.***>
>
--
Dennis Risen
University Technology, [U]Tech
Case Western Reserve University
Cleveland, OH 44106-7072
(216)798-9086 (cell)
--
Dennis Risen
University Technology, [U]Tech
Case Western Reserve University
Cleveland, OH 44106-7072
(216)798-9086 (cell)
|
In Windows 10, Python 3.8, ping version 4.0.0, using WiFi access to the network: if the laptop's WiFi disconnects, ping3.ping detects that the destination is unreachable, but then dies processing the error with an AttributeError in class DestinationUnreachable. E.g.
Traceback (most recent call last):
File "G:/My Drive/Case/PyCharm/netstats/ping_stats.py", line 47, in
result = ping3.ping(site.ipAddress, timeout=timeout, unit='ms', size=56)
File "C:\Users\dar5\AppData\Local\Programs\Python\Python38\lib\site-packages\ping3_init_.py", line 83, in wrapper
func_return = func(*args, **kwargs)
File "C:\Users\dar5\AppData\Local\Programs\Python\Python38\lib\site-packages\ping3_init_.py", line 311, in ping
delay = receive_one_ping(sock=sock, icmp_id=icmp_id, seq=seq, timeout=timeout) # in seconds
File "C:\Users\dar5\AppData\Local\Programs\Python\Python38\lib\site-packages\ping3_init_.py", line 83, in wrapper
func_return = func(*args, **kwargs)
File "C:\Users\dar5\AppData\Local\Programs\Python\Python38\lib\site-packages\ping3_init_.py", line 240, in receive_one_ping
raise errors.DestinationHostUnreachable(ip_header=ip_header, icmp_header=icmp_header)
File "C:\Users\dar5\AppData\Local\Programs\Python\Python38\lib\site-packages\ping3\errors.py", line 30, in init
super().init(self.message)
File "C:\Users\dar5\AppData\Local\Programs\Python\Python38\lib\site-packages\ping3\errors.py", line 21, in init
self.message = message if self.ip_header is None else message + " (Host='{}')".format(self.ip_header.get("src_addr"))
AttributeError: 'str' object has no attribute 'get'
The text was updated successfully, but these errors were encountered: