Make applications generate traffic within their associated context/node

This commit is contained in:
Guillaume Seguin
2009-11-14 17:47:05 +01:00
parent c420843c3d
commit a23934a4b7
30 changed files with 225 additions and 126 deletions

View File

@@ -186,8 +186,8 @@ main (int argc, char *argv[])
Ptr<V4Ping> app = CreateObject<V4Ping> ();
app->SetAttribute ("Remote", Ipv4AddressValue (remoteIp));
node->AddApplication (app);
app->Start (Seconds (1.0));
app->Stop (Seconds (5.0));
app->SetStartTime (Seconds (1.0));
app->SetStopTime (Seconds (5.0));
//
// Give the application a name. This makes life much easier when constructing

View File

@@ -183,8 +183,8 @@ int main (int argc, char** argv)
radvd->AddConfiguration (routerInterface2);
r->AddApplication (radvd);
radvd->Start (Seconds (1.0));
radvd->Stop (Seconds (2.0));
radvd->SetStartTime (Seconds (1.0));
radvd->SetStopTime (Seconds (2.0));
/* Create a Ping6 application to send ICMPv6 echo request from n0 to n1 via R */
uint32_t packetSize = 1024;

View File

@@ -123,8 +123,8 @@ int main (int argc, char** argv)
radvd->AddConfiguration (routerInterface2);
r->AddApplication (radvd);
radvd->Start (Seconds (1.0));
radvd->Stop (Seconds (10.0));
radvd->SetStartTime (Seconds (1.0));
radvd->SetStopTime (Seconds (10.0));
/* Create a Ping6 application to send ICMPv6 echo request from n0 to n1 via R */
uint32_t packetSize = 1024;

View File

