CS 258 NS-2 Tutorial Last Update: Oct. 2001
Edited By Ms. Hong Li
1.
NS Overview
NS is a discrete event simulator targeted at networking research. NS provides substantial support for simulation of TCP, routing, and multicast protocols over wired and wireless (local and satellite) networks.
NS
began as a variant of the REAL network simulator in 1989 and has evolved
substantially over the past few years. NS is open source package that has
always included substantial contributions from other researchers.
2.
NS Installation
·
Version
NS evolves through version 1, version 2, and the
most up-to-date version is 2.1b8a. The versions available to download on NS
page are from 2.1b3 to 2.1b8a for all-in-one package. You may download any
version that is best fit your need. The newer the version is, the more modules
and features it has. But it does not mean the newer, the better -- you may not
need the newly added parts at all.
For NS source core, you could get as early as
version 2.0(which is rarely used now). Link
to download version 1 of NS is also there in case some researchers may need to
use that version.
·
Platform
NS supports Unix (FreeBSD, SunOS, Solaris), Linux,
and Windows-95/98/2000/NT. Unix is highly preferred, since you will experience
less problems in using NS2 on Unix than on Windows.
·
Components
q
Tcl
release 8.3.2 (required component)
q
Tk
release 8.3.2 (required component)
q
Otcl
release 1.0a7 (required component)
q
TclCL
release 1.0b11 (required component): simulation interface
q
NS
release 2.1b8a (required component): simulation code core
q
Nam
release 1.0a10 (optional component): animation tool
q
Xgraph
version 12 (optional component): graphic tool
q
CWeb
version 3.4g (optional component)
q
SGB
version 1.0 (?) (optional component, builds sgblib for all UNIX type platforms)
q
Gt-itm
gt-itm and sgb2ns 1.1 (optional component):
build complex topology
q
Zlib
version 1.1.3 (optional, but required should Nam be used)
·
Requirements
To build NS you need a computer and a C++ compiler.
NS is fairly large. The all-in-one package requires about 250MB of disk space
to be built. Building NS from pieces can save some disk space.
3.
NS Functions
·
Creating the event scheduler
·
Creating network
·
Computing routes
·
Creating connection
·
Create queuing scheme
·
Creating traffic
·
Inserting errors
·
Tracing
4.
NS Development
·
C++ and Otcl Separation
q
C++
is for data and per packet action. The overhead of modifying C++ code is more compared to that of script
languages.
q
Otcl is for control and periodic or
triggered action. Otcl is interpreting language and script driven, so it is
easy to change.
q
The advantage to have 2 languages is to
achieve compromise between composibility and speed.
q
The disadvantage to have 2 languages is long
learning curve and hard to debug.
·
Getting Start with NS
q
NS
is a large and complicated package. Before changing it, you must get some level
of knowledge and understanding of it. Instead of jumping into the detail
immediately, it’s better to stand at a higher position, and look at its
architecture and design strategy first. Otherwise, you will be easily
overwhelmed by tremendous details. At the beginning, it might be painful, but
you will like it after you master NS’s spirit.
q
To start and get some intuitive sense of NS,
you could run some sample scripts, from simple ones to complicate ones. The
ones with Nam animation might give you more feeling on NS. You could also run
the samples in the area you are especially interested in.
q
To learn NS, NS tutorials on the web are
good resource. They walk you through the key NS development processes in an
incremental way, and educate you about key concepts in NS. They could help you
get basic understanding in a short period time.
q
After preparing you with basic knowledge of
NS, studying NS manual is an important and inevitable step if you want to make
your own agents and complicated simulation schemes.
q
NS is open source and used by many
researchers who already built up rich knowledge and experience with NS. They
would like to share their experience and help each other. To get help from them
and learn the lessons from other people’s experience, you could subscribe NS
mailing list.
·
Making Changes in NS
q
C++
makes the core part of NS. In NS, C++ objects have hierarchical and cross
relations among each other. Changing in one part might have potential impact on
other parts, so it has to be very careful. To add new C++ program or class in
NS, you need to change the Makefile and recompile it. To change existing C++
code, you always need to recompile it.
q
Otcl is a script language. The overhead to
change it is less compared to changing C++ code. To add new Otcl program or class in NS Otcl
library, you need to source it, change the Makefile and recompile it, but to
add your own testing Otcl scripts, you could directly run it without changing
Makefile and recompiling them. To change existing Otcl code, you always need to
recompile, and might source them if necessary. But to change your test scripts,
most of the time you can directly run it.
·
Directory Structure
Getting familiar with NS directory structure is the
basic requirement for NS development.
·
Class Structure
Getting familiar with NS class structure is the
basic requirement if you need do complex NS development such as create a new
agent.
5.
Reference and Useful NS URLs
·
http://www.isi.edu/nsnam/ns/ns-build.html
·
http://www.isi.edu/nsnam/dist/
·
http://www.isi.edu/nsnam/ns/ns-tests.html
·
http://www.isi.edu/nsnam/ns/
·
http://www.isi.edu/nsnam/ns/tutorial/index.html
·
http://nile.wpi.edu/NS/
·
http://www.isi.edu/nsnam/ns/ns-documentation.html
·
http://www.isi.edu/nsnam/ns/ns-tutorial/index.html
6.
Other Simulation Tools
·
Active Network Simulator
q
On
current networks, packets are Not-So- Smart, all packets are treated
identically and network is rigid, relatively passive; On active networks, packets
are Smart, they contain their own handling instructions and network is hollow
flexible.
q
Active
Network Reliable Multicast Simulation -- This package contains C++ and tcl
files that have been modified to support reliable multicast using active
processing at intermediate nodes within a multicast tree. An example tcl script
demonstrates multicast repair server functionality at active agents.
q
Active
Network Active Error Recovery/Nominee-based Congestion Algorithm Protocol
Simulation -- This package contains C++/tcl files for LBNL NS version 2 and a
tcl script which demonstrates features of the AER/NCA protocol.
q
Reference
http://www.tascnets.com/newtascnets/Software/Documents/Main.html
·
JavaSim Simulator
q
JavaSim
has been developed entirely in Java. This, coupled with the autonomous
component architecture, makes JavaSim a truly platform-neutral, extensible, and
reusable environment. JavaSim also provides a script interface to allow
integration with different script languages such as Perl, Tcl. In the current
release, JavaSim has been integrated with a Java implementation of the Tcl. So,
similar to NS-2, JavaSim is a dual-language simulation environment in which
classes are written in Java (for NS-2, in C++) and "glued" together
using Tcl/Java. However, unlike NS-2, classes/methods/fields in Java need not
be explicitly exported in order to be accessed in the Tcl environment. Instead,
all the public classes/methods/fields in Java can be accessed (naturally) in
the Tcl environment.
q Reference
http://javasim.cs.uiuc.edu/index.html
http://javasim.cs.uiuc.edu/tutorial/javasim_tutorial.html