Skip to content

Configuring Network Buffers for UDP

Proper buffer configuration prevents data loss when sending or receiving UDP streams.

Add the following settings to the /etc/sysctl.conf file.

For 1G Ethernet Adapters:

net.core.rmem_max = 16777216
net.core.wmem_max = 16777216
net.ipv4.udp_mem = 8388608 12582912 16777216
net.ipv4.tcp_rmem = 4096 87380 8388608
net.ipv4.tcp_wmem = 4096 65536 8388608
net.core.wmem_default = 16777216
net.core.rmem_default = 16777216
net.ipv4.tcp_tw_reuse = 1

For 10G Ethernet Adapters:

net.core.rmem_max = 67108864
net.core.wmem_max = 67108864
net.ipv4.udp_mem = 8388608 16777216 33554432
net.ipv4.tcp_rmem = 4096 87380 33554432
net.ipv4.tcp_wmem = 4096 65536 33554432
net.core.wmem_default = 33554432
net.core.rmem_default = 33554432
net.core.default_qdisc=fq
net.ipv4.tcp_congestion_control=bbr
net.ipv4.tcp_tw_reuse = 1

For 40G Ethernet Adapters:

net.core.rmem_max = 134217728
net.core.wmem_max = 134217728
net.ipv4.udp_mem = 8388608 33554432 67108864
net.ipv4.tcp_rmem = 4096 87380 67108864
net.ipv4.tcp_wmem = 4096 65536 67108864
net.core.wmem_default = 67108864
net.core.rmem_default = 67108864
net.core.default_qdisc=fq
net.ipv4.tcp_congestion_control=bbr
net.ipv4.tcp_tw_reuse = 1

To apply settings without restarting, run:

Terminal window
sysctl -p

Verify current buffer values:

Terminal window
sysctl \
net.core.rmem_default \
net.core.rmem_max \
net.core.wmem_default \
net.core.wmem_max \
net.ipv4.udp_mem \
net.ipv4.tcp_wmem

On high-load servers, configure the network card buffer to prevent packet loss.

Check current buffer settings:

Terminal window
ethtool -g eth1

Example output:

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

The optimal buffer size depends on your hardware. For high-frequency multi-core processors (over 3 GHz), maximum values often work best. For other systems, an average value is a good starting point.

To increase the buffer size:

Terminal window
ethtool -G eth1 rx 2048
  • System Tune - script to optimize Linux settings for streaming