<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
Simulation of Networks
Guidelines for the ns network simulator tool on Windows platform
Introduction
ns is an event-driven network simulator that has been developed at University of California Berkeley. The simulation engine of ns is implemented in C++ and uses the Object oriented version of Tool Command Language (OTcl) as its front-end. Accessing the ns library through this front-end is thus possible with commands or scripts that are written in the Tcl language.
With an interpreter style of code execution, the ns program interprets each line of user script in a Tcl program during execution time and produces the output in the form of a formatted text file. Post-processing is performed in order to filter particular data throughout the simulation time. Tools are required, such as gnuplot as to create graphs or nam as to display an animated visualization of the ns simulations.
Ns works best under unix/linux – there is a windows version
that you can play with on your home pc, it is useful for learning ns, but
doesn’t work as well as it should. However, there is some windows-based
information below, as well as some generic ns stuff.
|
The main page of ns is at: |
|
|
The main page of nam is at: |
|
|
The ns mailing list archive is at: |
Windows Download
|
ns - binary windows version |
|
|
nam - binary windows version |
|
|
Tcl/Tk |
|
|
gnuplot - windows version |
Installation
For ns and nam:
For gnuplot :
Program Execution
·
Open an MS-DOS
window.
· Change to the directory that keeps your own ns programs by typing a DOS command such as "cd my_directory".
· Type a command like "c:\ns2\ns my_program.tcl" to activate the ns program in the c:\ns2\ directory for executing your program (my_program.tcl) in the current directory.
·
To avoid this cumbersome form of command, the DOS
command "path" should be issued once at the DOS prompt.
For example:
· path =%path%;c:\ns2\;c:\nam\;c:\gnuplot\gp37w16
Then, a command to activate either ns program or tools becomes:
· ns my_program.tcl or
· nam my_nam.out
· wgnuplot my_gnuplot_srcipt.gp
Verification
· Copy the example script file of simple.tcl and run ns with it as input.
· The following should appear on the DOS window:
|
Trace files opened… CBR traffic starts at time 1.1 sec… |
In order to view an animation of the simulation results:
· run nam with the file out.nam as input.
· A nam window like the picture below should pop up. A circle represents a node and a line represents a link.
· Press the run button, and you will see an animation of the simulation - with many packets being transported on the link at various times as specified by the ns script.

Documentation
·
The 350-page ns-documentation
is available in html, postscript or pdf format at
http://www.isi.edu/nsnam/ns/ns-documentation.html
·
The user guide for gnuplot
is available at
ftp://ftp.dartmouth.edu/pub/gnuplot
Tutorial
· For a novice, it is strongly recommended to read Marc Greis 's ns tutorial, which is available at http://www.isi.edu/nsnam/ns/tutorial/index.html
· Homework in the subject of computer networks at various universities, e.g.:
·
CS 268: Computer Networks in Computer Science
Department of UC-Bekeley
[Spring 97] http://www-mash.cs.berkeley.edu/cs268-s97/
[Spring 98] http://www-mash.cs.berkeley.edu/cs268-s98/
· http://www.docs.uu.se/~perg/course/datakom2/it98/tcpsims_lab.html
Examples of application
· Lots of examples and ns applications in various fields of computer network and telecommunication can be found in the directory \ns2-1b5\tcl\ex of the full souce-code version of ns.
· Any text-based editor can be used to edit the tcl files.
Brief overview of the Tcl language
|
Tcl command |
Meaning |
Remarks |
|
Assignment statement |
||
|
set a 1 |
assign variable a with value of
1 |
No previous variable declaration is
required. |
|
set b $a |
assign the value from variable a to
(newly-created) variable b |
Since variable a is already declared,
this variable should be accessed with the $ sign. |
|
Arithmetic statement |
||
|
set c [expr 1 / 3.0] |
Assign the result from expression 1 /
3.0 to the variable c |
|
|
Print statement |
||
|
puts "Hello" |
Display message "Hello" on
the screen. |
|
|
puts $b |
Display the value of variable b on
the screen. |
|
|
puts $f "Hello" |
Print message "Hello" to
the f variable |
In this case, f is a file variable
and should be declared in the previous part of program with the command: |
|
Comment statement |
||
|
# bla bla ... |
All characters following the # sign
are treated as comments |
Possible to lead with the semicolon
sign and put at end of line for comment operation on that line. |
|
IF-ELSE statement |
||
|
If { $a == 1 } { |
Check whether variable a is equal to
1, if yes display EQ, otherwise display NEQ. |
|
|
Procedure/Function
statement |
||
|
proc my_sum { v1 v2 } { |
The procedure named my_sum requires 2
variables (i.e. v1 and v2). |
|
W. Suntorn wsuntorn@swin.edu.au 22
Nov 1999
Updated: David Everitt deveritt@it.usyd.edu.au
29 August 2002