| 1 |
#include "protoSimAgent.h" |
| 2 |
|
| 3 |
#include "ns3/application.h" |
| 4 |
|
| 5 |
|
| 6 |
/** |
| 7 |
* @class Ns3ProtoSimAgent |
| 8 |
* |
| 9 |
* @brief Ns3 ProtoSimAgent implementation. |
| 10 |
*/ |
| 11 |
class Ns3ProtoSimAgent : public ProtoSimAgent : public Application |
| 12 |
{ |
| 13 |
public: |
| 14 |
virtual ~Ns3ProtoSimAgent(); |
| 15 |
|
| 16 |
virtual bool OnStartup(int argc, const char*const* argv) = 0; |
| 17 |
virtual bool ProcessCommands(int argc, const char*const* argv) = 0; |
| 18 |
virtual void OnShutdown() = 0; |
| 19 |
|
| 20 |
// Some helper methods |
| 21 |
void ActivateTimer(ProtoTimer& theTimer) |
| 22 |
{ProtoSimAgent::ActivateTimer(theTimer);} |
| 23 |
|
| 24 |
void DeactivateTimer(ProtoTimer& theTimer) |
| 25 |
{ProtoSimAgent::DeactivateTimer(theTimer);} |
| 26 |
|
| 27 |
ProtoSocket::Notifier& GetSocketNotifier() |
| 28 |
{return ProtoSimAgent::GetSocketNotifier();} |
| 29 |
|
| 30 |
ProtoTimerMgr& GetTimerMgr() |
| 31 |
{return ProtoSimAgent::GetTimerMgr();} |
| 32 |
|
| 33 |
// Override ProtoTimerMgr::GetSystemTime() |
| 34 |
virtual void GetSystemTime(struct timeval& currentTime) |
| 35 |
{ |
| 36 |
double now = ns3::Simulator::Now().Seconds(); |
| 37 |
currentTime.tv_sec = (unsigned long)(now); |
| 38 |
currentTime.tv_usec = (unsigned long)((now - currentTime.tv_sec) * 1.0e06); |
| 39 |
} |
| 40 |
|
| 41 |
private: |
| 42 |
|
| 43 |
}; // end class Ns3ProtoSimAgent |