[H-GEN] testing network connectivity with perl

Christopher Biggs listjunkie at pobox.com
Sun Aug 24 06:42:09 EDT 2003


[ Humbug *General* list - semi-serious discussions about Humbug and     ]
[ Unix-related topics. Posts from non-subscribed addresses will vanish. ]

Conor Cunningham <cunningtek at optusnet.com.au> moved upon the face of the 'Net and spake thusly:

> I'm currently writing a script that simply pings a UNIX box every
> sixty seconds
> and logs any failed pings. 

I've done that, in perl some years ago, using the standalone ping (as
perl's Net::Ping didn't really do the right thing).

> However, I have been asked to connect to an
> ORACLE port on the same UNIX box and log if the connection ever drops
> out.
>
> The connection sometimes drops out, but only for a split second, and
> we need to prove this fact with logs files.

What do you exactly mean by "drops out"?   Connection closed?
Temporary packet loss?   

> So to start off, I connect to the ORACLE port using IO::Socket and log
> success or failure.
>
> I then enter a while(1) loop and do an
>
> if(!connection) {log failure}
>
> How I have been testing this is to simply unplug the network cable
> from my laptop, then replug it.

TCP is *supposed* to survive stuff like that.

Failures at the link layer are not something that the transport layer
is supposed to even care about.

If you want to detect link failure, all you can do is attempt some
trivial transaction over the socket and see if you get a response
within the expected timeout.

(If you have an OS that supports per-socket control over the TCP
keepalive timer, you could also set a ludicrously short keepalive on
the socket and see what happens...)


--
* This is list (humbug) general handled by majordomo at lists.humbug.org.au .
* Postings to this list are only accepted from subscribed addresses of
* lists 'general' or 'general-post'.  See http://www.humbug.org.au/



More information about the General mailing list