Project Home
Project Home
Wiki
Wiki
Discussion Forums
Discussions
Project Information
Project Info
Forum Topic - How to detecting the network down quickly?: (5 Items)
   
How to detecting the network down quickly?  
Dear all,

Is there a way to quickly detect when an ethernet is disconnected ?(This could be the peer PC is freezed, or the 
ethernet cable is unplugged from the switch, or the ethernet is brought down( e.g. ifconfig down command)).
 
I am using POSIX message queue to exchange messages between two QNX6.5.0 PCs. If the connection lost, the mq_open() 
operation normally takes 3-5seconds to return an open error. That is too long for me, is there a way to know quickly 
within milliseconds that the connection is broken? Or is there any events I can watch upon the lost of the connection ?

Thanks in advance!

Yours
Jay
Re: How to detecting the network down quickly?  
You can use ifwatchd to detect when the cable is disconnected or when 
the interface is brought down (the utility uses routing control messages 
- see socket#PF_ROUTE).

In the case of a peer PC freezing I think you might try setting the send 
timeout value (I believe this would support microsecond resolution) and 
try sending a packet to the peer (see setsockopt#SO_SNDTIMEO).
Re: How to detecting the network down quickly?  
> In the case of a peer PC freezing I think you might try setting the send 
> timeout value (I believe this would support microsecond resolution) and 
> try sending a packet to the peer (see setsockopt#SO_SNDTIMEO).

Millisecond resolution here is a bit ridiculous though.

-seanb
Re: How to detecting the network down quickly?  
You're right - I wasn't considering network latency at all. So set the timeout to the highest observed network latency 
(so if highest was <200ms then set the timeout to 200ms) or just set the timeout to 1 second and be safe.
Re: How to detecting the network down quickly?  
Thanks a lot for your super fast response! Really appreciated you nice guys!

Yes, I can use mq_timedsend to send but the problem is the open(Which takes a 3-5 seconds to return a failure if a peer 
PC is freezing). I have to open that message queue first, get a file descriptor, then use the file descriptor to do send
. Unfortunately, I can find a timed open() or a timed access() functions to test the existence of the remote message 
queues  :(. 

I will try ifwatchd to detect when the cable is disconnected or when 
the interface is brought down. Didn't use that before.

I am testing a hot swap application between two QNX PCs, upon one machine freezing, another PC takes over the task, that
 is why I need to detect the failure very fast, otherwise, a lot of packets will be lost. 

Yours
Jay