3. • Verss
Use Linux
Because….
✤Support has been stopped beyond
NS-2.27 in windows
✤Package Configuration is tedious in
windows
✤Use NS2 at your own risk in windows
✤Also now the recent architecture of
windows8x family is experiencing lot
of difficulties in tuning cygwin or
mingw.
3
4. Ò Linux for NS2
✕You may use any distributions like Ubuntu, Fedora, Linux
Mint, RHEL/CentOS, etc.
É Know basic commands (ls, chmod, tar, rpm, make, gedit, vi,
pwd, passwd, echo, cd, etc)
É Know the directory structure and shell prompt in linux and NS2
É Understand Path variables setting, Installation of packages and
dependencies for corresponding distribution.
4
5. Basic Linux Commands
✤ ls – to list the directory contents
✤ chmod – changing the mode of the file
✤ tar – tape archive (to compress or decompress)
✤ rpm – a type of installation file for linux
✤ make – to compile or recompile in linux
✤ gedit or vi – editors (similar like notepad)
✤ pwd - present working directory
✤ passwd – to change the user passwd
✤ echo – to echo to the screen
✤ cd – change directory
✤ mkdir – to create a directory
5
6. TS PRADEEP KUMAR
6
✤ To run the install file within the directory scope
✤ $prompt] ./install
✤ To run the install file in global scope is
✤ $prompt] install
Linux basics
7. TS PRADEEP KUMAR
✤ Approaches
✤ Experiment
✤ Put all network Devices and measure the results/performance
✤ Pros - realistic
✤ Cons - Expensive/Sometime impossible
✤ Mathematical model
✤ Model devices using a graph model
✤ Insight
✤ Need to make assumptions
✤ Simulation
✤ Use programming to represent devices
✤ Easy and can be easily verified
✤ Not much insight, need to make assumptions
Network Simulation
7
8. TS PRADEEP KUMAR
A B C
✤ Network Simulation
✤ Event Driven
✤ Every event provide a reference to the next event (Example: using
pointer)
✤ Simulation finishes
✤ When there are no more events
✤ At pre-specified time
8
Network Simulation
9. TS PRADEEP KUMAR
✤ NS is a discrete event simulator
✤ It provides support for
✤ Simulation of TCP
✤ Routing
✤ Huge number of protocols ranging from wired to wireless
networks
✤ Supports the addition of new entities like agent, packet,
application, queue, protocol, routing, etc.
9
About NS2
10. TS PRADEEP KUMAR
✤ NS2 is not a polished or a finished product
✤ Errors/Bugs are being discovered and corrected.
✤ Users of ns are requested to verify that the results are
not invalidated by bugs.
10
About NS2
11. TS PRADEEP KUMAR
✤ Network Simulator 2 is an event driven Simulator
✤ It consists of
✤ C++ (Internally)
✤ OTCL (User Interface)
✤ TclCL (Interface between C++ and OTCL)
11
NS2 Architecture
15. ✤ NS is a OTCL interpreter with network simulation
object libraries
✤ Relation between TCL & OTCL is similar to C & C++
✤ To run a Tcl File and animation file
✤ ns filename.tcl (or) tclsh filename.tcl
✤ nam filename.nam
15
OTCL
16. # Create a class call "mom" and add a member function call "greet"
Class mom
mom instproc greet {} {
$self instvar age_
puts "$age_ years old mom say:
How are you doing?"
}
16
OTCL Example
17. # Create a child class of "mom" called "kid" and overide
the member function "greet"
Class kid -superclass mom
kid instproc greet {} {
$self instvar age_
puts "$age_ years old kid say:
What's up, dude?"
}
17
OTCL Example
18. ✤ # Create a mom and a kid object set each age
✤ set a [new mom]
✤ $a set age_ 45
✤ set b [new kid]
✤ $b set age_ 15
✤ # Calling member function "greet" of each object
✤ $a greet
✤ $b greet
18
OTCL Example
19. To run the above file
✤ Open an Editor preferably gedit or Text Editor in Linux
✤ Type the program
✤ Mom Class
✤ Kid Class
✤ creation of object of both classes
✤ Run the File using
✤ ns momkid.tcl
19