UDP is a a lossy unreliable protocol which runs on top of the IP protocol. Unlike TCP (which handles all aspects of reliable communication) it is up to the application layer to handle dropped packets and other aspects of a "reliable" transport protocol. As such it is likely that any implementation which requires reliability to similar extent as that given by TCP will occur additional overhead.
You could set aside two ports port A
and port B
. Each port is unidirectional unless there is a dropped packet.
client 1 = port A = server 2
server 1 = port B = client 2
This keeps things simple. Server simply sends data and listens periodically but only receives messages if it's client drops a signal.
The client is the negation. It receives signals and only sends if it is missing a packet. An alternative implementation would be one in which the client/server pair could talk to each other, making the port truly unidirectional.
We get message reliability on both ports by using two packet index.
client index 1 = server index 2
server index 1 = client index 2
The index for each are single byte and incremented by the clients when they send a new message. Message delivery is assumed until reception of a special message which would be a UDP message for dropped packet. It would contane the signal for dropped message probably in it's most significant or least significant bit/byte depending on the endianness of the design as well as the index of the message. A queue also seems to be necessary but I have not worked the details of that out yet.