Linux - Can I Duplicate, send, then and Deduplicate UDP packets?

3

I am transmitting UDP data across 2 Linux (Intel) based routers, and I am experiencing low levels of packet loss which are interfering with the application.

Is there a way (ideally, but not necessarily involving iptables) I can receive each UDP packet and send 2 copies of it, discarding the second one to arrive (if both packets arrive) ? I am aware that this will use double the bandwidth and I'm OK with that.

davidgo

Posted 2017-11-27T04:31:23.180

Reputation: 49 152

That's a lame solution. How do you handle the case when both datagrams get lost? Have you looked into Reliable UDP, RUDP, or Reliable Datagram Protocol, RDP? – sawdust – 2017-11-27T04:48:39.800

@sawdust - Thank you for these options, but I don't see how I can deploy them in my usage case. I was trying to avoid disclosing it, but I'm trying to bolt a hack on a VOIP network where I can't modify the clients or server - and am seeing a very low level of packet loss (significantly less then 1%). I am also not in a position to deal with the heavy jitter caused by retransmission of lost packets over the moderately long distance link. Also, the circuit will always be very overspecced capacity wise and is flat rate with 100% CIR, so its OK to waste bits. – davidgo – 2017-11-27T05:01:00.317

@sawdust - Also, the connection is used ONLY for VOIP, so no need to handle a mix of large and small packets, or bursty usage. – davidgo – 2017-11-27T05:05:41.883

I know little about it so this may be a stupid idea, but... What if you passed UDP packets via VPN that uses TCP? Wouldn't they effectively gain the reliability of TCP? – Kamil Maciorowski – 2017-11-27T05:16:29.727

@KamilMaciorowski - Thanks for the thought, but that would make things worse. It would subject the UDP frames to being resent, which will create a lot more jitter, which is no good for a VOIP connection. – davidgo – 2017-11-27T05:18:49.387

1I suspect that without ARQ, you cannot achieve reliability. But if you replicate datagrams and send as a pair, then you maximize the chance of losing both (by a noise burst of x duration). You might minimize the chance of losing both by separating the duplicate datagrams, i.e. delay sending the replicated datagram by time x. But you might be better off understanding why you're losing the datagrams in the first place. I.E maybe there's something that could be done to reduce the loss rate. – sawdust – 2017-11-27T05:24:50.747

@sawdust Thank you for this. I accept my solution has substantial limitations, but as the connections don't go anywhere near wireless links I'm guessing that the issue is to do with packets being dropped by upstream routers - over which I have no control - and I recon if I resend there is a high chance one of the 2 will get through. I've just discovered the "tee" module for iptables and am now trying to work out if I can use that to bodge up a useable hack ! – davidgo – 2017-11-27T05:31:33.637

1I agree with @sawdust, unless you are pushing a large amount of traffic through the connection you shouldn’t be dropping that many UDP packets. I find even standard internet connections transmit UDP from end to end almost flawlessly at any bandwidth suitable for VoIP. You can use iPerf to do some UDP quality and bandwidth testing. I think the answer it to find out why you are having the packet loss. Is it a router, QoS, noisy line, failing modem, etc. I bet you could even narrow it down to one side of the connection with the problem by testing to a third site. – Appleoddity – 2017-11-27T05:32:52.300

@Appleoddity the reason I'm having trouble is because terrestrial Internet in Australia sucks unbelievably badly. I am having packet loss because their wired infrastructure has been crippled by politics (Nationwide fibre rollout not available in CBD?) . I get a 5 times faster connection to my rural home then the 3 (telco) bonded pair in Melbourne CBD which costs 5 times as much - I'm not making it up - https://delimiter.com.au/2016/03/24/australia-huge-slip-global-broadband-rankings/

– davidgo – 2017-11-27T05:41:37.643

Answers

1

I know this is an older thread, but you might want to look into FEC.

Check our the "UDPspeeder" application written by wangyu. You can find it here on git: https://github.com/wangyu-/UDPspeeder

This application doesn't just duplicate the packet, but sends packets with information about being able to reconstruct the packet that is lost if needed.

There are lots of parameters to tune for your needs.

Tom

Posted 2017-11-27T04:31:23.180

Reputation: 26

1

If an application transmits UDP packets, it must be prepared that some (or even many) of these packets are dropped.

So either the application must deal with that (e.g. real-time audio or video data, where the missing information is just ignored and causes reduced quality, because you can't resend packages), or it must implement its own protocol to ensure retransmitting, or it must use another protocol that guarantuees eventual delivery.

Implementing an external "just send 2 copies" layer is not the solution. Yes, I know you don't want to hear that, but it's true.

So rewrite the application to use the proper protocol.

Alternatively, tunnel the packets over some other application that implements a proper protocol (tun/tap interface). If you insist on "just duplicate packets" to be a proper protocol (it's not difficult to write such an application, google for tun/tap example programs), try it, and see if it works (it won't).

dirkt

Posted 2017-11-27T04:31:23.180

Reputation: 11 627

this in no way answers the question. I could accept this as a comment, but not a solution. Further, as stated, I have no ability to modify the clients (sip phones) or server - indeed these are standard sip components (controlled by a third party). Would you care to delete your answer and make it a comment? – davidgo – 2017-11-27T08:15:22.763

If this is about SIP phones, please include it in the question. Don't add additional information in comments, edit the question. And the answer stays the same: If you experience heavy UDP packet loss, the application must deal with that. – dirkt – 2017-11-27T08:32:25.403

It's not about SIP phones. It's about duplicating UDP packets and deduplicating them. As a network administrator I want to improve performance of a link I can excert limited control over. – davidgo – 2017-11-27T08:41:26.140