ping with python?

Christian Tismer tismer at tismer.com
Tue Feb 4 21:43:20 CET 2003


Jeff Bauer wrote:
> This page http://www.python.org/~jeremy/python.html has
> an implementation of ping.

Without looking onto the code, it partially
seems to work under Win2k, but gives a funny crash:

D:\tmp\ping\ping>python ping.py tismer.com
PING tismer.com
21 bytes from tismer.com (216.110.35.181): icmp_seq=0. time=210. ms
21 bytes from tismer.com (216.110.35.181): icmp_seq=1. time=189. ms
21 bytes from tismer.com (216.110.35.181): icmp_seq=2. time=211. ms
21 bytes from tismer.com (216.110.35.181): icmp_seq=3. time=189. ms
21 bytes from tismer.com (216.110.35.181): icmp_seq=4. time=190. ms
21 bytes from tismer.com (216.110.35.181): icmp_seq=5. time=200. ms
21 bytes from tismer.com (216.110.35.181): icmp_seq=6. time=179. ms
21 bytes from tismer.com (216.110.35.181): icmp_seq=7. time=200. ms
21 bytes from tismer.com (216.110.35.181): icmp_seq=8. time=179. ms
Traceback (most recent call last):
   File "ping.py", line 175, in ?
     p.ping()
   File "ping.py", line 158, in ping
     Pinger.ping(self)
   File "ping.py", line 103, in ping
     self.wait()
   File "ping.py", line 120, in wait
     repip = ip.Packet(pkt)
   File "ip.py", line 79, in __init__
     self.__disassemble(packet, cksum)
   File "ip.py", line 157, in __disassemble
     packet = inet.net2iph(raw_packet)
   File "inet.py", line 49, in net2iph
     return s[:2] + mks(len) + mks(id) + mks(off) + s[8:]
   File "inet.py", line 37, in mks
     return struct.pack('h', h)
struct.error: short format requires SHRT_MIN<=number<=SHRT_MAX

D:\tmp\ping\ping>

> In addition to Jeremy's code, Matthew Cowles has also
> written a Python implementation of ping:
> 
>   http://www.visi.com/~mdc/pythonstuff.html

Hey, this is a nice one! Tested it under
Windows 2000 - great, no probs!
Perfect for gamers who just want to take
a single measure, like my son :-)

ciao - chris

-- 
Christian Tismer             :^)   <mailto:tismer at tismer.com>
Mission Impossible 5oftware  :     Have a break! Take a ride on Python's
Johannes-Niemeyer-Weg 9a     :    *Starship* http://starship.python.net/
14109 Berlin                 :     PGP key -> http://wwwkeys.pgp.net/
work +49 30 89 09 53 34  home +49 30 802 86 56  pager +49 173 24 18 776
PGP 0x57F3BF04       9064 F4E1 D754 C2FF 1619  305B C09C 5A3B 57F3 BF04
      whom do you want to sponsor today?   http://www.stackless.com/






More information about the Python-list mailing list