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).
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