网络丢包使用ethtool分析

ethtool -g eth0

ethtool eth0: 查询ethx网口基本设置。

-g: 显示网卡的接收/发送环形参数(ringbuffer)。

Ring parameters for eth0:
Pre-set maximums:
RX: 4096
RX Mini: 0
RX Jumbo: 0
TX: 4096
Current hardware settings:
RX: 512
RX Mini: 0
RX Jumbo: 0
TX: 512

Pre-set maximums指的是RingBuffer的最大值,Current hardware settings指的是当前的设置。如果内核处理得不及时导致RingBuffer满了,那后面新来的数据包就会被丢弃,通过ethtool或ifconfig可以查看是否有RingBuffer溢出。

ethtool -S eth0

-S:显示NIC- and driver-specific 的统计参数(驱动层),如网卡接收/发送的字节数、接收/发送的广播包个数等。

rx_fifo_errors:0

tx_fifo_errors:0

rx_fifo_errors如果不为0,表示有包因为RingBuffer装不下而丢弃了,可以通过调整RingBuffer大小解决。

ethtool -G eth0 rx 4096 tx 4096

-G: 显示网卡的接收/发送环形参数。

这样RingBuffer就调大了,可以解决偶发瞬时的丢包。但是排队的包过多也会增加网络包的延时。所以还有个办法就是加快内核处理网络包的速度,而不是让网络包在RingBuffer中排队。

posted on 2023-02-19 18:03  zhengbiyu  阅读(924)  评论(0)    收藏  举报