How can I perform a ping or traceroute using native python?

后端 未结 7 1684
走了就别回头了
走了就别回头了 2021-01-05 14:56

I would like to be able to perform a ping and traceroute from within Python without having to execute the corresponding shell commands so I\'d prefer a native python solutio

7条回答
  •  鱼传尺愫
    2021-01-05 15:47

    ICMP Ping is standard as part of the ICMP protocol.

    Traceroute uses features of ICMP and IP to determine a path via Time To Live values. Using TTL values, you can do traceroutes in a variety of protocols as long as IP/ICMP work because it is the ICMP TTL EXceeded messages that tell you about the hop in the path.

    If you attempt to access a port where no listener is available, by ICMP protocol rules, the host is supposed to send an ICMP Port Unreachable message.

提交回复
热议问题