It's going to be a little while before I can get my "real" simulations
up and running with ns-3, but your questions got me curious so I
whipped up a test script, in which every node follows the same path
and fires off some packets during its trip. While these results are
relatively anecdotal (and can be considered worst-case), they helped
provide me with some insight on (1) the code difference between
scheduling velocity-change events and just adding waypoints (to my own
model), and (2) the memory usage requirements of scheduling a large
number of events.
My test was pretty basic, and I played with the parameters a bit but
most of the results follow a trend. I simulated 50 vehicles traveling
along the same path consisting of 3600 waypoints over the course of
3600 seconds. The method of movement was the only thing that changed:
velocity update events vs. the automatic updates from my custom
mobility model. During each vehicle's trip, 1000 L3 broadcasts are
sent at random times (and verified as received, but that's less
important). Most parameters were left as default, with a
ConstantRateWifiManager and an AdhocWifiMac (no internet stack was set
up for these runs). I do mostly understand the implications of this
setup (I grok source code as a hobby!), but as I said this is a basic
test and I might have time for more detail in the coming months. If
there is anything really simple that would help this experiment that I
missed, feel free to point it out.
As far as speed goes, my mobility model provided only a 0-2% speed
increase (parameter-dependent), which is much less than I expected,
but I also haven't looked much into any optimization possibilities.
The lack of improvement there led me to do some memory profiling to
see if there was any significant benefit at all, which made me feel
better about caring about this issue in the first place :)
Here are some massif graphs that I hope will come out okay in their
default format.
First, the memory usage (compared to total) for the event-based method
using existing mobility models:
--------------------------------------------------------------------------------
Command: ./build/optimized/scratch/mobile-wireless -c
Massif arguments: --time-unit=B
ms_print arguments: massif.out.c3
--------------------------------------------------------------------------------
MB
27.63^#..
|#::::.
|#::::: ::..
|#::::: :::: :..
|#::::: :::: ::::.
|#::::: :::: ::::: :: .
|#::::: :::: ::::: :: ::..
|#::::: :::: ::::: :: :::: :,..
|#::::: :::: ::::: :: :::: :@:::..
|#::::: :::: ::::: :: :::: :@:::::::..
|#::::: :::: ::::: :: :::: :@::::::::::@ .
|#::::: :::: ::::: :: :::: :@::::::::::@ ::@..
|#::::: :::: ::::: :: :::: :@::::::::::@ ::@:::..
|#::::: :::: ::::: :: :::: :@::::::::::@ ::@::::::.,.
|#::::: :::: ::::: :: :::: :@::::::::::@ ::@:::::::@::..
|#::::: :::: ::::: :: :::: :@::::::::::@ ::@:::::::@::::::,.
|#::::: :::: ::::: :: :::: :@::::::::::@ ::@:::::::@::::::@::..
|
#::::: :::: ::::: :: :::: :@::::::::::@ ::@:::::::@::::::@:::::@..
|
#::::: :::: ::::: :: :::: :@::::::::::@ ::@:::::::@::::::@:::::@:::...
|
#::::: :::: ::::: :: :::: :@::::::::::@ ::@:::::::@::::::@:::::@::::::@.
0
+-----------------------------------------------------------------------
>GB
0
3.261
Number of snapshots: 83
Detailed snapshots: [1 (peak), 24, 36, 40, 50, 60, 70, 80]
--------------------------------------------------------------------------------
n time(B) total(B) useful-heap(B) extra-heap(B)
stacks(B)
--------------------------------------------------------------------------------
0 0 0 0
0 0
1 29,215,328 28,971,312 25,226,619
3,744,693 0
Now, with the SpecificWaypointMobilityModel (mine):
--------------------------------------------------------------------------------
Command: ./build/optimized/scratch/mobile-wireless -w
Massif arguments: --time-unit=B
ms_print arguments: massif.out.w3
--------------------------------------------------------------------------------
MB
15.85^#.
|#::: ..
|#::: ::: ..
|#::: ::: ::::.
|#::: ::: :::::::: .
|#::: ::: :::::::: : .,
|#::: ::: :::::::: : :@::..
|#::: ::: :::::::: : :@:::::: ..
|#::: ::: :::::::: : :@:::::: :: ..
|#::: ::: :::::::: : :@:::::: :: ::@ ..
|#::: ::: :::::::: : :@:::::: :: ::@ :: :..
|#::: ::: :::::::: : :@:::::: :: ::@ :: ::::: .
|#::: ::: :::::::: : :@:::::: :: ::@ :: ::::: :@.
|#::: ::: :::::::: : :@:::::: :: ::@ :: ::::: :@: :: .
|#::: ::: :::::::: : :@:::::: :: ::@ :: ::::: :@: :: : :@.
|#::: ::: :::::::: : :@:::::: :: ::@ :: ::::: :@: :: : :@:::.,
|
#::: ::: :::::::: : :@:::::: :: ::@ :: ::::: :@: :: : :@::::@::..
|
#::: ::: :::::::: : :@:::::: :: ::@ :: ::::: :@: :: : :@::::@::::::,.
|
#::: ::: :::::::: : :@:::::: :: ::@ :: ::::: :@: :: : :@::::@::::::@::..
|
#::: ::: :::::::: : :@:::::: :: ::@ :: ::::: :@: :: : :@::::@::::::@::::
0
+-----------------------------------------------------------------------
>GB
0
3.246
Number of snapshots: 74
Detailed snapshots: [1 (peak), 20, 32, 41, 48, 56, 66]
--------------------------------------------------------------------------------
n time(B) total(B) useful-heap(B) extra-heap(B)
stacks(B)
--------------------------------------------------------------------------------
0 0 0 0
0 0
1 19,911,408 16,623,264 15,555,907
1,067,357 0
So, despite the lack of a huge speed increase, there is a tangible
memory usage benefit. Also, the code is a bit more simple to set up a
VANET-type simulation where paths are expressed as waypoints. Let's
pretend we have a waypoint type set up, which is a struct containing a
time (t) and position (p). The code for a
ConstantVelocityWaypointModel might look something like this (with a
previously set up deque of waypoints):
for ( std::deque<Waypoint>::const_iterator i = waypoints.begin ();
i != waypoints.end (); ++i )
{
if ( i == waypoints.begin() )
{
lastWaypoint = (*i);
nodeMobility->SetPosition (lastWaypoint.p);
continue;
}
span = ((*i).t - lastWaypoint.t).GetSeconds ();
currentVelocity.x = ((*i).p.x - lastWaypoint.p.x) / span;
currentVelocity.y = ((*i).p.y - lastWaypoint.p.y) / span;
currentVelocity.z = ((*i).p.z - lastWaypoint.p.z) / span;
Simulator::Schedule (lastWaypoint.t, UpdateVelocity,
nodeMobility, currentVelocity);
lastWaypoint = (*i);
}
Simulator::Schedule (lastWaypoint.t, UpdateVelocity, nodeMobility,
Vector (0,0,0));
--
Whereas a waypoint-based mobility model would simplify it to this:
for ( std::deque<Waypoint>::const_iterator i = waypoints.begin();
i != waypoints.end(); ++i )
nodeMobility->AddWaypoint(*i);
(and no UpdateVelocity event handler would be required)
--
This is assuming there is a "Waypoint" type and we have a mobility
model that would accept it, of course. I feel that myself and other
VANET simulation users look at mobility in a way that would be better
expressed as waypoints during a trip rather than velocity changes at
specific times.
Hopefully this sheds some light on the current situation, and I'll do
my best to provide any other test results/traces if necessary.
Currently, I'll setter with either implementation but I of course
prefer lower memory usage to promote simulation scalability. After
some time with ns-3, I'm seeing that my efforts might be better spent
on figuring out how to remove nodes from a very long running
simulation, which would also benefit many like-minded MANET/VANET
researchers.
Cheers,
- Phillip
On Oct 23, 12:46 am, Mathieu Lacage <
mathieu.lac...@gmail.com> wrote:
> Mathieu Lacage <
mathieu.lac...@gmail.com>