linuxcommand-line-interfacebitrate

Can ethtool provide the current incoming bitrate on a NIC


Is there an option in linux's ethtool command that retrieves the current incoming bitrate or packets-per-second straight from the NIC?


Solution

  • Not per packets-per-second, but overall RX/TX. You could write a script around it:

    ethtool -S <interface>

    For example currently on my wifi nice:

    [user@host ~]$ ethtool -S wlo1
    NIC statistics:
         rx_packets: 992535
         rx_bytes: 1010899932
         rx_duplicates: 3206
         rx_fragments: 878057
         rx_dropped: 4367
         tx_packets: 363876
         tx_bytes: 49823636
         tx_filtered: 1
         tx_retry_failed: 6567
         tx_retries: 160017
         sta_state: 4
         txrate: 40500000
         rxrate: 54000000
         signal: 181
         channel: 0
         noise: 18446744073709551615
         ch_time: 18446744073709551615
         ch_time_busy: 18446744073709551615
         ch_time_ext_busy: 18446744073709551615
         ch_time_rx: 18446744073709551615
         ch_time_tx: 18446744073709551615
    

    The same information could be extracted from:

    • /sys/class/net//statistics/rx_packets: number of packets received
    • /sys/class/net//statistics/tx_packets: number of packets transmitted
    • /sys/class/net//statistics/rx_bytes: number of bytes received
    • /sys/class/net//statistics/tx_bytes: number of bytes transmitted
    • /sys/class/net//statistics/rx_dropped: number of packets dropped while received
    • /sys/class/net//statistics/tx_dropped: number of packets dropped while transmitted

    Also see superuser.com for a specific real time solution.