Generate the Required Mobility Trace using Mobisim.
For this, you may follow the steps described in my previous post
VANET Mobility Trace file Generation using Mobisim for ns-2 and ns-3 Simulations
In the following video, you may see the output animation of the default Freeway Scenario of Mobisim. (but in the bottom example, we used another rectangular road scenario.)
The following Script is almost same as the one which we presented in my previous article
Using ns-2 Mobility Traces in ns-3 Simulation – A Simplified Example
SimpleNS3SimulationWithMobisimVANETtrac.cc
In this script, we are adding one important line which makes the output animation of the simulation much colourful. In that highlighted line at the bottom, we are setting the image attribute of the node. So, instead of seeing around the node, we will see a “car” image as a node.
#include "ns3/core-module.h" #include "ns3/mobility-module.h" #include "ns3/ns2-mobility-helper.h" #include "ns3/netanim-module.h" using namespace ns3; int main (int argc, char *argv[]) { // Create Ns2MobilityHelper with the specified trace log file as parameter Ns2MobilityHelper ns2 = Ns2MobilityHelper ("MobisimFreeway.txt"); // Create Moble nodes. NodeContainer MobileNodes; MobileNodes.Create (10); // configure movements for each node, while reading trace file ns2.Install (); AnimationInterface anim ("SimpleNS3SimulationWithMobisimFreeway-mobility-trace.xml"); //Setup Some image icon for the moving vehicles for(int i=0;i<10;i++) anim.UpdateNodeImage (i, anim.AddResource ("car-icon.png") ); Simulator::Stop (Seconds (100)); Simulator::Run (); return 0; }
You may download the above script from the following link :
SimpleNS3SimulationWithMobisimVANETtrace
Note: Sometimes, some manual editing should be made on the generated trace files of mobisim before using it on ns3 (or any other simulator) – At least we need to change the node IDs since the naming convention may differ. Similarly, we may need to add the initial node position and other things in the auto-generated mobility trace file.
The NetAnim Output
Finally, if we play the simulation in the NetAnim window, we will see an output similar to the following one..
Using a mobisim scenario in an ns-3 Simulation
The following article shows a way of simulating and visualizing a mobisim scenario in with ns-3.
Simulating Freeway Mobility Model under ns-3 Using Trace Files Generated by Mobisim
Visualizing a mobisim scenario in 3D in ns-3 Using NetSimulyzer
The following article shows a way of simulating and visualizing a mobisim scenario in 3D.
ns-3 VANET Simulation – 3D Visualization of 2D Gridway Mobility using NetSimulyzer