Solution to severe packet loss in Linux UDP

Source: Internet
Author: User

The performance of the test system in Linux has found that the packet loss rate is extremely serious. It sends 210000 pieces of data, and the packet loss rate reaches 110000. The packet loss rate exceeds 50%. In the same case, only a few pieces of data are lost during windows testing. The situation is grim and must be solved. It may be because the protocol stack buffer is too low. So let's first look at the default situation:

Sysctl-A | grep net. Core

Found

Net. Core. rmem_max = 131071

Net. Core. rmem_default = 112640

Change the value to 10 MB, and then reboot (restart a service)

Then check the NIC package status:

Netstat-su

The result is as follows:

UDP:

97690 packets received

112310 packets to unknown port already ed.

0 packet receive errors

20 packets sent

If data is lost on the NIC, the firewall may be the cause of the loss. Therefore, run the following command:

Iptables-l

The result is as follows:

Chain input (Policy accept)

Target prot opt source destination

Chain forward (Policy accept)

Target prot opt source destination

Chain output (Policy accept)

Target prot opt source destination

If iptables is enabled, the firewall is stopped:

Service iptables stop

This command takes effect immediately. The command to enable the firewall is as follows:

Service iptables start

If you want to completely disable the firewall, it will take effect after restart

Enable: chkconfig iptables on

Close: chkconfig iptables off

When the firewall is enabled, make the following settings to enable the relevant ports,

Modify the/etc/sysconfig/iptables file and add the following content:

-A RH-Firewall-1-INPUT-M state -- state new-m tcp-p tcp -- dport 80-J accept

-A RH-Firewall-1-INPUT-M state -- state new-m tcp-p tcp -- dport 22-J accept

Test again without losing a piece of data.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.