Thread: Multiple POSIX Timers with handlers: how to?
Started 1 month, 1 week ago by premudriy
Hello everyone,
I'm working on a course project. I need to implement a "pseudo TCP" on top of UDP protocol. I've already implemented sequence and error handling concepts of TCP. Now I need to deal with timers and retransmission of packets, i.e. when acknowledgement for a sent packet doesn't arrive after X seconds, then retransmit that given packet.
My plan for timers is as ...
I'm not Linus Tornvalds, alias a guru, and so more superficially and with poor knowledge of the subject, I would create a list of objects, with the appropriate functions to manage it (insert, delete, read, write objects, timer, ecc.) and one/more global functions to manage the list.
Or if I would have much free time, I would hack some good code written by others.
LOL. Ok. I see what's wrong - the title says for gurus only. I didn't think it's going to be so touchy.
Ok. The title means: If you will answer this question, then you're officially a guru. Will this work?
But seriously, I didn't mean the title to be accepted as it is by some people. I just wanted a concrete help and not just "Look in the man pages!" answers.
This is probably all you should need
man timer_create
Creating a timer per packet is a profligate use of resources. OK for a "toy" example but totally unrealistic.
Let me expand on Lewis41 suggestion.
Create linked list method so you can keep the packet handles in ordrer of expiration time.
You need to be able to insert packets in expiration time order,
remove packet by ID when you ...
Oops - use man 3p setitimer since you most certainly want signal notification when the timeout occurs.
You'll need to think about how to partition the work between the signal handler and the main process, perhaps using a semaphore from sighandler to the main ...
Another thought - if your main process/thread is normally waiting on input/output, you can use the timeout parameter of the ...
I also suggest that there be a maximum number of outstanding packets....
You wouldn't want to be sending a 3GB file to a system that goes down... and end up with 80% of your memory
with nothing but timeouts and packets to send...
Oh, yes, I must not implement NAKs in this project, only ACKs. Acknowledgements are cumulative, i.e. if three packets were received, then I'll send ACK for the last (third) packet, which will mean that all tree packets got through. As for congestion: there's a receiver buffer and ACKs have a special field that tell how much more packets the sender can supply to receiver.
Quote: Originally Posted by jpollard Yup - the application specified is using UDP, which doesn't block. That calls for something external to invoke the stall. In this case, I'd suggest a NAK when the count reaches the limit, and drop the data. So much misinformation in such few lines .... /UDP certainly does block, tho' for a smaller set of reasons. This "toy" case is presumable implemented in userspace making...
And none of them implement reliable delivery over UDP without implementing some form of ACK/NAK and sending limits. Reliable delivery of UDP is not a standard... The problem with UDP is that the senders/receivers cannot assume reliable delivery. Reliable delivery can only be supported at the application layer. The original statement was '"pseudo TCP" on top of UDP protocol'. I know TCP works differently. It...
I'm not Linus Tornvalds, alias a guru, and so more superficially and with poor knowledge of the subject, I would create a list of objects, with the appropriate functions to manage it (insert, delete, read, write objects, timer, ecc.) and one/more global functions to manage the list. Or if I would have much free time, I would hack some good code written by others.
Thread profile page for "Multiple POSIX Timers with handlers: how to?" on http://www.fedoraforum.org.
This report page is a snippet summary view from a single thread "Multiple POSIX Timers with handlers: how to?", located on the Message Board at http://www.fedoraforum.org.
This thread profile page shows the thread statistics for: Total Authors, Total Thread Posts, and Thread Activity