How to check ethernet speed / connection type in CrOS

808 views
Skip to first unread message

Simon Que

unread,
Jan 19, 2018, 7:54:56 PM1/19/18
to chromium-os-dev
Hi,

I'm looking for a way to detect changes in ethernet speed settings on Chrome OS, such as simplex vs duplex. I'm not familiar with ethernet connections though, so I can't tell you exactly what info I'm looking for.

This could be something in sysfs or a system command, or something in /var/log/net.log -- anything straightforward is fine.

Simon

Lei Zhang

unread,
Jan 19, 2018, 8:02:08 PM1/19/18
to Simon Que, chromium-os-dev
Are you looking for an interrupt mechanism or a polling mechanism?

On Linux, I usually use ethtool to check my ethernet cards' speed,
duplex type, and link status. With a test image, /usr/sbin/ethtool is
available. Not sure if that's shipped in production. You can also try
looking at the ethtool implementation if you don't want to rely on it,
and want to use the underlying mechanism.
> --
> --
> Chromium OS Developers mailing list: chromiu...@chromium.org
> View archives, change email options, or unsubscribe:
> http://groups.google.com/a/chromium.org/group/chromium-os-dev?hl=en
>

Simon Que

unread,
Jan 19, 2018, 8:25:12 PM1/19/18
to Lei Zhang, chromium-os-dev
Polling is preferred.

How does ethtool get included in the CrOS build? I see the ebuild package included in a few board-specific overlays, but not in any generic CrOS system overlay.

Lei Zhang

unread,
Jan 19, 2018, 8:44:10 PM1/19/18
to Simon Que, chromium-os-dev
No idea. I'm not a real ChromeOS developer. Underneath, ethtool uses
the SIOCETHTOOL ioctl.

Kevin Cernekee

unread,
Jan 19, 2018, 9:00:29 PM1/19/18
to Simon Que, Lei Zhang, chromium-os-dev
On Fri, Jan 19, 2018 at 5:24 PM, Simon Que <sq...@chromium.org> wrote:
Polling is preferred.

How does ethtool get included in the CrOS build? I see the ebuild package included in a few board-specific overlays, but not in any generic CrOS system overlay.

Looks like it is pulled in as a dependency of app-laptop/laptop-mode-tools, which gets built if USE=power_management (so pretty much always).

You might also be able to convince the kernel to log speed and duplex to /var/log/messages.  If you're already running a custom build on the board, it may be easier just to add a debug print in the kernel than to mess with polling on ethtool.  For instance, smsc95xx logs these events if it is built with -DDEBUG:

        netif_dbg(dev, link, dev->net,
                  "speed: %u duplex: %d lcladv: %04x rmtadv: %04x\n",
                  ethtool_cmd_speed(&ecmd), ecmd.duplex, lcladv, rmtadv);

Also try: `cat /sys/class/net/eth0/{speed,duplex,carrier}`

Daniel Erat

unread,
Jan 20, 2018, 2:27:32 AM1/20/18
to Simon Que, Lei Zhang, chromium-os-dev, Kevin Cernekee
There's an ongoing effort to delete laptop-mode-tools (https://crbug.com/214886), so if you end up using ethtool, please make sure that it's also pulled in by a package that's related to the work that you're doing.

--

Keith I Myers

unread,
Jan 22, 2018, 11:09:21 AM1/22/18
to Daniel Erat, Simon Que, Lei Zhang, chromium-os-dev, Kevin Cernekee
Why not use the Network Information API that was added in Chrome 62 - https://www.chromestatus.com/feature/5108786398232576

The example seems pretty easy to implement and adapt 

navigator.connection.addEventListener('change', logNetworkInfo);

function logNetworkInfo() {
// Network type that browser uses
log(' type: ' + navigator.connection.type);

// Effective bandwidth estimate
log(' downlink: ' + navigator.connection.downlink + 'Mb/s');

// Effective round-trip time estimate
log(' rtt: ' + navigator.connection.rtt + 'ms');

// Upper bound on the downlink speed of the first network hop
log(' downlinkMax: ' + navigator.connection.downlinkMax + 'Mb/s');

// Effective connection type determined using a combination of recently
// observed rtt and downlink values: ' +
log('effectiveType: ' + navigator.connection.effectiveType);

// True if the user has requested a reduced data usage mode from the user
// agent.
log(' saveData: ' + navigator.connection.saveData);
}

logNetworkInfo();

---
You received this message because you are subscribed to the Google Groups "Chromium OS dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to chromium-os-dev+unsubscribe@chromium.org.



--

Mike Frysinger

unread,
Jan 22, 2018, 11:43:41 AM1/22/18
to Keith I Myers, Daniel Erat, Simon Que, Lei Zhang, chromium-os-dev, Kevin Cernekee
Simon is most likely writing code on the OS side, not the browser/JS side
-mike

Simon Que

unread,
Jan 22, 2018, 11:46:01 AM1/22/18
to Mike Frysinger, Keith I Myers, Daniel Erat, Lei Zhang, chromium-os-dev, Kevin Cernekee
Actually this data is going to be consumed by a JS app. Keith's info is exactly what I'm looking for.

I didn't realize that this was already available through a Chrome API, so I asked about the OS level just to be safe.

Keith I Myers

unread,
Jan 22, 2018, 11:52:22 AM1/22/18
to Simon Que, Mike Frysinger, Daniel Erat, Lei Zhang, chromium-os-dev, Kevin Cernekee
Glad that could have been of help - if it is needed at the OS layer, you could also look at the source to see how it is implemented in the OS as well 

ggg

unread,
Jan 23, 2018, 2:23:45 PM1/23/18
to Chromium OS dev, sq...@chromium.org


On Friday, January 19, 2018 at 5:44:10 PM UTC-8, Lei Zhang wrote:
Underneath, ethtool uses the SIOCETHTOOL ioctl.

Kernel networking drivers most commonly used by chromeos (and I believe android) devices do not support ethtool. I'm thinking specifically of 80211 wifi and cd_ether (which is used to present an "ethernet" interface for USB modems LTE/3G/etc and some USB ethernet dongles (e.g. Linksys)).  "ethtool" will only report if link is up or down in those cases.

SIOCETHTOOL is generally well supported by PCI and USB ("vendor specific") *wired* ethernet devices (802.3: GigE, Fast Ethernet, etc).

The Chrome API for BW estimation sounds more useful in general.

cheers.
grant
Reply all
Reply to author
Forward
This conversation is locked
You cannot reply and perform actions on locked conversations.
0 new messages