i want to implement retry mechanism in my code with UDP portocol.
when i send a UDP packet i have a field called requestID to it.
i need to send the same packet again if i did not get response for a perticular ReqeustID.
i need your thoughts to implement it efficiently.

here is want i think

i will keep 3 threads.

thread 1. would remove a packet from DataQueue_1. and send it. it will also append it
to another DataQueue_2 (AddTail()).
thread 2 will receive the packet and removed the packet from the DataQueue_2 (Search from Head to get first packet ).

thread3 will be in wait for timeout period say (5 sec) after 5 second it will go through the
dataQueue_2 and check if (senttime+5 < currentTime) && retries<MAX_RETRIES if so then it will insert this packet to
DataQueue_1 again.

what do you guys think

regards
d