Make applications generate traffic within their associated context/node
This commit is contained in:
1 parent
86e9753297
commit
ef00a998fb
30 files changed
+225
-126
No files matched your search
@@ -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
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in new issue
Block a user