A Discrete-Event Network Simulator
API
ns3::Watchdog Class Reference

A very simple watchdog operating in virtual time. More...

#include "watchdog.h"

+ Collaboration diagram for ns3::Watchdog:

Public Member Functions

 Watchdog ()
 Constructor. More...
 
 ~Watchdog ()
 Destructor. More...
 
void Ping (Time delay)
 Delay the timer. More...
 
template<typename FN >
void SetFunction (FN fn)
 Set the function to execute when the timer expires. More...
 
template<typename MEM_PTR , typename OBJ_PTR >
void SetFunction (MEM_PTR memPtr, OBJ_PTR objPtr)
 Set the function to execute when the timer expires. More...
 
template<typename T1 >
void SetArguments (T1 a1)
 Set the arguments to be used when invoking the expire function. More...
 
template<typename T1 , typename T2 >
void SetArguments (T1 a1, T2 a2)
 
template<typename T1 , typename T2 , typename T3 >
void SetArguments (T1 a1, T2 a2, T3 a3)
 
template<typename T1 , typename T2 , typename T3 , typename T4 >
void SetArguments (T1 a1, T2 a2, T3 a3, T4 a4)
 
template<typename T1 , typename T2 , typename T3 , typename T4 , typename T5 >
void SetArguments (T1 a1, T2 a2, T3 a3, T4 a4, T5 a5)
 
template<typename T1 , typename T2 , typename T3 , typename T4 , typename T5 , typename T6 >
void SetArguments (T1 a1, T2 a2, T3 a3, T4 a4, T5 a5, T6 a6)
 

Private Member Functions

void Expire (void)
 Internal callback invoked when the timer expires. More...
 

Private Attributes

Time m_end
 The absolute time when the timer will expire. More...
 
EventId m_event
 The future event scheduled to expire the timer. More...
 
TimerImplm_impl
 The timer implementation, which contains the bound callback function and arguments. More...
 

Detailed Description

A very simple watchdog operating in virtual time.

The watchdog timer is started by calling Ping with a delay value. Once started the timer cannot be suspended, cancelled or shortened. It can be lengthened (delayed) by calling Ping again: if the new expire time (current simulation time plus the new delay) is greater than the old expire time the timer will be extended to the new expire time.

Typical usage would be to periodically Ping the Watchdog, extending it's execution time. If the owning process fails to Ping before the Watchdog expires, the registered function will be invoked.

If you don't ping the watchdog sufficiently often, it triggers its listening function.

See also
Timer for a more sophisticated general purpose Virtual Time Timer and Watchdog.

Definition at line 56 of file watchdog.h.

Constructor & Destructor Documentation

ns3::Watchdog::Watchdog ( )

Constructor.

Definition at line 34 of file watchdog.cc.

References NS_LOG_FUNCTION_NOARGS.

ns3::Watchdog::~Watchdog ( )

Destructor.

Definition at line 42 of file watchdog.cc.

References m_impl, and NS_LOG_FUNCTION.

Member Function Documentation

void ns3::Watchdog::Expire ( void  )
private

Internal callback invoked when the timer expires.

Definition at line 62 of file watchdog.cc.

References ns3::TimerImpl::Invoke(), m_end, m_event, m_impl, ns3::Now(), ns3::Simulator::Now(), NS_LOG_FUNCTION, and ns3::Simulator::Schedule().

Referenced by Ping().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void ns3::Watchdog::Ping ( Time  delay)

Delay the timer.

Parameters
[in]delayThe watchdog delay

After a call to this method, the watchdog will not be triggered until the delay specified has been expired. This operation is sometimes named "re-arming" a watchdog in some operating systems.

Definition at line 49 of file watchdog.cc.

References Expire(), ns3::EventId::IsRunning(), m_end, m_event, max, ns3::Now(), ns3::Simulator::Now(), NS_LOG_FUNCTION, and ns3::Simulator::Schedule().

Referenced by ns3::tests::WatchdogTestCase::DoRun().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

template<typename T1 >
void ns3::Watchdog::SetArguments ( T1  a1)

Set the arguments to be used when invoking the expire function.

Template Parameters
T1[deduced] Type of the first argument.
Parameters
[in]a1The first argument

Definition at line 214 of file watchdog.h.

References m_impl, NS_FATAL_ERROR, and ns3::TimerImpl::SetArgs().

Referenced by ns3::tests::WatchdogTestCase::DoRun().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

template<typename T1 , typename T2 >
void ns3::Watchdog::SetArguments ( T1  a1,
T2  a2 
)
Template Parameters
T1[deduced] Type of the first argument.
T2[deduced] Type of the second argument.
Parameters
[in]a1the first argument
[in]a2the second argument

