Introduction To NS2: - Network Simulator
Introduction To NS2: - Network Simulator
-Network Simulator-
/usr/local/ns-allinone-2.29.2/bin
/usr/local/ns-allinone-2.29.2/tcl8.4.11/unix
/usr/local/ns-allinone-2.29.2/tk8.4.11/unix
How to Install
Go to cygwin and type the following
content
Export LD_LIBRARY_PATH=/usr/local/ns-
allinone-2.29/otcl-1.11
Export LD_LIBRARY_PATH=/usr/local/ns-
allinone-2.29/lib
Export TCL_LIBRARY_PATH=/usr/local/ns-
allinone-2.29/tcl8.4.11/library
How to Install
OTcl – The User Language
NS2 is basically an OTcl interpreter with network
simulation object libraries
Very simple syntax and easy integration with
other languages.
Characteristics:
- fast development
- provide graphic interface
- compatible with many platforms
- flexible for integration
- easy to use
- free
OTcl – The User Language
Example
OTcl – The User Language
Proc: define a procedure, followed by an
procedure name and arguments
Set: assign a value to a variable
[expr …]: to make the interpreter calculate
the value of expression within the bracket
To assign to variable x the value that
variable a has, then write “set x $a”.
Put: prints out
OTcl – The User Language
Event Scheduler
Main users of an event scheduler are network components that
simulate packet-handling delay or that need time
Event Scheduler
Two different types of event schedulers
- real time: for emulation which allow the
simulator to interact with a real network
- non-real time: three implementations are
available (Heap, List, Calendar). The
default is set as Calendar
Event Scheduler
Example
...
set ns [new Simulator]
$ns use-scheduler Heap
...
...
set ns [new Simulator]
$ns use-scheduler Heap
$ns at 300.5 "complete_sim"
...
proc complete_sim {} {
...
}
Packet
NS2 packet is composed of a stack of
headers and optional dataspace.
Packet format is initialized when a
Simulator object is created. So, a network
object can access any header in the stack
of a packet it processes using
corresponding offset value.
Packet
Simple Simulation Implement
Simple Simulation Implement
Simple Simulation Implement
Clickon desktop icon “cygwin”
Make sure to put the exe files under
C:\cygwin\usr\local
Do the following steps to execute
example.
Simple Simulation Implement
Simple Simulation Implement
However you will fail to run the “ns-simple.tcl” with the displayed
notice. This is because you did not open “XWin” yet
Simple Simulation Implement
Open “Xwin” from “C:\cygwin\usr\X11R6\bin”. If everything is fine,
you will then get the following figures.
Simple Simulation Implement
Yet you may get the following warning messages:
Simple Simulation Implement
That means some components missed. You can then copy these
files from “C:\cygwin\bin” to “C:\cygwin\usr\X11R6\bin”
After you open X11, you may still can not run “ns-simple.tcl”
Simple Simulation Implement
The following command can solve this
issue
export DISPLAY=:0.0
Simple Simulation Implement
Simple Simulation Implement
Run “ns-simple.tcl”
Simple Simulation Implement
DONE !!!
Simple Simulation Implement
Thank You….