Comments (10)
Hi @ste48 ,
Can you turn on the debug mode by setting ping3.DEBUG = True
then test them again?
If the debug mode is on, there are more info printed on the screen, you can copy them or screenshot them and paste here.
from ping3.
from ping3.
Try this:
import ping3
ping3.DEBUG = True
# Codes
def do_ping(host_ip):
PingErgebnis = 1
a = ping3.ping(host_ip)
if a == False:
PingErgebnis=0
print(host_ip, a, "PingErgebnis", PingErgebnis)
return PingErgebnis
from ping3.
I did. Do you want me to the complete session or only one faulty ping?
from ping3.
It's better to see all the outputs. But if you think it's too long, let's focus on one faulty ping first.
from ping3.
here is a faulty one:
[DEBUG] Ping3 Version: 3.0.1
[DEBUG] LOGGER: <Logger ping3 (DEBUG)>
[DEBUG] Function Called: ping('192.168.99.80')
[DEBUG] Function Called: send_one_ping({'sock': <socket.socket fd=736, family=AddressFamily.AF_INET, type=SocketKind.SOCK_RAW, proto=1>, 'dest_addr': '192.168.99.80', 'icmp_id': 10439, 'seq': 0, 'size': 56})
[DEBUG] Destination Address: '192.168.99.80'
[DEBUG] Destination Address: 192.168.99.80
[DEBUG] Sent ICMP Header: {'type': 8, 'code': 0, 'checksum': 15033, 'id': 10439, 'seq': 0}
[DEBUG] Sent ICMP Payload: b'A\xd8I\x8c\xdd\xad\x8b\xcdQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQ'
[DEBUG] Function Returned: send_one_ping -> None
[DEBUG] Function Called: receive_one_ping({'sock': <socket.socket fd=736, family=AddressFamily.AF_INET, type=SocketKind.SOCK_RAW, proto=1, laddr=('0.0.0.0', 0)>, 'icmp_id': 10439, 'seq': 0, 'timeout': 4})
[DEBUG] Timeout time: Wed Aug 25 13:11:38 2021
[DEBUG] Timeout left: 4.00s
[DEBUG] Received IP Header: {'version': 69, 'tos': 0, 'len': 84, 'id': 34939, 'flags': 0, 'ttl': 255, 'protocol': 1, 'checksum': 60524, 'src_addr': '192.168.99.80', 'dest_addr': '192.168.98.31'}
[DEBUG] Received ICMP Header: {'type': 0, 'code': 0, 'checksum': 17081, 'id': 10439, 'seq': 0}
[DEBUG] Received ICMP Payload: b'A\xd8I\x8c\xdd\xad\x8b\xcdQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQ'
[DEBUG] Function Returned: receive_one_ping -> 0.0
[DEBUG] Function Returned: ping -> 0.0
[DEBUG] Function Called: ping('192.168.99.81')
[DEBUG] Function Called: send_one_ping({'sock': <socket.socket fd=736, family=AddressFamily.AF_INET, type=SocketKind.SOCK_RAW, proto=1>, 'dest_addr': '192.168.99.81', 'icmp_id': 10439, 'seq': 0, 'size': 56})
[DEBUG] Destination Address: '192.168.99.81'
[DEBUG] Destination Address: 192.168.99.81
[DEBUG] Sent ICMP Header: {'type': 8, 'code': 0, 'checksum': 10840, 'id': 10439, 'seq': 0}
[DEBUG] Sent ICMP Payload: b'A\xd8I\x8c\xdd\xad\x9c.QQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQ'
[DEBUG] Function Returned: send_one_ping -> None
192.168.99.80 0.0 PingErgebnis 0
from ping3.
hope, that helps
from ping3.
I just update ping3 to version 3.0.2, can you update your ping3 to this version and run the test again? 3.0.2 adds more debug outputs so I can dive deeper to this problem. (3.0.2 did not solve your problem, it just add some outputs. Paste your debug outputs here please).
from ping3.
from ping3.
Hi @ste48 ,
I read the debug outputs and it's really helpful, Thank you for your work.
When host is unreachable, the ping()
will return False
. And for the 0.0 return by ping()
, it's probably because the latency between the two hosts is even lower than the precision of time.time()
(which should have the best precision on Linux according to offical doc). This also reminds me that in some implementations of ping, they show "<1ms" on this case. If you want to test the precision on your machine, run the following code:
import time
def get_precision():
start = time.time()
end = time.time()
while start == end:
end = time.time()
return end - start
print("Precision is", get_precision(), "second.")
To tell if a host is unreachable or have a really low latency, you can try the following codes:
if a is False:
# host unreachable
elif a is None:
# timeout
else:
# host available
If you get your precision, let me know for further discussion.
from ping3.
Related Issues (20)
- ping never ends while pc is hibernated HOT 1
- ping not support count ? HOT 1
- Is it possible to save the results in a variable? HOT 2
- How to get packet loss? HOT 1
- ping3 does not support ipv6 and that is not documented HOT 1
- Patch failure due to "different line endings" HOT 1
- ping3 does not support IPv6 HOT 2
- Dont work in 3.11.1 HOT 4
- Inconsistency between ping and verbose_ping: count parmameter and return value HOT 1
- Payload size and TTL in response HOT 8
- Not receiving low TTL response. Receiving Timeout instead. HOT 11
- Can you create a new git tag for release 4.0.4 HOT 1
- Inconsistent cross-distro behavior HOT 6
- Add to APT? HOT 6
- Some exceptions are still thrown even if EXCEPTIONS mode is disabled HOT 2
- Unit tests failing HOT 2
- Incomplete type hints HOT 3
- 4.0.6 fails to import in Python <3.10 HOT 6
- Not respecting options passed as parameters HOT 2
- Destination unreachable HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. πππ
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ping3.