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
Detecting Network Link Failure
Re: Detecting Network Link Failure
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
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
Re: Detecting Network Link Failure
Thanks Larry!
The updated Etherlink() function works exactly
like I need it to now.
Netburner support is awesome!
-Doug
The updated Etherlink() function works exactly
like I need it to now.
Netburner support is awesome!
-Doug