Quick introduction to a ns-3 Simulation Script

Networking engineers and researchers love ns-3, once they understand how easy it is to set up any complex networking topology. NS-3 supports most of the wired and wireless networking technologies. NS-3 is offering detailed documentation and many example c++ scripts related to a variety of networking technologies. Having experience in working with Ethernet, Wi-Fi, Wi-Fi 6, and LTE technologies, I would like to introduce you to important steps to write either wired or wireless ns-3 script. You may take any complex ns-3 script, you can understand it easily by mapping it into the following steps:

Setting up a simulation topology and configure it

  1. Create a number of nodes using NS-3 NodeContainer (C++ classes). In NS-3, we can set up any networking equipment (Wi-Fi, LTE, Ethernet, Computer, Server, Cell Phone, Laptop) using nodes.
  2. Deploy nodes using placement and mobility models. (Wi-Fi or LTE networks).
  3. Connect nodes using suitable communication channels with necessary configuration (e.g, Ethernet( CsmaHelper, PointToPointHelper), YansWifiChannelHelper, LteHelper, PointToPointEpcHelper).
  4. Install technology specific protocols using Helper classes on nodes.
  5. Install TCP/IP protocols on nodes (using InternetStackHelper)
  6. Configure IP addresses for all nodes (Ipv4AddressHelper)
  7. Enable global routing using Ipv4GlobalRoutingHelper::PopulateRoutingTables ()

After setting up your topology, we want to evaluate our test set up. NS-3 is offering a rich number of network applications to evaluate your test set up. (For example, it supports TCP, UDP, PING, and HTTP applications).

  1. Configure network application specific traffic characteristics such as packet size, number of packets, packet transmission interval etc.
  2. Install client and server applications carefully.
  3. Configure start and stop timings of your applications.
  4. To collect network performance metrics at the end of the simulation such as throughput, delay, jitter, and packet loss for each flow, install NS-3 FlowMonitor on nodes.
  5. To collect and view various flow packets at the end of the simulation, enable the packet capturing feature (using EnablePcapAll)  in your script.
  6. It is necessary to use Stop::Simulator () to collect flow statistics at the end of the simulation. 
  7. It is necessary to use Simulator::Run() for starting your simulation execution. 
  8. To visualize simulation details such as nodes placement, mobility, and their packets exchange, you can generate animation XML file using NS-3 AnimationInterface. It can be viewed at the end of the simulation using NS-3 supporting NetAnim visualization tool.
  9. Finally, release your simulation resources using Simulator::Destroy().

That’s all. With this just explore any ns-3 script for understanding details and make necessary changes for your simulation setup.

You may refer the following link to know more details: 

https://www.nsnam.org/docs/tutorial/singlehtml/

To view or add a comment, sign in

More articles by Anil Kumar Rangisetti

Others also viewed

Explore content categories