Ns-3 Network Simulator

From Script | Spoken-Tutorial
Jump to: navigation, search

The ns-3 simulator is a sophisticated, discrete-event network simulator, widely used for research and educational purposes in the field of computer networking. It excels in simulating a variety of network protocols and technologies, both wired and wireless, including emerging Internet systems. Open-source and freely available, ns-3 provides an extensible framework that allows users to develop new models and protocols. The simulator supports scripting in both C++ and Python, offering flexibility in simulation design and implementation. Its realistic modeling of network behavior makes it a valuable tool for academic research, enabling the testing of network protocols and architectures under controlled conditions. The version of the ns-3 used in this tutorials series is ns-3.38.

The development of the ns-3 simulator is a collaborative effort involving a global community of researchers and developers. It was not created by a single individual or organization. Instead, it emerged from the academic and research community as a successor to the ns-2 simulator.


This tutorial was written and recorded by Karthik chandrasekar, Arun Santosh and Josiga under the guidance of Dr. R. Radha, Dr.X. Anita and Dr.T. Subbulakshmi from VIT Chennai. The Spoken Tutorial Effort for ns-3 is being contributed by Ms. Nirmala Venkat and Ms. Madhuri Ganapathi.

Basic Level

1.Installation of Network simulator-3

  • ns-3 version 3.38
  • About ns-3
  • Installation of Network Simulator-3 on ubuntu Linux
  • Update the system
  • Download the packages.txt
  • Install the packages mentioned in packages text file
  • Go to www.nsnam.org website and download ns-3.38
  • Install and build the extracted files
  • Install NetAnim
  • Run a default Scratch simulator program to verify the installation
  • Features of ns-3

2. Creating Point to Point Network in ns-3

  • ns-3 version 3.38
  • About Point to point topology
  • Create nodes in ns-3
  • Initialize a Point-to-Point network between the nodes
  • Install net devices on nodes
  • Assign IP addresses to net devices
  • Install and configure an echo server on a node
  • Install and configure an echo client on a node
  • Generate an XML file for simulation animation
  • Run the simulation and observe the output in the terminal
  • Play network simulation animation in NetAnim

3. Network performance Analysis

  • Create variables for network parameters
  • Create callback functions
  • Connect trace sources to callback functions
  • Calculate network parameters using trace source
  • Create a point-to-point network topology
  • Install client and server applications
  • Configure animation
  • Run the simulation
  • Observe the terminal output
  • Observe animation in NetAnim

4. CSMA based network with bus topology

  • ns-3 version 3.38
  • Defining the topology
  • Classes and methods description
  • Initializing bus topology
  • Setting default parameters
  • Installing Server and client applications on node 1 and node 10
  • Calculate delay and throughput
  • Populate routing tables for the topology
  • Run simulation
  • Observe delay and throughput in terminal window
  • Visualizing through NetAnim

5. Connecting multiple networks with routers

  • ns-3 version 3.38
  • Define topology, classes and methods description
  • Describe the parameters for star and CSMA networks
  • Set attributes of point-to-point connections
  • Initialize star network and install internet stack on nodes of the star network
  • Create packet sink on the hub of the star network
  • Create node container for point-to-point network and CSMA network
  • Install net devices and internet stack on the nodes
  • Assign IP addresses to the networks
  • Install echo client and echo server applications on the nodes
  • Set the position of the nodes
  • Run the simulation and observe the output
  • Play simulation animation in NetAnim

Intermediate Level

1. Dynamic Routing Protocol

  • ns-3 version 3.38
  • Enable dynamic routing
  • Create nodes
  • Install internet stack
  • Assign IP addresses to the networks
  • Create On/Off applications
  • Install applications on the nodes
  • Create routing tables
  • Select link to deactivate
  • Set down times for selected link
  • Run simulation
  • Analyze routes file
  • Visualize routing animation in NetAnim

2. Creating TCP-UDP flow with Star Topology

  • ns-3 version 3.38
  • Defining the topology
  • Classes and Methods required
  • Build Star topology using p2p links
  • Setting constant parameters like Dataflow and delay
  • Create TCP flow
  • Set the attribute to remote
  • Create UDP flow
  • Run the simulation
  • Initialize flow monitor
  • Analyze the flow using flow monitor
  • Observe Throughput and delay of the flow

3. Analyzing TCP Congestion window

  • ns-3 version 3.38
  • Introduction to TCP New Reno congestion control algorithm
  • Overview of classes and methods used
  • About TutorialApp class and trace sources
  • Create a CSMA network with 2 nodes
  • Create a RateErrorModel object pointer
  • Create a TCP socket with TCP New Reno congestion control algorithm
  • Install packet sink on receiver node
  • Create a file stream and Connect stream to trace source
  • Configure GNU plot and run the simulation
  • Observe changes in window size over time
  • Generate a plot

4. Infrastructure based Wireless Network

  • ns-3 version 3.38
  • Create nodes for the topology
  • Put the network Interface cards together
  • Set the wifi channel attributes
  • Connect the wifi devices to the channel
  • Add MAC addresses and assign SSID to devices
  • Set up Station nodes and Access points of the network
  • Install mobility helper to the nodes and install internet stack on the nodes
  • Assign IP addresses and create UDP flows
  • Schedule the simulator and analyze the flow using a flow monitor
  • Generate XML file and observe the flow details
  • Visualize the network infrastructure

5. Creating an ad-hoc wireless network

  • ns-3 version 3.38
  • Create nodes for the topology
  • Put the network Interface cards together
  • Set the wifi channel attributes
  • Connect the wifi devices to the channel
  • Add MAC addresses and set the network to Ad-hoc mode
  • Install mobility helper and internet stack to the nodes
  • Assign IP addresses and create UDP flows
  • Schedule the simulator
  • Analyze the flow using a flow monitor
  • Generate XML file
  • Observe the flow details and visualize the network infrastructure

Contributors and Content Editors

Madhurig