[ns] Canceling Events vs. Handling Events
damian.philipp at gmx.net
Thu Jul 9 01:31:30 PDT 2009
I am developing some protocol extensions utilizing a keep-alive (recieve a packet every n seconds, if there was no packet for n+x seconds consider the sender dead).
When designing an implementation, I thought about the scheduler: I read somewhere in the manual, that inserting and deleting events may be costly. So now I am faced with two options:
- Have a single periodic timer for each node that when fired performs all pending actions.
- Have a separate timer for everything that needs to be timer-handled and have a receive-event of a keep-alive-packet cancel and reschedule the timer to the appropriate timeout.
Both are okay with respect to my protocol. I am expecting the keep-alive timeout to be reached almost never, so the timer handlers will hardly ever be run (second case) or have anything to do but calculate what actions actually are pending (first case).
Which would make my simulation run faster?
More information about the Ns-users