To be a better coder
分类: 架构设计与优化
2018-06-06 09:26:27
原文地址:dropped与overruns的区别 作者:powerful_boy
在使用ifconfig命令查看网卡信息时,对于收发包的统计里有dropped与overruns两个字段,看上去都是丢包,但它们有什么区别呢?
1
2
3
4
5
6
7
8
9
10
11
|
[root@localhost ~]# ifconfig eth3
eth3 Link encap:Ethernet HWaddr 00:0C:29:45:2E:8B
inet addr:192.168.122.1 Bcast:192.168.122.255 Mask:255.255.255.0
inet6 addr: fe80::20c:29ff:fe45:2e8b/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:129430 errors:0 dropped:0 overruns:0 frame:0
TX packets:2255 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:9978636 (9.5 MiB) TX bytes:320765 (313.2 KiB)
[root@localhost ~]#
|
网址:给的解释是:how many packets were dropped (probably because of low memory), and how many were lost because of an overrun. Receiver overruns usually occur when packets come in faster than the kernel can service the last interrupt.
具体解释如下:
dropped,表示这个数据包已经进入到网卡的接收缓存fifo队列,并且开始被系统中断处理准备进行数据包拷贝(从网卡缓存fifo队列拷贝到系统内存),但由于此时的系统原因(比如内存不够等)导致这个数据包被丢掉,即这个数据包被Linux系统丢掉。
overruns,表示这个数据包还没有被进入到网卡的接收缓存fifo队列就被丢掉,因此此时网卡的fifo是满的。为什么fifo会是满的?因为系统繁忙,来不及响应网卡中断,导致网卡里的数据包没有及时的拷贝到系统内存,fifo是满的就导致后面的数据包进不来,即这个数据包被网卡硬件丢掉。所以,个人觉得遇到overruns非0,需要检测cpu负载与cpu中断情况。
ifconfig读的是/proc/net/dev接口,在源文件net-tools-1.60\lib\interface.c的if_readlist_proc函数内可以看到;而/proc/net/dev接口导出的数据是通过函数dev_seq_show以及dev_seq_printf_stats来的,这两个函数都在\linux\2.6.38.8.x86\net\core\dev.c文件内,其中:
dropped对应的是stats->rx_dropped + stats->rx_missed_errors,
overruns对应的是stats->rx_fifo_errors。
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
|
/* The main device statistics structure */
struct rtnl_link_stats64 {
__u64 rx_packets; /* total packets received */
__u64 tx_packets; /* total packets transmitted */
__u64 rx_bytes; /* total bytes received */
__u64 tx_bytes; /* total bytes transmitted */
__u64 rx_errors; /* bad packets received */
__u64 tx_errors; /* packet transmit problems */
__u64 rx_dropped; /* no space in linux buffers */
__u64 tx_dropped; /* no space available in linux */
__u64 multicast; /* multicast packets received */
__u64 collisions;
/* detailed rx_errors: */
__u64 rx_length_errors;
__u64 rx_over_errors; /* receiver ring buff overflow */
__u64 rx_crc_errors; /* recved pkt with crc error */
__u64 rx_frame_errors; /* recv'd frame alignment error */
__u64 rx_fifo_errors; /* recv'r fifo overrun */
__u64 rx_missed_errors; /* receiver missed packet */
/* detailed tx_errors */
__u64 tx_aborted_errors;
__u64 tx_carrier_errors;
__u64 tx_fifo_errors;
__u64 tx_heartbeat_errors;
__u64 tx_window_errors;
/* for cslip etc */
__u64 rx_compressed;
__u64 tx_compressed;
};
|