NIC Level Packet Drops
Packet drops hinders the performance of networks.
We can use ethtool to check NIC level packet drops in Linux. Use the -S option to get the statistics.
Sample Usage:
ethtool -S em1 | egrep "(nodesc)|(bad)" tx_bad_bytes: 0 tx_bad: 0 rx_bad_bytes: 65824 rx_bad: 0 rx_bad_lt64: 0 rx_bad_64_to_15xx: 0 rx_bad_15xx_to_jumbo: 0 rx_bad_gtjumbo: 0 rx_nodesc_drop_cnt: 1039The field rx_nodesc_drop_cnt increasing over time is an indication that packets are being dropped by the adapter.
You can also view the packet drops using ifconfig
ifconfig em1 | grep drop RX packets:4154237628 errors:4 dropped:1429 overruns:0 frame:4 TX packets:4148105177 errors:0 dropped:0 overruns:0 carrier:0
Fixing NIC Level Packet Drops
One common issue with Packet drops is that the NIC ring buffer is not enough for buffering. Solution is to increase the buffer size.
To view the existing buffer size:
ethtool -g em1 Ring parameters for em1: Pre-set maximums: RX: 1020 RX Mini: 0 RX Jumbo: 4080 TX: 255 Current hardware settings: RX: 255 RX Mini: 0 RX Jumbo: 0 TX: 255
Pre-set maximums are the maximum values for the buffers. As in the above example, we can increase the receive buffer(RX) to 1020. To increase the buffer size, use the following command
ethtool -G em1 rx 1020
Socket Level Packet Drops
Packets can also be dropped with UDP due to datagrams arriving when the socket buffer is full i.e. traffic is arriving faster than the application can consume. Solution is to increase the receive buffer
Increasing socket receive buffer size
uint64_t size=10*1024*1024;//10 MB setsockopt(m_socketFd, SOL_SOCKET, SO_RCVBUF, &size, sizeof(size));
SO_RCVBUF sets or gets the maximum socket receive buffer in bytes. The kernel doubles this value to allow space for bookkeeping overhead when it is set using setsockopt.
The maximum allowed value for this option is set by /proc/sys/net/core/rmem_max. You might have to change it to allow higher values in the SO_RCVBUF.
Maximum value can also be set using sysctl -w net.core.rmem_max=262144
No comments :
Post a Comment