How do I Run Simulation in ns3

             Consider this article as the answer for the question “how do I run simulation in ns3?” because our research experts have provided the step by step process of simulation in network simulator 3.

Simulation Code in Ns3

             As the first process, the research scholars have to get to know about the source codes based on Ns3 in the following.

  • Ns3 source code for TCP sink application and packet transmission process
uint16_t port = 50000;
Address sinkLocalAddress (InetSocketAddress (Ipv4Address::GetAny (), port));
PacketSinkHelper sinkHelper ("ns3::TcpSocketFactory", sinkLocalAddress);
ApplicationContainer sinkApp = sinkHelper.Install (serverNode);
sinkApp.Start (Seconds (1.0));
sinkApp.Stop (Seconds (10.0));
  • Ns3 source code for node creation
NS_LOG_INFO ("Create nodes.");
NodeContainer serverNode;
NodeContainer clientNodes;
serverNode.Create (1);
clientNodes.Create (N-1);
NodeContainer allNodes = NodeContainer (serverNode, clientNodes);
  • Ns3 source code for header files
#include "ns3/core-module.h"
#include "ns3/network-module.h"
#include "ns3/internet-module.h"
#include "ns3/point-to-point-module.h"
#include "ns3/applications-module.h"
#include "ns3/ipv4-global-routing-helper.h"

Simulation Execution

           Consequently, the simulation program has to run through the implementation of the following commands.

cd /home/research/ns-allinone-3.28/ns-3.28

sudo ./waf –run SimulationCode –vis

Run Ns3 Simulation Program

         In addition, we have highlighted the results that are acquired from the execution of simulation and trace file format respectively.

Result of Simulation Execution

          The research scholars can call us to get clear with all their complications while implementing the simulation in ns3.