Install NS2 (Network Simulator) on Ubuntu 18.04

1 minute read


Introduction

NS2 is an open-source simulation tool that runs on Linux. It is a discreet event simulator targeted at networking research and provides substantial support for simulation of routing, multicast protocols and IP protocols, such as UDP, TCP, RTP and SRM over wired and wireless (local and satellite) networks.


Pre-requisites

To view your network simulation traces made using ns-2, you’ll need Nam: Network Animator.

Nam is a Tcl/TK based animation tool for viewing network simulation traces and real world packet traces. It supports topology layout, packet level animation, and various data inspection tools.

Install it by running the following command in your terminal:

sudo apt-get install -y nam


Installation

Run the following command in your terminal to install ns-2:

sudo apt-get install -y ns2


Check your installation

You can check your installation by running a simple Tcl script.

  1. Create a file:
     gedit add.tcl
    
  2. Paste the following code in the file:
     set a 20
     set b 30
     set c [expr $a+$b]
     puts $c
    
  3. Run in the terminal using ns-2:
     ns add.tcl
    


Running a simple simulation

  1. Paste the following code in a file simple.tcl:
  2. Run the simulation from the terminal using ns-2:
     ns simple.tcl
    
  3. Click on the play button to start the simulation:

If you are a beginner to network simulation, you can find the explanation for the above script here.

The ns-allinone-2.31 package is available here if needed.


Contribute

This website is open source. :hearts:
Improve this page

Updated:

Leave a comment