[Twisted-Python] Support for ICMP ping?
I've been googling if there is any 'ICMP ping' support in Twisted. I've encounter ancient replies: http://twistedmatrix.com/pipermail/twisted-python/2003-August/005542.html I wonder if today is any ICMP support. I've tried to search the source tree[1], and doesn't seem. My actual needs is creating a DeferredList with "ping-testers" for different IPs, just to check if there up or not. I know I can end up using twisted.internet.utils.getProcessOutput and calling ping, as I would normally do from command line. For other newbies as me in the same situation please read: http://twistedmatrix.com/users/moshez/talk.html and search for 'getProcessOutput' ;-) Greetings, [1] my search was: -------------------------------------------------------------------- $ grep -C3 -ir icmp * internet/protocol.py- internet/protocol.py- internet/protocol.py-class AbstractDatagramProtocol: internet/protocol.py: """Abstract protocol for datagram-oriented transports, e.g. IP, ICMP, ARP, UDP.""" internet/protocol.py- internet/protocol.py- transport = None internet/protocol.py- numPorts = 0 -- internet/protocol.py- def connectionRefused(self): internet/protocol.py- """Called due to error from write in connected mode. internet/protocol.py- internet/protocol.py: Note this is a result of ICMP message generated by *previous* internet/protocol.py- write. internet/protocol.py- """ internet/protocol.py- -------------------------------------------------------------------- -- Nicolás D. César <ncesar@lunix.com.ar> Lunix S.R.L. -[ http://www.lunix.com.ar ]- GnuPG Public Key: gpg --keyserver wwwkeys.pgp.net --recv-key 0x3606F3E6
FWIW, I wrote a Perl module called Net::Ping::External that used the system 'ping' command to do ICMP ping on a variety of OSes. 'ping' commands are remarkably different from platform to platform, in terms of the arguments expected and the return values (IIRC win32 doesn't return differently on success or failure so you actually need to parse the output), so the purpose of N::P::E was to make a standard cross-platform way of getting a useful result from the system ICMP ping utilities. The module supports Win32, Linux, BSD, Solaris (2.6 and 2.7 at least), IRIX, and supposedly a bunch of other obscure systems (based on output that I was given by a few of the Perl developers that had odd platforms available.) I've not look at or touched that code in years, but you might want to look into it if you feel like writing a cross-platformish pinger for Python. (Google for Net::Ping::External and take any of the first 50 or so hits :)) - Colin
El Lunes, 11 de Septiembre de 2006 17:10, Colin McMillen escribió:
FWIW, I wrote a Perl module called Net::Ping::External that used the system 'ping' command to do ICMP ping on a variety of OSes.
Thanks Colin for your reply. I'm not a very good Perl speaker and I must do this in Python, so probably I'll see Net::Ping::External as a future reference. Greetings -- Nicolás D. César <ncesar@lunix.com.ar> Lunix S.R.L. -[ http://www.lunix.com.ar ]- GnuPG Public Key: gpg --keyserver wwwkeys.pgp.net --recv-key 0x3606F3E6
On Mon, Sep 11, 2006 at 05:24:48PM -0300, Nicolas D. Cesar wrote:
El Lunes, 11 de Septiembre de 2006 17:10, Colin McMillen escribió:
FWIW, I wrote a Perl module called Net::Ping::External that used the system 'ping' command to do ICMP ping on a variety of OSes.
Thanks Colin for your reply. I'm not a very good Perl speaker and I must do this in Python, so probably I'll see Net::Ping::External as a future reference.
That's mostly what I intended. What I mean is, a bunch of people already did the difficult work of reporting the arguments and outputs to "ping" on their system, so reading the code should at least give you an idea of how to write code that supports the systems you're interested in supporting. (Of course, most likely you only care about one specific system, in which case you may as well make a throwaway script with a shell command in it. :)) - Colin
On a similar note, I've been looking to implement OSPF in twisted (which does multicast over IP protocol 89), and was wondering the best way to bludgeon DatagramSocket into doing raw IP. (Preferably in a cross-platform manner, but if it only works on Linux it'd suit my purposes fine) Any hints? BTW, is there any interest in BGP around here? I've implemented it as a research project for work, and they've given me the go ahead to release the source. Oh, and to answer the original question... take a look at fping. It's output is designed to be parsed, and it scales really well.
On Tue, 12 Sep 2006 11:42:49 +1000, Michael Samuel <michael@miknet.net> wrote:
On a similar note, I've been looking to implement OSPF in twisted (which does multicast over IP protocol 89), and was wondering the best way to bludgeon DatagramSocket into doing raw IP. (Preferably in a cross-platform manner, but if it only works on Linux it'd suit my purposes fine) Any hints?
You can't and shouldn't co-opt DatagramSocket for this. Instead, add a new kind of transport, a raw socket. This should be fairly straightforward and it would actually be a fairly useful addition to Twisted.
BTW, is there any interest in BGP around here? I've implemented it as a research project for work, and they've given me the go ahead to release the source.
It'd be neat. I can't think of anything I'd personally be able to _do_ with it. :)
Oh, and to answer the original question... take a look at fping. It's output is designed to be parsed, and it scales really well.
I'll second this recommendation. You need root privileges on most systems to open an ICMPable socket anyway. Running your whole process as root just so you can ping some stuff is kind of unfortunate. Jean-Paul
El Lunes, 11 de Septiembre de 2006 23:42, Jean-Paul Calderone escribió:
I'll second this recommendation. You need root privileges on most systems to open an ICMPable socket anyway. Running your whole process as root just so you can ping some stuff is kind of unfortunate.
Thanks Jean-Paul for the reply. Yes, i'm aware of that, but in my case, I need to run my application as root anyway because im using ip_queue to filter dhcp packets, and only root can do that. So I was asking if there is any plans of expanding twisted, so a root-capable twisted application could ping the world! I have little python and twisted skills , but if there is interest I could help in the develop. Greetings, BTW, the application I'm developing (and all my work actually) is released as Free Software. If anyone is interested in having it, just mail me or wait until I put a nice-little-project page on-line. As allways: Pardon my English. -- Nicolás D. César <ncesar@lunix.com.ar> Lunix S.R.L. -[ http://www.lunix.com.ar ]- GnuPG Public Key: gpg --keyserver wwwkeys.pgp.net --recv-key 0x3606F3E6
On Mon, 2006-09-11 at 16:57 -0300, Nicolas D. Cesar wrote:
I've been googling if there is any 'ICMP ping' support in Twisted. I've encounter ancient replies:
http://twistedmatrix.com/pipermail/twisted-python/2003-August/005542.html
I wonder if today is any ICMP support. I've tried to search the source tree[1], and doesn't seem.
My actual needs is creating a DeferredList with "ping-testers" for different IPs, just to check if there up or not.
I'm a little behind in my reading, but this caught my eye. I've written a twisted based ICMP module for our seafelt software that I'm willing to share with people, if you're still looking for one. The purpose for writing it is very similar to what you've described here, so it may suit your purposes. -- Justin Warren <daedalus@eigenmagic.com>
participants (5)
-
Jean-Paul Calderone
-
Justin Warren
-
mcmillen@cs.cmu.edu
-
Michael Samuel
-
Nicolas D. Cesar