Detecting Network Link Failure

Discussion to talk about software related topics only.
Post Reply
dacoast
Posts: 14
Joined: Fri Apr 25, 2008 10:09 am

Detecting Network Link Failure

Post by dacoast »

How can I detect a failed network connection quickly?

I have been using the EtherLink() function to check the link status on
a Mod-5272, but it seems to take several seconds to indicate a link failure after
unplugging the cable.

I would like to detect a failed link after 100 or 200 msec. Is there
anyway to do this?

Thanks,

Doug
User avatar
lgitlitz
Posts: 331
Joined: Wed Apr 23, 2008 11:43 am
Location: San Diego, CA
Contact:

Re: Detecting Network Link Failure

Post by lgitlitz »

This can be done by reading directly from the PHY registers. The release build Ethernet driver interacts with the PHY so we check for a link with EtherLink() at the software level. This ensures you will be able to communicate on Ethernet when gaining the link but can delay the indication of a lost link. The Debug Ethernet driver has no PHY interaction, so a call to the EtherLink() function returns the immediate link state reported by the PHY. Now that I think about it this EtherLink() function should change for release build so it checks both the PHY and software levels to ensure a link is valid. This way the software link delay is still present when gaining a link but there will be no delay from this function when indicating a link is lost.

You can find the EtherLink function code here:
C:\Nburn\"platform"\system\etherprint.cpp
or in your case C:\Nburn\MOD5272\system\etherprint.cpp

I changed the function to the following, this will be in future releases:

BOOL EtherLink()
{
#ifndef _DEBUG
if( !bEthLink ) // do we have link?
return FALSE;
#else
EtherInit();
#endif
if ( ( GetMII( PHY_addr, 0x01 ) & 0x0024 ) == 0x0024 )
return TRUE;
else
return FALSE;
}

After you make these changes rebuild the platform system directory and you should be good to go.

-Larry
dacoast
Posts: 14
Joined: Fri Apr 25, 2008 10:09 am

Re: Detecting Network Link Failure

Post by dacoast »

Thanks Larry!
The updated Etherlink() function works exactly
like I need it to now.

Netburner support is awesome!

-Doug
Post Reply