Network speed debugging experience

If the priority of your test program and the priority of the network protocol stack are not equal, serious packet loss may occur, for the following reasons:

  1. The network driver submits the message data to the protocol stack after receiving the message data. If the priority of the protocol stack is higher than the test program at this time, the test program will always be blocked from receiving messages. At this time, the result is packet loss, and this The value of packet loss is very stable, no matter whether you start the test as soon as you turn it on, or after a period of time, it is almost unchanged. I prefer to call this "priority packet loss". (Changed from 12.01) In fact, this packet loss value may also be 0, because the above can at least guarantee that data is received in the multi-core case, but this is not necessarily the case in the single-core case. If the test program performs statistics every second Well, if the statistics are unified and re-tested, the test result will be zero. This high probability is that the test program is blocked when the test result is calculated, resulting in the inability to send the result correctly (say you, netperf), which will affect Final data.
  2. If the "priority packet loss" does not occur, that is, the protocol stack priority is equal to the test program, then if the packet is still lost at this time, you can try to judge whether there is a problem with the memory allocation. If the network driver has been unable to do anything after receiving the message Putting a message in the memory will also cause packet loss. However, there are trigger conditions for this kind of packet loss. First of all, it is necessary to ensure that it will only occur after a period of network testing. Generally, packet loss will not occur at the beginning. Second, the value (percentage) of this packet loss is relatively unstable. Third, this type of packet loss is generally a normal phenomenon when the network rate is low, and it is occasionally observed when the network rate is high, and it is a common phenomenon when the network rate is extremely high. I prefer to call this "memory allocation packet loss".
  3. If "memory allocation packet loss" occurs, it may mean that the memory opened by the protocol stack has been used up; or the memory marked to be released in the memory opened by the protocol stack has not been completely released, resulting in insufficient memory. "Dead" phenomenon occurs. At this time, if it is the driver layer, you need to modify the strategy of sending the message to the memory, that is, try to ensure that the memory is used as little as possible, and leave enough time for the protocol stack to release the memory. The specific solution is to transfer the message Temporarily store in a permanent and pre-allocated memory pool, and pass the message address to the protocol stack. When the protocol stack has completed the message, the temporarily stored messages in the memory pool are also released immediately, so that you can To ensure that the message is definitely in the memory pool, but to set the memory pool to be larger, this solution is called "zero copy".

Guess you like

Origin blog.csdn.net/weixin_44076906/article/details/108637775