How to install NS(Network Simulator) and how do the simulation in Debian linux

Extract ns-allinone-2.34.tar to /usr/local/ns or /home/../ns then execute the command ./install
(if it goes fail fulfill all required dependencies–you may have to install xorg-x11-base separately…)

NS installation running on Debian terminal
Installation Process

After completing the installation

After completing the installation process
bin folder

#Duminda Rajitha Wanninayake
#This file is recreated using ns-simple.tcl example

#Create a simulator object
set ns [new Simulator]

#Define different colors for data flows (for NAM)
$ns color 1 Blue
$ns color 2 Red

#Open the NAM trace file
set nf [open out.nam w]
$ns namtrace-all $nf

#Define a 'finish' procedure
proc finish {} {

global ns nf

$ns flush-trace

#Close the NAM trace file

close $nf

#Execute NAM on the trace file

exec nam out.nam &

exit 0
}

#Create 8 nodes

set n0 [$ns node]
set n1 [$ns node]
set n2 [$ns node]
set n3 [$ns node]
set n4 [$ns node]
set n5 [$ns node]
set n6 [$ns node]
set n7 [$ns node]

#Create links between the nodes
$ns duplex-link $n2 $n1 5Mb 20ms DropTail
$ns duplex-link $n2 $n0 12Mb 5ms DropTail
$ns duplex-link $n1 $n0 3Mb 10ms DropTail
$ns duplex-link $n0 $n3 10Mb 10ms DropTail
$ns duplex-link $n3 $n4 1Mb 200ms DropTail
$ns duplex-link $n4 $n5 5Mb 30ms DropTail
$ns duplex-link $n5 $n6 7Mb 30ms DropTail
$ns duplex-link $n6 $n7 5Mb 20ms DropTail
$ns duplex-link $n6 $n4 4Mb 30ms DropTail
$ns duplex-link $n7 $n3 6Mb 15ms DropTail
$ns duplex-link $n7 $n0 4Mb 30ms DropTail

#Define Routing Distance Vector for Network
$ns rtproto DV

#Monitor the queue for link (n2-n3). (for NAM)
$ns duplex-link-op $n1 $n2 queuePos 0.5

#Setup a TCP connection between 3 and 6
set tcp [new Agent/TCP]
$tcp set class_ 2
$ns attach-agent $n2 $tcp
set sink [new Agent/TCPSink]
$ns attach-agent $n5 $sink
$ns connect $tcp $sink
$tcp set fid_ 1

#Setup a FTP over TCP connection
set ftp [new Application/FTP]
$ftp attach-agent $tcp
$ftp set type_ FTP

#Setup a UDP connection between 1 and 5
set udp [new Agent/UDP]
$ns attach-agent $n0 $udp
set null [new Agent/Null]
$ns attach-agent $n4 $null
$ns connect $udp $null
$udp set fid_ 2

#Setup a CBR over UDP connection
set cbr [new Application/Traffic/CBR]
$cbr attach-agent $udp
$cbr set type_ CBR
$cbr set packet_size_ 1500
$cbr set rate_ 1mb
$cbr set random_ false

#Set Queue Buffer Size of link (1-8) to 5
$ns queue-limit $n0 $n7 5

#Set Queue Buffer Size of link (1-4) to 10
$ns queue-limit $n0 $n3 10

#Schedule events for the CBR and FTP agents
$ns at 0.1 "$cbr start"
$ns at 0.2 "$ftp start"

$ns at 3.0 "$cbr stop"
$ns at 3.2 "$ftp stop"

#Call the finish procedure after 3.3 seconds of simulation time
$ns at 3.3 "finish"

#Run the simulation
$ns run

save this code as exNS.tcl and run it by executing the command ./ns exNS.tcl

Ex-

 
root@debian:/usr/local/ns-allinone-2.34/bin# ns /home/duminda/Desktop/NS/exNS.tcl
After run the tcl file using ns command

Do the simulation using NAM (The Network Animator)

Animation process
Run the simulation