|
-
September 16th, 2009, 06:38 AM
#1
UDP and retry machanism a design question
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
-
September 16th, 2009, 06:49 AM
#2
Re: UDP and retry machanism a design question
i want to implement retry mechanism in my code with UDP portocol.
You know that there already is something like that ? It's called TCP. Any reason why you are re-inventing the wheel ?
-
September 16th, 2009, 07:09 AM
#3
Re: UDP and retry machanism a design question
Looks OK for me - I am also in the same stage now, and my design is similar.
More interesting is to see input from somebody who already implemented this, so my post is kind of thread subscription
-
September 16th, 2009, 07:17 AM
#4
Re: UDP and retry machanism a design question
hello,
Skizmo: yes it needs to be in UDP. we have come so far that we could not change it to TCP.
there is one more think that i want to discuss that
i have two list for this task. dataqueue_1 and dataQueue_2. when i get response i need to traverse the dataQueue_2 list to remove the received packet from it.
should i insert it to the threaded binary tree instead of DataQueue_2 for fast searching?
any inputs?
regards
d
-
September 16th, 2009, 07:39 AM
#5
Re: UDP and retry machanism a design question
Does other side replies in the same order as it receives packets? In this case I would start from a simple list. Though UDP may change packets order, in 99.9% cases the first packet in dataQueue_2 matches the received reply.
Also, watchdog thread is more effective with simple list structure.
-
September 16th, 2009, 08:11 AM
#6
Re: UDP and retry machanism a design question
hello alex,
yes it is in the same order!!
what is watchdog thread?
regards
d
-
September 16th, 2009, 09:27 AM
#7
Re: UDP and retry machanism a design question
This is your thread3. In real time programming watchdog is some thread or timer which checks periodically state of device, communication or anything else.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|