On 7/7/06, Shafiq Hashmi <[EMAIL PROTECTED]> wrote:
>
> Hello all,
>
> I want to implement a timer function for a packet to be resent if that same 
> timer expires for not getting the respective ACK.
>
> Can anybody help me to get a simple example so that I can use that function. 
> Whatever I got on the net or on this forum is difficult to comprehend. I 
> would really appreciate for the help.
>
> Thanx
> Shafiq
>
>

Hello Shafiq,

An example from UM-OLSR :-) which I renamed to RHARP protocol *_*

In .h file:
// ==========
#include <timer-handler.h>

/// Timer for sending an enqued message.
class RHARP_MsgTimer : public TimerHandler {
public:
        RHARP_MsgTimer(RHARP* agent) : TimerHandler() {
                agent_  = agent;
        }
protected:
        RHARP*  agent_;                 ///< RHARP agent which created the 
timer.
        virtual void expire(Event* e);
};
// ==========

In .cc file:
// ==========
void
RHARP_MsgTimer::expire(Event* e) {
        agent_->send_pkt(); // do anything you want here, check the reception
of ACK for instance
        delete this;
}

// example to run this timer:

RHARP_MsgTimer* timer = new RHARP_MsgTimer(this);
timer->resched(delay);
// ==========


in this example, agent_->send_pkt(); will be called after a delay "delay"

Good luck ;-)

-- 
Hai-Nam NGUYEN
Elève 3A SLR, ENST Bretagne
2 rue de la Châtaigneraie
35576 Cesson Sévigné

Site web: http://www.jcisio.com

Reply via email to