@@ -167,12 +167,12 @@ int main(int argc, char *argv[]) {
Ptr<Node> appSource = NodeList::GetNode(0);
Ptr<Sender> sender = CreateObject<Sender>();
appSource->AddApplication(sender);
sender->Start(Seconds(1));
sender->SetStartTime(Seconds(1));
Ptr<Node> appSink = NodeList::GetNode(1);
Ptr<Receiver> receiver = CreateObject<Receiver>();
appSink->AddApplication(receiver);
receiver->Start(Seconds(0));
receiver->SetStartTime(Seconds(0));
// Config::Set("/NodeList/*/ApplicationList/*/$Sender/Destination",
// Ipv4AddressValue("192.168.0.2"));

View File

@@ -210,8 +210,8 @@ main (int argc, char *argv[])
Ptr<MyApp> app = CreateObject<MyApp> ();
app->Setup (ns3TcpSocket, sinkAddress, 1040, 1000, DataRate ("1Mbps"));
nodes.Get (0)->AddApplication (app);
app->Start (Seconds (1.));
app->Stop (Seconds (20.));
app->SetStartTime (Seconds (1.));
app->SetStopTime (Seconds (20.));
devices.Get (1)->TraceConnectWithoutContext("PhyRxDrop", MakeCallback (&RxDrop));

View File

@@ -80,7 +80,7 @@ static void GenerateTraffic (Ptr<Socket> socket, uint32_t pktSize,
{
socket->Send (Create<Packet> (pktSize));
Simulator::Schedule (pktInterval, &GenerateTraffic,
socket, pktSize,pktCount-1, pktInterval);
socket, pktSize,pktCount-1, pktInterval);
}
else
{
@@ -187,8 +187,9 @@ int main (int argc, char *argv[])
// Output what we are doing
NS_LOG_UNCOND ("Testing " << numPackets << " packets sent with receiver rss " << rss );
Simulator::Schedule (Seconds (1.0), &GenerateTraffic,
source, packetSize, numPackets, interPacketInterval);
Simulator::ScheduleWithContext (source->GetNode ()->GetId (),
Seconds (1.0), &GenerateTraffic,
source, packetSize, numPackets, interPacketInterval);
Simulator::Run ();
Simulator::Destroy ();

View File

@@ -200,8 +200,9 @@ int main (int argc, char *argv[])
// Output what we are doing
NS_LOG_UNCOND ("Testing " << numPackets << " packets sent with receiver rss " << rss );
Simulator::Schedule (Seconds (1.0), &GenerateTraffic,
source, packetSize, numPackets, interPacketInterval);
Simulator::ScheduleWithContext (source->GetNode ()->GetId (),
Seconds (1.0), &GenerateTraffic,
source, packetSize, numPackets, interPacketInterval);
Simulator::Stop (Seconds (30.0));
Simulator::Run ();

View File

@@ -245,11 +245,13 @@ int main (int argc, char *argv[])
// Output what we are doing
NS_LOG_UNCOND ("Primary packet RSS=" << Prss << " dBm and interferer RSS=" << Irss << " dBm at time offset=" << delta << " ms");
Simulator::Schedule (Seconds (startTime), &GenerateTraffic,
source, PpacketSize, numPackets, interPacketInterval);
Simulator::ScheduleWithContext (source->GetNode ()->GetId (),
Seconds (startTime), &GenerateTraffic,
source, PpacketSize, numPackets, interPacketInterval);
Simulator::Schedule (Seconds (startTime + delta/1000000.0), &GenerateTraffic,
interferer, IpacketSize, numPackets, interPacketInterval);
Simulator::ScheduleWithContext (interferer->GetNode ()->GetId (),
Seconds (startTime + delta/1000000.0), &GenerateTraffic,
interferer, IpacketSize, numPackets, interPacketInterval);
Simulator::Run ();
Simulator::Destroy ();

View File

@@ -81,6 +81,7 @@ Object::GetTypeId (void)
Object::Object ()
: m_tid (Object::GetTypeId ()),
m_disposed (false),
m_started (false),
m_aggregates ((struct Aggregates *)malloc (sizeof (struct Aggregates))),
m_getObjectCount (0)
{
@@ -113,6 +114,7 @@ Object::~Object ()
Object::Object (const Object &o)
: m_tid (o.m_tid),
m_disposed (false),
m_started (false),
m_aggregates ((struct Aggregates *)malloc (sizeof (struct Aggregates))),
m_getObjectCount (0)
{
@@ -158,6 +160,17 @@ Object::DoGetObject (TypeId tid) const
}
return 0;
}
void
Object::Start (void)
{
uint32_t n = m_aggregates->n;
for (uint32_t i = 0; i < n; i++)
{
Object *current = m_aggregates->buffer[i];
current->DoStart ();
current->m_started = true;
}
}
void
Object::Dispose (void)
{
@@ -264,6 +277,11 @@ Object::DoDispose (void)
NS_ASSERT (!m_disposed);
}
void
Object::DoStart (void)
{
NS_ASSERT (!m_started);
}
bool
Object::Check (void) const

View File

@@ -140,6 +140,12 @@ public:
*/
AggregateIterator GetAggregateIterator (void) const;
/**
* Execute starting code of an object. What this method does is really up
* to the user.
*/
void Start (void);
protected:
/**
* This function is called by the AggregateObject on all the objects connected in the listed chain.
@@ -148,6 +154,15 @@ protected:
* additional/special behavior when aggregated to another object.
*/
virtual void NotifyNewAggregate ();
/**
* This method is called only once by Object::Start. If the user
* calls Object::Start multiple times, DoStart is called only the
* first time.
*
* Subclasses are expected to override this method and _chain up_
* to their parent's implementation once they are done.
*/
virtual void DoStart (void);
/**
* This method is called by Object::Dispose or by the object's
* destructor, whichever comes first.
@@ -250,6 +265,11 @@ private:
* has run, false otherwise.
*/
bool m_disposed;
/**
* Set to true once the DoStart method has run,
* false otherwise
*/
bool m_started;
/**
* a pointer to an array of 'aggregates'. i.e., a pointer to
* each object aggregated to this object is stored in this

View File

@@ -90,6 +90,8 @@ NqapWifiMac::NqapWifiMac ()
m_dca->SetManager (m_dcfManager);
m_dca->SetTxOkCallback (MakeCallback (&NqapWifiMac::TxOk, this));
m_dca->SetTxFailedCallback (MakeCallback (&NqapWifiMac::TxFailed, this));
m_enableBeaconGeneration = false;
}
NqapWifiMac::~NqapWifiMac ()
{
@@ -110,6 +112,7 @@ NqapWifiMac::DoDispose (void)
m_dca = 0;
m_beaconDca = 0;
m_stationManager = 0;
m_enableBeaconGeneration = false;
m_beaconEvent.Cancel ();
WifiMac::DoDispose ();
}
@@ -118,20 +121,21 @@ void
NqapWifiMac::SetBeaconGeneration (bool enable)
{
NS_LOG_FUNCTION (this << enable);
if (enable)
if (!enable)
{
m_beaconEvent.Cancel ();
}
else if (enable && !m_enableBeaconGeneration)
{
m_beaconEvent = Simulator::ScheduleNow (&NqapWifiMac::SendOneBeacon, this);
}
else
{
m_beaconEvent.Cancel ();
}
m_enableBeaconGeneration = enable;
}
bool
NqapWifiMac::GetBeaconGeneration (void) const
{
return m_beaconEvent.IsRunning ();
return m_enableBeaconGeneration;
}
Time
NqapWifiMac::GetBeaconInterval (void) const
@@ -594,4 +598,15 @@ NqapWifiMac::FinishConfigureStandard (enum WifiPhyStandard standard)
}
void
NqapWifiMac::DoStart (void)
{
m_beaconEvent.Cancel ();
if (m_enableBeaconGeneration)
{
m_beaconEvent = Simulator::ScheduleNow (&NqapWifiMac::SendOneBeacon, this);
}
WifiMac::DoStart ();
}
} // namespace ns3

View File

@@ -112,6 +112,7 @@ private:
void SetBeaconGeneration (bool enable);
bool GetBeaconGeneration (void) const;
virtual void DoDispose (void);
virtual void DoStart (void);
NqapWifiMac (const NqapWifiMac & ctor_arg);
NqapWifiMac &operator = (const NqapWifiMac &o);
Ptr<DcaTxop> GetDcaTxop (void) const;
@@ -123,6 +124,7 @@ private:
Ptr<WifiPhy> m_phy;
Callback<void, Ptr<Packet>,Mac48Address, Mac48Address> m_upCallback;
Time m_beaconInterval;
bool m_enableBeaconGeneration;
DcfManager *m_dcfManager;
MacRxMiddle *m_rxMiddle;

View File

@@ -109,6 +109,8 @@ QapWifiMac::QapWifiMac ()
SetQueue (AC_VI);
SetQueue (AC_BE);
SetQueue (AC_BK);
m_enableBeaconGeneration = false;
}
QapWifiMac::~QapWifiMac ()
@@ -129,6 +131,7 @@ QapWifiMac::DoDispose ()
m_low = 0;
m_phy = 0;
m_beaconDca = 0;
m_enableBeaconGeneration = false;
m_beaconEvent.Cancel ();
m_stationManager = 0;
for (Queues::iterator i = m_queues.begin (); i != m_queues.end (); ++i)
@@ -142,20 +145,21 @@ void
QapWifiMac::SetBeaconGeneration (bool enable)
{
NS_LOG_FUNCTION (this << enable);
if (enable)
{
m_beaconEvent = Simulator::ScheduleNow (&QapWifiMac::SendOneBeacon, this);
}
else
if (!enable)
{
m_beaconEvent.Cancel ();
}
else if (enable && !m_enableBeaconGeneration)
{
m_beaconEvent = Simulator::ScheduleNow (&QapWifiMac::SendOneBeacon, this);
}
m_enableBeaconGeneration = enable;
}
bool
QapWifiMac::GetBeaconGeneration (void) const
{
return m_beaconEvent.IsRunning ();
return m_enableBeaconGeneration;
}
Time
@@ -772,4 +776,15 @@ QapWifiMac::FinishConfigureStandard (enum WifiPhyStandard standard)
}
}
void
QapWifiMac::DoStart (void)
{
m_beaconEvent.Cancel ();
if (m_enableBeaconGeneration)
{
m_beaconEvent = Simulator::ScheduleNow (&QapWifiMac::SendOneBeacon, this);
}
WifiMac::DoStart ();
}
} //namespace ns3

View File

@@ -92,6 +92,7 @@ private:
typedef std::list<std::pair<Ptr<Packet>, AmsduSubframeHeader> >::const_iterator DeaggregatedMsdusCI;
virtual void DoDispose (void);
virtual void DoStart (void);
void Receive (Ptr<Packet> packet, WifiMacHeader const*hdr);
void ForwardUp (Ptr<Packet> packet, Mac48Address from, Mac48Address to);
void ForwardDown (Ptr<const Packet> packet, Mac48Address from, Mac48Address to);
@@ -130,6 +131,7 @@ private:
Ssid m_ssid;
EventId m_beaconEvent;
Time m_beaconInterval;
bool m_enableBeaconGeneration;
Callback<void,Ptr<Packet>, Mac48Address, Mac48Address> m_forwardUp;
};

View File

@@ -85,7 +85,7 @@ ApplicationContainer::Start (Time start)
for (Iterator i = Begin (); i != End (); ++i)
{
Ptr<Application> app = *i;
app->Start (start);
app->SetStartTime (start);
}
}
void
@@ -94,7 +94,7 @@ ApplicationContainer::Stop (Time stop)
for (Iterator i = Begin (); i != End (); ++i)
{
Ptr<Application> app = *i;
app->Stop (stop);
app->SetStopTime (stop);
}
}

View File

@@ -55,11 +55,6 @@ RandomDirection2dMobilityModel::GetTypeId (void)
return tid;
}
RandomDirection2dMobilityModel::RandomDirection2dMobilityModel ()
{
m_event = Simulator::ScheduleNow (&RandomDirection2dMobilityModel::Start, this);
}
void
RandomDirection2dMobilityModel::DoDispose (void)
{
@@ -67,7 +62,14 @@ RandomDirection2dMobilityModel::DoDispose (void)
MobilityModel::DoDispose ();
}
void
RandomDirection2dMobilityModel::Start (void)
RandomDirection2dMobilityModel::DoStart (void)
{
DoStartPrivate ();
MobilityModel::DoStart ();
}
void
RandomDirection2dMobilityModel::DoStartPrivate (void)
{
double direction = m_direction.GetValue (0, 2 * PI);
SetDirectionAndSpeed (direction);
@@ -79,6 +81,7 @@ RandomDirection2dMobilityModel::BeginPause (void)
m_helper.Update ();
m_helper.Pause ();
Time pause = Seconds (m_pause.GetValue ());
m_event.Cancel ();
m_event = Simulator::Schedule (pause, &RandomDirection2dMobilityModel::ResetDirectionAndSpeed, this);
NotifyCourseChange ();
}
@@ -97,6 +100,7 @@ RandomDirection2dMobilityModel::SetDirectionAndSpeed (double direction)
m_helper.Unpause ();
Vector next = m_bounds.CalculateIntersection (position, vector);
Time delay = Seconds (CalculateDistance (position, next) / speed);
m_event.Cancel ();
m_event = Simulator::Schedule (delay,
&RandomDirection2dMobilityModel::BeginPause, this);
NotifyCourseChange ();
@@ -136,7 +140,8 @@ RandomDirection2dMobilityModel::DoSetPosition (const Vector &position)
{
m_helper.SetPosition (position);
Simulator::Remove (m_event);
m_event = Simulator::ScheduleNow (&RandomDirection2dMobilityModel::Start, this);
m_event.Cancel ();
m_event = Simulator::ScheduleNow (&RandomDirection2dMobilityModel::DoStartPrivate, this);
}
Vector
RandomDirection2dMobilityModel::DoGetVelocity (void) const

View File

@@ -45,14 +45,14 @@ class RandomDirection2dMobilityModel : public MobilityModel
public:
static TypeId GetTypeId (void);
RandomDirection2dMobilityModel ();
private:
void Start (void);
void ResetDirectionAndSpeed (void);
void BeginPause (void);
void SetDirectionAndSpeed (double direction);
void InitializeDirectionAndSpeed (void);
void DoStartPrivate (void);
virtual void DoDispose (void);
virtual void DoStart (void);
virtual Vector DoGetPosition (void) const;
virtual void DoSetPosition (const Vector &position);
virtual Vector DoGetVelocity (void) const;

View File

@@ -72,13 +72,15 @@ RandomWalk2dMobilityModel::GetTypeId (void)
return tid;
}
RandomWalk2dMobilityModel::RandomWalk2dMobilityModel ()
void
RandomWalk2dMobilityModel::DoStart (void)
{
m_event = Simulator::ScheduleNow (&RandomWalk2dMobilityModel::Start, this);
DoStartPrivate ();
MobilityModel::DoStart ();
}
void
RandomWalk2dMobilityModel::Start (void)
RandomWalk2dMobilityModel::DoStartPrivate (void)
{
m_helper.Update ();
double speed = m_speed.GetValue ();
@@ -109,9 +111,10 @@ RandomWalk2dMobilityModel::DoWalk (Time delayLeft)
Vector nextPosition = position;
nextPosition.x += speed.x * delayLeft.GetSeconds ();
nextPosition.y += speed.y * delayLeft.GetSeconds ();
m_event.Cancel ();
if (m_bounds.IsInside (nextPosition))
{
m_event = Simulator::Schedule (delayLeft, &RandomWalk2dMobilityModel::Start, this);
m_event = Simulator::Schedule (delayLeft, &RandomWalk2dMobilityModel::DoStartPrivate, this);
}
else
{
@@ -163,7 +166,7 @@ RandomWalk2dMobilityModel::DoSetPosition (const Vector &position)
NS_ASSERT (m_bounds.IsInside (position));
m_helper.SetPosition (position);
Simulator::Remove (m_event);
m_event = Simulator::ScheduleNow (&RandomWalk2dMobilityModel::Start, this);
m_event = Simulator::ScheduleNow (&RandomWalk2dMobilityModel::DoStartPrivate, this);
}
Vector
RandomWalk2dMobilityModel::DoGetVelocity (void) const

View File

@@ -52,13 +52,12 @@ class RandomWalk2dMobilityModel : public MobilityModel
MODE_TIME
};
RandomWalk2dMobilityModel ();
private:
void Start (void);
void Rebound (Time timeLeft);
void DoWalk (Time timeLeft);
void DoStartPrivate (void);
virtual void DoDispose (void);
virtual void DoStart (void);
virtual Vector DoGetPosition (void) const;
virtual void DoSetPosition (const Vector &position);
virtual Vector DoGetVelocity (void) const;

View File

@@ -54,11 +54,6 @@ RandomWaypointMobilityModel::GetTypeId (void)
return tid;
}
RandomWaypointMobilityModel::RandomWaypointMobilityModel ()
{
m_event = Simulator::ScheduleNow (&RandomWaypointMobilityModel::Start, this);
}
void
RandomWaypointMobilityModel::BeginWalk (void)
{
@@ -74,13 +69,21 @@ RandomWaypointMobilityModel::BeginWalk (void)
m_helper.SetVelocity (Vector (k*dx, k*dy, k*dz));
m_helper.Unpause ();
Time travelDelay = Seconds (CalculateDistance (destination, m_current) / speed);
m_event.Cancel ();
m_event = Simulator::Schedule (travelDelay,
&RandomWaypointMobilityModel::Start, this);
&RandomWaypointMobilityModel::DoStartPrivate, this);
NotifyCourseChange ();
}
void
RandomWaypointMobilityModel::Start (void)
RandomWaypointMobilityModel::DoStart (void)
{
DoStartPrivate ();
MobilityModel::DoStart ();
}
void
RandomWaypointMobilityModel::DoStartPrivate (void)
{
m_helper.Update ();
m_helper.Pause ();
@@ -100,7 +103,7 @@ RandomWaypointMobilityModel::DoSetPosition (const Vector &position)
{
m_helper.SetPosition (position);
Simulator::Remove (m_event);
m_event = Simulator::ScheduleNow (&RandomWaypointMobilityModel::Start, this);
m_event = Simulator::ScheduleNow (&RandomWaypointMobilityModel::DoStartPrivate, this);
}
Vector
RandomWaypointMobilityModel::DoGetVelocity (void) const

View File

@@ -45,10 +45,11 @@ class RandomWaypointMobilityModel : public MobilityModel
{
public:
static TypeId GetTypeId (void);
RandomWaypointMobilityModel ();
protected:
virtual void DoStart (void);
private:
void Start (void);
void BeginWalk (void);
void DoStartPrivate (void);
virtual Vector DoGetPosition (void) const;
virtual void DoSetPosition (const Vector &position);
virtual Vector DoGetVelocity (void) const;

View File

@@ -40,6 +40,14 @@ Application::GetTypeId (void)
{
static TypeId tid = TypeId ("ns3::Application")
.SetParent<Object> ()
.AddAttribute ("StartTime", "Time at which the application will start",
TimeValue (Seconds (0.0)),
MakeTimeAccessor (&Application::m_startTime),
MakeTimeChecker ())
.AddAttribute ("StopTime", "Time at which the application will stop",
TimeValue (TimeStep (0)),
MakeTimeAccessor (&Application::m_stopTime),
MakeTimeChecker ())
;
return tid;
}
@@ -52,38 +60,38 @@ Application::Application()
Application::~Application()
{}
void
Application::SetStartTime (Time start)
{
m_startTime = start;
}
void
Application::SetStopTime (Time stop)
{
m_stopTime = stop;
}
void
Application::DoDispose (void)
{
m_node = 0;
Simulator::Cancel(m_startEvent);
Simulator::Cancel(m_stopEvent);
m_startEvent.Cancel ();
m_stopEvent.Cancel ();
Object::DoDispose ();
}
void Application::Start(const Time& startTime)
{
ScheduleStart (startTime);
}
void Application::Start(const RandomVariable& startVar)
void
Application::DoStart (void)
{
RandomVariable v = startVar;
ScheduleStart (Seconds (v.GetValue ()));
m_startEvent = Simulator::Schedule (m_startTime, &Application::StartApplication, this);
if (m_stopTime != TimeStep (0))
{
m_stopEvent = Simulator::Schedule (m_stopTime, &Application::StopApplication, this);
}
Object::DoStart ();
}
void Application::Stop(const Time& stopTime)
{
ScheduleStop (stopTime);
}
void Application::Stop(const RandomVariable& stopVar)
{
RandomVariable v = stopVar;
ScheduleStop (Seconds (v.GetValue ()));
}
Ptr<Node> Application::GetNode() const
{
return m_node;
@@ -105,20 +113,6 @@ void Application::StopApplication()
{ // Provide null functionality in case subclass is not interested
}
// Private helpers
void Application::ScheduleStart (const Time &startTime)
{
m_startEvent = Simulator::Schedule (startTime,
&Application::StartApplication, this);
}
void Application::ScheduleStop (const Time &stopTime)
{
m_stopEvent = Simulator::Schedule (stopTime,
&Application::StopApplication, this);
}
} //namespace ns3

View File

@@ -64,7 +64,7 @@ public:
static TypeId GetTypeId (void);
Application ();
virtual ~Application ();
/**
* \brief Specify application start time
* \param startTime Start time for this application,
@@ -76,15 +76,7 @@ public:
* private "StartApplication" method defined below, which is called at the
* time specified, to cause the application to begin.
*/
void Start (const Time& startTime);
/**
* \brief Specify application start time.
* \param startVariable the random variable to use to pick
* the real start time as a relative time, in units of
* seconds, relative to the current simulation time.
*/
void Start (const RandomVariable& startVariable);
void SetStartTime (Time start);
/**
* \brief Specify application stop time
@@ -97,16 +89,8 @@ public:
* the private StopApplication method, to be notified when that
* time has come.
*/
void Stop (const Time& stopTime);
/**
* \brief Specify application stop time
* \param stopVariable the random variable to use to pick
* the real stop time, in units of seconds,
* relative to the current simulation time.
*/
void Stop (const RandomVariable& stopVariable);
void SetStopTime (Time stop);
/**
* \returns the Node to which this Application object is attached.
*/
@@ -137,13 +121,13 @@ private:
virtual void StopApplication (void);
protected:
virtual void DoDispose (void);
private:
void ScheduleStart (const Time &time);
void ScheduleStop (const Time &time);
virtual void DoStart (void);
EventId m_startEvent;
EventId m_stopEvent;
Ptr<Node> m_node;
Time m_startTime;
Time m_stopTime;
EventId m_startEvent;
EventId m_stopEvent;
};
} //namespace ns3

