How to debug packet loss?

I wrote a C ++ application (works on Linux) that serves an RTP stream of around 400 kbps. For most destinations this works fine, but packet loss occurs in some places. It seems that the problematic destinations have a slower connection, but for the stream I'm sending it should be fast enough.

Since these destinations can receive the same RTP streams for other applications without packet loss, my application may be malfunctioning.

I already checked a few things: - in tcpdump, I see that all RTP packets that go to the sending machine - there is a UDP send buffer in place (I tried sizes from 64 KB to 300 KB) - RTP packets basically stay below 1400 bytes so that avoid fragmentation

What can the sending application do to minimize the chance of packet loss and what would be the best way to debug this situation?

+5
source share
5 answers

Do not send packets in large bursts.

Packet loss is usually caused by slow routers with a limited packet buffer size. A slow router can handle 1 Mbit / s just fine, if it has time to send, say, 10 packets before receiving another 10, but if the sender side at a speed of 100 Mbit / s sends it a large piece of 50 packets, it there is no choice but to refuse 40 of them.

, , . , , , 5 .

+9

netstat .

- netstat -su ( UDP):

dima@linux-z8mw:/media> netstat -su                                                      
IcmpMsg:                                                                                 
    InType3: 679
    InType4: 20
    InType11: 548
    OutType3: 100
Udp:
    12945 packets received
    88 packets to unknown port received.
    0 packet receive errors
    13139 packets sent
    RcvbufErrors: 0
    SndbufErrors: 0
UdpLite:
    InDatagrams: 0
    NoPorts: 0
    InErrors: 0
    OutDatagrams: 0
    RcvbufErrors: 0
    SndbufErrors: 0
IpExt:
    InNoRoutes: 0
    InTruncatedPkts: 0
    InMcastPkts: 3877
    OutMcastPkts: 3881
    InBcastPkts: 0
    OutBcastPkts: 0
    InOctets: 7172779304
    OutOctets: 785498393
    InMcastOctets: 525749
    OutMcastOctets: 525909
    InBcastOctets: 0
    OutBcastOctets: 0

"RcvbufErrors" "SndbufErrors"

- UDP :

dima@linux-z8mw:/media> netstat -ua
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address           Foreign Address         State
udp        0      0 *:bootpc                *:*
udp        0      0 *:40134                 *:*
udp        0      0 *:737                   *:*
udp        0      0 *:mdns                  *:*

Recv-Q Send-Q . , .

.

mtr, traceroute ping - . . , .

+5

RTP UDP, , . , .

:

  • a:
  • b: "", . .. UDP - , 1400 .
  • c: , TCP RTP.

, WireShark - . , - .

+4
source

You should try to reduce the speed of sending packets. A slow connection can mean all kinds of things, and trying to send packets (small or large) at high speed will not help.

+1
source

This may not be the answer you want, but if I had problems with packet loss, I would try to switch my application to use TCP and most of all was worried about the loss of packets taken from my mind.

-2
source

All Articles