Definition at line 225 of file watchdog.h.

References m_impl, NS_FATAL_ERROR, and ns3::TimerImpl::SetArgs().

+ Here is the call graph for this function:

template<typename T1 , typename T2 , typename T3 >
void ns3::Watchdog::SetArguments ( T1  a1,
T2  a2,
T3  a3 
)
Template Parameters
T1[deduced] Type of the first argument.
T2[deduced] Type of the second argument.
T3[deduced] Type of the third argument.
Parameters
[in]a1the first argument
[in]a2the second argument
[in]a3the third argument

Definition at line 237 of file watchdog.h.

References m_impl, NS_FATAL_ERROR, and ns3::TimerImpl::SetArgs().

+ Here is the call graph for this function:

template<typename T1 , typename T2 , typename T3 , typename T4 >
void ns3::Watchdog::SetArguments ( T1  a1,
T2  a2,
T3  a3,
T4  a4 
)
Template Parameters
T1[deduced] Type of the first argument.
T2[deduced] Type of the second argument.
T3[deduced] Type of the third argument.
T4[deduced] Type of the fourth argument.
Parameters
[in]a1the first argument
[in]a2the second argument
[in]a3the third argument
[in]a4the fourth argument

Definition at line 249 of file watchdog.h.

References m_impl, NS_FATAL_ERROR, and ns3::TimerImpl::SetArgs().

+ Here is the call graph for this function:

template<typename T1 , typename T2 , typename T3 , typename T4 , typename T5 >
void ns3::Watchdog::SetArguments ( T1  a1,
T2  a2,
T3  a3,
T4  a4,
T5  a5 
)
Template Parameters
T1[deduced] Type of the first argument.
T2[deduced] Type of the second argument.
T3[deduced] Type of the third argument.
T4[deduced] Type of the fourth argument.
T5[deduced] Type of the fifth argument.
Parameters
[in]a1the first argument
[in]a2the second argument
[in]a3the third argument
[in]a4the fourth argument
[in]a5the fifth argument

Definition at line 261 of file watchdog.h.

References m_impl, NS_FATAL_ERROR, and ns3::TimerImpl::SetArgs().

+ Here is the call graph for this function:

template<typename T1 , typename T2 , typename T3 , typename T4 , typename T5 , typename T6 >
void ns3::Watchdog::SetArguments ( T1  a1,
T2  a2,
T3  a3,
T4  a4,
T5  a5,
T6  a6 
)
Template Parameters
T1[deduced] Type of the first argument.
T2[deduced] Type of the second argument.
T3[deduced] Type of the third argument.
T4[deduced] Type of the fourth argument.
T5[deduced] Type of the fifth argument.
T6[deduced] Type of the sixth argument.
Parameters
[in]a1the first argument
[in]a2the second argument
[in]a3the third argument
[in]a4the fourth argument
[in]a5the fifth argument
[in]a6the sixth argument

Definition at line 273 of file watchdog.h.

References m_impl, NS_FATAL_ERROR, and ns3::TimerImpl::SetArgs().

+ Here is the call graph for this function:

template<typename FN >
void ns3::Watchdog::SetFunction ( FN  fn)

Set the function to execute when the timer expires.

Parameters
[in]fnThe function

Store this function in this Timer for later use by Timer::Schedule.

Definition at line 199 of file watchdog.h.

References m_impl, and ns3::MakeTimerImpl().

Referenced by ns3::tests::WatchdogTestCase::DoRun().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

template<typename MEM_PTR , typename OBJ_PTR >
void ns3::Watchdog::SetFunction ( MEM_PTR  memPtr,
OBJ_PTR  objPtr 
)

Set the function to execute when the timer expires.

Template Parameters
MEM_PTR[deduced] Class method function type.
OBJ_PTR[deduced] Class type containing the function.
Parameters
[in]memPtrThe member function pointer
[in]objPtrThe pointer to object

Store this function and object in this Timer for later use by Timer::Schedule.

Definition at line 206 of file watchdog.h.

References m_impl, and ns3::MakeTimerImpl().

+ Here is the call graph for this function:

Member Data Documentation

Time ns3::Watchdog::m_end
private

The absolute time when the timer will expire.

Definition at line 182 of file watchdog.h.

Referenced by Expire(), and Ping().

EventId ns3::Watchdog::m_event
private

The future event scheduled to expire the timer.

Definition at line 180 of file watchdog.h.

Referenced by Expire(), and Ping().

TimerImpl* ns3::Watchdog::m_impl
private

The timer implementation, which contains the bound callback function and arguments.

Definition at line 178 of file watchdog.h.

Referenced by Expire(), SetArguments(), SetFunction(), and ~Watchdog().


The documentation for this class was generated from the following files: