Is there a way to get current txqueue utilization on e.g. eth0 or tun device?

I have detected drops on my tun0 interface.

They seem to have been caused by low txqueuelen setting. Now as I increased the txqueuelen value for the network device and there are no more drops yet - I am wondering is there any way to get actual current usage of network device buffer?


Solution 1:

For TCP Buffer,you can use

       netstat -nt 

and look for second and third column for receive and send buffer(Recv-Q,Send-Q)

For UDP

       netstat -nua

Same way you can look inside /proc/net/{tcp,udp} and look for tx_queue & rx_queue

Same way you can use

          ethtool -S <nic card name>  (driver need to support)


                NIC statistics:
                rx_packets: 445
                tx_packets: 48
                rx_bytes: 56015
                tx_bytes: 5938
                rx_broadcast: 336
                tx_broadcast: 2
                rx_multicast: 89
                tx_multicast: 28
                rx_errors: 0
                tx_errors: 0
                tx_dropped: 0

Also just want to add there is one network parameter "tcp_moderate_rcvbuf" which is enabled by default,performs receive buffer auto-tuning.As per kernel-doc

     If set, TCP performs receive buffer auto-tuning, attempting to
     automatically size the buffer (no greater than tcp_rmem[2]) to
     match the size required by the path for full throughput