Re: Non-MII card link detection

Hi Dan,

On Sun, 06 Feb 2005 14:07:20 +0200, Paul Ionescu wrote:
> Hi Dan,
> On Sun, 06 Feb 2005 00:07:08 -0500, Dan Williams wrote:
>> Hi,
>> Ok, so I did non-MII link detection as follows:
>> Every wired device has a timout function running in the device thread,
>> that every 2s checks the numbers in:
>> /sys/class/net/<dev>/statistics/rx_packets
>> /sys/class/net/<dev>/statistics/collisions
>> If the numbers have changed within the last 10s, then the code sets link
>> status to TRUE.  If they have not changed, it sets link status to FALSE.
>> While this works great at the office, where there are a lot of broadcast
>> packets around, this works badly for my home network with 1 server and
>> just the laptop, using a Belkin F5D5020 that doesn't support either MII
>> or ethtool.  There just isn't enough traffic to update the statistics
>> within 10s necessarily.
> I have a suggestion, but I don't really know if we can do this in NM, or
> if it will work as expected, because I never tried it.
> Every X seconds we send a special frame on the wire, the destination
> address is our own MAC address of that interface, which means that we
> are the end destination of that packet. The ether-type can be 0x9000
> which is
>  registered for loopback packets.
> If the link is up, we should receive this packet because it has our own
> mac address as destination, which will be reflected in rx_packets
> counter. Now, if we miss Y packet in a row, we could assume the link is
> off.
> X is a user configurable interval, and have a sane default, like 5 or 10
> secs, and Y is the number of replies we are allow to loose before we
> declare the link down.
> What do you think about it ?

I actually did some further test, and so far I like what I found.
I used only ready available tools (like ping) because I did not have time
to do some real programs.
Here is what I did:

Plug out the network cable from the eth0.
On eth0 I have IP addr
I did "ping -b" and I could see TX bytes growing, the RX bytes
were remaining the same.
Then I plugged a HARD LOOPBACK RJ-45 in the eth0 network card, to simulate
a silent network, and redid the ping -b.
And the surprise was that it actually worked as I expected, meaning that
RX bytes were growing this time, because ping -b sends a ping to the
broadcast mac address.
Now, this is just a proof a concept that is works this way.

Comments ?

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]