[Click] How to implement a Timeout?

David Fusté f2308030 at est.fib.upc.edu
Sat May 21 07:32:20 EDT 2005


Hi,
I have to implement a new specific forwarding table (FT). Each entry of 
this FT has to have a timeout. And when this timeout expires not only 
has to delete the entry but also has to run other functions. So, I need 
a mechanism that supports creation/destruction of timeouts in runtime 
(since FT entries are dynamics).
I have studied examples of timeouts implementations in existents 
elements but I haven't found any implementation that runs as I want:
I have found an implementation in arpquerier that uses a "Timer 
_expire_timer" and a "expire_hook" function that is rescheduled every N 
ms. But this implementation don't use a timeout for each entry of the 
table (in the case of arpquerier, _map). It only uses a general timeout, 
and when it expires, the function expire_hook cheks all the entries of 
the map and deletes the expired entries. So, timeout expiration is not 
independent between different timeouts.
I have found another implementation in etherswitch. In this case every 
entry has a timestamp, and only when a packet has to use the entry, it 
checks if the entry has expired or not. So, it is not a reactive system.
So, in any of the two implementation I can't satisfy my needs 
(independent dynamic timeouts for each entry).
Perhaps the only valid solution is the solution used in the arpquerier 
element: only one Timer, and one timestamp for each entry, but this 
system has the problem of that all timeouts of the table are not 
independent in terms of time expiration (and this problem gets worse 
when the number of milliseconds to schedule the Timer is more great).
I have thought in implementing a new class FT. Next, a new class 
FTEntry, and this last class will contain a Timer variable and a 
expire_timer function. So, each entry of the FT will have its own 
timeout and when a new ARPEntry is created, a new Timeout will be created.
But, when a timeout of an entry expires, it has to delete the entry, so, 
delete itself!

What is the best solution to implement this type of timeout? Any other idea?
Thank you very much!



More information about the click mailing list