1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Display of Ethernet connection speed in Device list

Discussion in 'Tomato Firmware' started by occamsrazor, May 11, 2012.

  1. occamsrazor

    occamsrazor Network Guru Member

    I was was wondering whether it might be possible, as an enhancement to the GUI, to show the ethernet connection speed for wired devices in the Device List page. I don't mean the actual traffic speed, just the connection speed i.e. 10/100/1000Mbps.
    Without having to change the tables, I was thinking you could display these values in the column that shows Wifi connection speed - the column named "TX/RX Rate". Anyone else think this would be useful? Possible?
    PS - I've no idea how to actually code such a function, I'm just throwing the idea out there hoping someone with the skills might pick it up...
     
  2. mstombs

    mstombs Network Guru Member

    Should be possible ethtool or mii-tool might work - but its likely to be router/driver specific. Asus have a standalone program 'wanduck' which uses various tricks to determine the state of the wan port, for some reason just finding out whether there's a cable connected isn't straightforward in Linux!
     
  3. BHTeam

    BHTeam LI Guru Member

    This idea, if implemented, can be very useful.
     
  4. waeking

    waeking Networkin' Nut Member

    ipkg doesn't have ethtool but if it was you could use ethtool eth0 | grep -i speed
     
  5. brueggma

    brueggma Networkin' Nut Member

    /usr/sbin/ip should give you this information.

    Looks like /usr/sbin/ip can not show you link/speed. Sorry for the misinformation.

    http://linux.die.net/man/8/ip
     
  6. Dark_Shadow

    Dark_Shadow Addicted to LI Member

    What code would be used to display this information?
     
  7. brueggma

    brueggma Networkin' Nut Member

    I see there is a precompiled binary, but it displays the speed incorrectly for me..

    [root@mainrouter /tmp]$ wget http://multics.minidns.net/tomato/ethtool-2.6.36/ethtool
    Connecting to multics.minidns.net (74.90.75.252:80)
    ethtool 100% |*************************************************************| 191k 00:00:00 ETA
    [root@mainrouter /tmp]$ chmod 755 ethtool
    [root@mainrouter /tmp]$ ./ethtool eth0
    Settings for eth0:
    Supported ports: [ ]
    Supported link modes: 10baseT/Half 10baseT/Full
    100baseT/Half 100baseT/Full
    Supports auto-negotiation: Yes
    Advertised link modes: Not reported
    Advertised pause frame use: No
    Advertised auto-negotiation: Yes
    Link partner advertised link modes: 100baseT/Half
    1000baseT/Full
    Link partner advertised pause frame use: No
    Link partner advertised auto-negotiation: Yes
    Speed: 1833173002Mb/s
    Duplex: Full
    Port: Twisted Pair
    PHYAD: 0
    Transceiver: internal
    Auto-negotiation: on
    MDI-X: Unknown
    Cannot get wake-on-lan settings: Invalid argument
    Cannot get message level: Invalid argument
    Cannot get link status: Invalid argument

    [root@mainrouter /tmp]$ ./ethtool -i eth0
    driver: et0
    version: 5.10.147.0
    firmware-version:
    bus-info:
    [root@mainrouter /tmp]$
     
  8. mstombs

    mstombs Network Guru Member

    So it looks like the universal tool doesn't work - Asus GPL sourcecode does have a function which seems to do exactly what you want though, here 's a sourcecode snippet

    Code:
    // 2bit per port (0-4(5)*2 shift)
    // 0: 10 Mbps
    // 1: 100 Mbps
    // 2: 1000 Mbps
    uint32_t get_phy_speed(uint32_t portmask)
    {
        int fd, tmp;
        struct ifreq ifr;
        // page 0x01 and status register 0x04
        int vecarg[2] = { 0x01 << 16 | 0x04, 0 };
     
        memset(&ifr, 0, sizeof(ifr));
        strcpy(ifr.ifr_name, "eth0"); // is it always the same?
        fd = socket(AF_INET, SOCK_DGRAM, 0);
        if (fd < 0) return 0;
     
        ifr.ifr_data = (caddr_t) vecarg;
        if(ioctl(fd, SIOCGETCROBORD, (caddr_t)&ifr)<0) vecarg[1] = 0;
        close(fd);
     
        /* 53115/53125, 2bit: 0=10 Mbps, 1=100Mbps, 2=1000Mbps */
        /* 5325E/535x,  1bit: 0=10 Mbps, 1=100Mbps */
        tmp = get_model();
        if (tmp != MODEL_RTN66U && tmp != MODEL_RTN16 &&
            tmp != MODEL_RTN15U && tmp != MODEL_RTN53)
        {
            for (tmp = 0; vecarg[1]; vecarg[1] >>= 1) {
                tmp |= (vecarg[1] & 0x01);
                tmp <<= 2;
            }
            vecarg[1] = tmp;
        }
     
    //_dprintf("get_phy_speed %x %x\n", vecarg[1], portmask);
     
        return (vecarg[1] & portmask);
    }
    
     
  9. brueggma

    brueggma Networkin' Nut Member

    Looks like robocfg can possibly get the speed/duplex? http://sourceforge.net/projects/tomatousb/files/Experimental (beta)/K26-MIPSR2/extras-K26-MIPSR2.tar.gz/download

    [root@tivorouter apps]$ ./robocfg show
    Switch: enabled gigabit
    Port 0: 1000FD enabled stp: none vlan: 2 jumbo: off mac: 68:7f:74:c7:12:c4
    Port 1: DOWN enabled stp: none vlan: 1 jumbo: off mac: 00:00:00:00:00:00
    Port 2: DOWN enabled stp: none vlan: 1 jumbo: off mac: 00:00:00:00:00:00
    Port 3: 100FD enabled stp: none vlan: 1 jumbo: off mac: 00:11:d9:30:0e:da
    Port 4: DOWN enabled stp: none vlan: 1 jumbo: off mac: 00:00:00:00:00:00
    Port 5: 1000FD enabled stp: none vlan: 1 jumbo: off mac: 68:7f:74:c7:12:c4
    VLANs: BCM53115 enabled mac_check mac_hash
    1: vlan1: 1 2 3 4 8t
    2: vlan2: 0 8t


    https://code.google.com/p/wl500g/source/browse/trunk/utils/robocfg.c
     
  10. mstombs

    mstombs Network Guru Member

    Yup that tool would be it

    On my RT-N16 it shows the MAC addresses (obscured) on devices connected, which do match up with the device list

    Code:
    root@RTN16:/tmp/home/root# robocfg show
    Switch: enabled gigabit
    Port 0:  100FD enabled stp: none vlan: 2 jumbo: off mac: 00:12:17:xx:yy:zz
    Port 1:  DOWN enabled stp: none vlan: 1 jumbo: off mac: 90:fb:a6:xx:yy:zz
    Port 2: 1000FD enabled stp: none vlan: 1 jumbo: off mac: 00:22:15:xx:yy:zz
    Port 3:  DOWN enabled stp: none vlan: 1 jumbo: off mac: 00:0c:41:xx:yy:zz
    Port 4:  DOWN enabled stp: none vlan: 1 jumbo: off mac: 00:00:00:00:00:00
    Port 5: 1000FD enabled stp: none vlan: 1 jumbo: off mac: 90:e6:ba:xx:yy:zz
      2: vlan2: 0 8t
    
    But on wrt54gs which has various devices and switches hanging off it, need the showmacs command

    Code:
    root@wrt54gs:/tmp/home/root# robocfg show
    Switch: enabled
    Port 0:  100FD enabled stp: none vlan: 1 mac: 00:00:00:00:00:00
    Port 1:  100FD enabled stp: none vlan: 0 mac: 00:00:00:00:00:00
    Port 2:  100FD enabled stp: none vlan: 0 mac: 00:00:00:00:00:00
    Port 3:  100FD enabled stp: none vlan: 0 mac: 00:00:00:00:00:00
    Port 4:  100FD enabled stp: none vlan: 0 mac: 00:00:00:00:00:00
    Port 5:  100FD enabled stp: none vlan: 0 mac: 00:00:00:00:00:00
    VLANs: BCM5325/535x enabled mac_check mac_hash
      0: vlan0: 1 2 3 4 5t
      1: vlan1: 0 5t
      2: vlan2:
      3: vlan3:
      4: vlan4:
      5: vlan5:
      6: vlan6:
      7: vlan7:
      8: vlan8:
      9: vlan9:
    10: vlan10:
    11: vlan11:
    12: vlan12:
    13: vlan13:
    14: vlan14:
    15: vlan15:
    root@wrt54gs:/tmp/home/root# robocfg showmacs
    --------------------------------------
    VLAN  MAC                Type    Port
    --------------------------------------
    0001  00:12:17:xx:yy:zz  DYNAMIC  5
    0000  00:22:15:xx:yy:zz  DYNAMIC  1
    0000  00:15:af:xx:yy:zz  DYNAMIC  5
    0000  00:21:14:xx:yy:zz  DYNAMIC  3
    0000  00:13:10:xx:yy:zz  DYNAMIC  3
    0001  00:12:17:xx:yy:zz  STATIC  5
    0000  f4:6d:04:xx:yy:zz  DYNAMIC  4
    0000  00:12:17:xx:yy:zz  STATIC  5
    0000  00:0c:41:xx:yy:zz  DYNAMIC  3
    0001  00:30:b8:xx:yy:zz  DYNAMIC  0
    0000  00:23:69:xx:yy:zz  DYNAMIC  4
    
    But that command doesn't work on the RT-N16
    Code:
    root@RTN16:/tmp/home/root# robocfg showmacs
    --------------------------------------
    VLAN  MAC                Type    Port
    --------------------------------------
    *** Not ready for BCM53115!
    
     
  11. brueggma

    brueggma Networkin' Nut Member

  12. mstombs

    mstombs Network Guru Member

    I did use the precompiled, but have now compiled from that source without any changes and it does work on RT-N16

    Code:
     robocfg showmacs
    --------------------------------------
    VLAN  MAC                Type    Port
    --------------------------------------
    0001  90:e6:ba:xx.yy.zz  STATIC   8
    0001  00:15:af:xx.yy.zz  DYNAMIC  8
    0002  00:12:17:xx.yy.zz  DYNAMIC  0
    0001  00:22:15:xx.yy.zz  DYNAMIC  2
    0002  90:e6:ba:xx.yy.zz  DYNAMIC  8
    0002  90:e6:ba:xx.yy.zz  STATIC   8
    This version also knows the wan interface vlan2 is port 8

    Still quite tricky to use this need to look up device by MAC to port then speed
     
  13. RobF

    RobF Serious Server Member

    I too would find this feature very handy.
     
  14. mstombs

    mstombs Network Guru Member

    The robocfg binary and build script is still temporarily available on http://mymwi.comli.com/Tomtest/, if anyone wants to take this on - I feel it should be possible to do with a bash script and then added to tomato http c-code for efficient implementation
     
  15. occamsrazor

    occamsrazor Network Guru Member

    Here's a question... My setup has E3000 going via ethernet to a gigabit switch then on to a bunch of devices (some 1000mbps, some 100mbps). What speed would be reported for each device based on MAC?
     
  16. Diexgo

    Diexgo Serious Server Member

    The wireless link rate is already being indicated under "device list" menu, it would be also great to show the wired device port speed ;)
     
  17. Elfew

    Elfew Addicted to LI Member

    Any news about this?
     

Share This Page