View File

@@ -119,6 +119,7 @@ NodeListPriv::Add (Ptr<Node> node)
{
uint32_t index = m_nodes.size ();
m_nodes.push_back (node);
Simulator::ScheduleWithContext (index, TimeStep (0), &Node::Start, node);
return index;
}

View File

@@ -167,6 +167,24 @@ Node::DoDispose()
m_applications.clear ();
Object::DoDispose ();
}
void
Node::DoStart (void)
{
for (std::vector<Ptr<NetDevice> >::iterator i = m_devices.begin ();
i != m_devices.end (); i++)
{
Ptr<NetDevice> device = *i;
device->Start ();
}
for (std::vector<Ptr<Application> >::iterator i = m_applications.begin ();
i != m_applications.end (); i++)
{
Ptr<Application> application = *i;
application->Start ();
}
Object::DoStart ();
}
void
Node::NotifyDeviceAdded (Ptr<NetDevice> device)

View File

@@ -186,6 +186,7 @@ protected:
* end of their own DoDispose method.
*/
virtual void DoDispose (void);
virtual void DoStart (void);
private:
/**

View File

@@ -68,6 +68,19 @@ Ipv4ListRouting::DoDispose (void)
m_ipv4 = 0;
}
void
Ipv4ListRouting::DoStart (void)
{
for (Ipv4RoutingProtocolList::iterator rprotoIter = m_routingProtocols.begin ();
rprotoIter != m_routingProtocols.end (); rprotoIter++)
{
Ptr<Ipv4RoutingProtocol> protocol = (*rprotoIter).second;
protocol->Start ();
}
Ipv4RoutingProtocol::DoStart ();
}
Ptr<Ipv4Route>
Ipv4ListRouting::RouteOutput (Ptr<Packet> p, const Ipv4Header &header, uint32_t oif, enum Socket::SocketErrno &sockerr)
{

View File

@@ -88,6 +88,7 @@ public:
protected:
void DoDispose (void);
void DoStart (void);
private:
typedef std::pair<int16_t, Ptr<Ipv4RoutingProtocol> > Ipv4RoutingProtocolEntry;
typedef std::list<Ipv4RoutingProtocolEntry> Ipv4RoutingProtocolList;

View File

@@ -213,8 +213,6 @@ RoutingProtocol::SetIpv4 (Ptr<Ipv4> ipv4)
m_linkTupleTimerFirstTime = true;
m_ipv4 = ipv4;
Simulator::ScheduleNow (&RoutingProtocol::Start, this);
}
void RoutingProtocol::DoDispose ()
@@ -231,7 +229,7 @@ void RoutingProtocol::DoDispose ()
Ipv4RoutingProtocol::DoDispose ();
}
void RoutingProtocol::Start ()
void RoutingProtocol::DoStart ()
{
if (m_mainAddress == Ipv4Address ())
{

View File

@@ -81,6 +81,8 @@ public:
void SetMainInterface (uint32_t interface);
protected:
virtual void DoStart (void);
private:
std::map<Ipv4Address, RoutingTableEntry> m_table; ///< Data structure for the routing table.
@@ -111,7 +113,7 @@ private:
Ptr<Ipv4> m_ipv4;
private:
void Start ();
void Clear ();
uint32_t GetSize () const { return m_table.size (); }
std::vector<RoutingTableEntry> GetEntries () const;