Giter VIP home page Giter VIP logo

Comments (10)

kyan001 avatar kyan001 commented on September 15, 2024

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.

ste48 avatar ste48 commented on September 15, 2024

from ping3.

kyan001 avatar kyan001 commented on September 15, 2024

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.

ste48 avatar ste48 commented on September 15, 2024

I did. Do you want me to the complete session or only one faulty ping?

from ping3.

kyan001 avatar kyan001 commented on September 15, 2024

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.

ste48 avatar ste48 commented on September 15, 2024

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.

ste48 avatar ste48 commented on September 15, 2024

hope, that helps

from ping3.

kyan001 avatar kyan001 commented on September 15, 2024

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.

ste48 avatar ste48 commented on September 15, 2024

from ping3.

kyan001 avatar kyan001 commented on September 15, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.