[ns] Help on Timer
Udit Kumar
udit.vlsi at gmail.com
Sat Jun 13 21:18:46 PDT 2009
Hi Friends,
(1) I want to create my own Timer, I tried it as below code (This is part of
my main code) and it is compiling but it is not giving me any result, Please
tell me what mistake I am doing ...
(2) Supppose I want to do following Please help on this ..
<Task one >
<specified delay >
<task two >
Here my intention is to delay <task two> with <specified delay> from <Task
one> , Please suggest me how this can be done.
Thanks & Regards,
Udit Kumar
IIT delhi
class udit_timer : public TimerHandler {
public:
udit_timer (IP_Agent * agent) : TimerHandler()
{ agent_ = agent; }
protected:
virtual void expire(Event *e); //! function call when the timer reach
zero.
IP_Agent *agent_;
};
//! define the main class of the IP agent.
class IP_Agent : public Agent {
friend class udit_timer;
protected:
udit_timer udit_func_ ;
bool udit_timer_call(void);
}
void udit_timer::expire(Event *e) { agent_->udit_timer_call(); }
bool IP_Agent::udit_timer_call(void)
{
fprintf(stdout, "%.6e Udit timer 1\n", CURRENT_TIME );
udit_func_.resched( 2 );
fprintf(stdout, "%.6e Udit timer 2\n", CURRENT_TIME );
return true;
}
More information about the Ns-users
mailing list