I wrote a C++ application (running on Linux) that serves an RTP stream of about 400 kbps. To most destinations this works fine, but some destinations expericence packet loss. The problematic destinations seem to have a slower connection in common, but it should be plenty fast enough for the stream I'm sending.
Since these destinations are able to receive similar RTP streams for other applications without packet loss, my application might be at fault.
I already verified a few things: - in a tcpdump, I see all RTP packets going out on the sending machine - there is a UDP send buffer in place (I tried sizes between 64KB and 300KB) - the RTP packets mostly stay below 1400 bytes to avoid fragmentation
What can a sending application do to minimize the possibility of packet loss and what would be the best way to debug such a situation ?
How to grep lines having specific format
1:How to make shell output redirect (>) write while script is still running?
Notice "RcvbufErrors" and "SndbufErrors". Additional option is to monitor receive and send UDP buffers of the process:.
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
Here you need to look at Recv-Q and Send-Q column of the connection you're interested. If the values high and don't drop to zero, than the process must not handle the load.. You must use these commands on sending and on receiving machine.. Also you must use mtr, which combines traceroute and ping - it pings each hop in route. This may detect a slow hop in your route. Run it on oth machines to check connectivity to the second one..
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 *:*
- a: Reduce the overall data rate
- b: Reduce the 'peak' data rate, by sending small packets more often rather than one huge chunk every few seconds. ie, REDUCE your UDP send buffer - maybe even to just 1400 bytes.
- c: See if you must switch to a TCP variant of RTP.