4. Why not Windows?
• Verss
•Support has been stopped
beyond NS-2.27
•Package Configuration is tedious
•Use NS2 at your own risk
5.
Linux for NS2
Fedora (10, 12)
If DVD Version- no need of additional package installation
Install all the packages (if default installation selected, then additional packages have to be
installed)
Ubuntu (9.04, 9.10, 10.04, 10.10)
Additional packages to be installed, there may be GCC Issues, xgraph and NAM issues
Red Hat Enterprise Linux 5 (RHEL5)
Cent OS is the alternative for RHEL
Basic commands (ls, chmod, tar, rpm, make, gedit, vi, pwd, passwd, echo, cd, etc)
Directory structure and shell prompt
Path variables setting, Installation of packages and dependencies
6. 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
7. Linux basics
• To run the install file within the directory
scope
• $prompt] ./install
• To run the install file in global scope is
– $prompt] install
TS PRADEEP KUMAR
8. Network Simulation
• 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
TS PRADEEP KUMAR
9. Network Simulation
• Network Simulation
– Time Driven
• Events occurs within the interval is assumed to be
occur at the end of the interval
• Simulation finishes at a pre-specified time
• a, b,c,d are events
• a is assumed to occur at t=2Δ
TS PRADEEP KUMAR
10. Network Simulation
• Network Simulation
– Event Driven
• Every event provide a reference to the next event (Example: using
pointer)
A
B
• Simulation finishes
– When there are no more events
– At pre-specified time
TS PRADEEP KUMAR
C
11. About NS2
• NS is a discrete event simulator
• It provides support for
– Simulation of TCP
– Routing
– Multicast Protocols over Wired and Wireless
networks
TS PRADEEP KUMAR
12. About NS2
• NS is not a polished and finished product, but
the result of an on-going effort of research
and development.
• In particular, bugs in the software are still
being discovered and corrected.
• Users of ns are responsible for verifying for
themselves that their simulations are not
invalidated by bugs
TS PRADEEP KUMAR
14. NS2 Architecture
• Network Simulator 2 is an event driven
Simulator
• It consists of
– C++ (Internally)
– OTCL (User Interface)
– TclCL (Interface between C++ and OTCL)
TS PRADEEP KUMAR
18. OTCL
• NS is a OTCL interpreter with network
simulation object libraries
• Relation between TCL and OTCL is similar to C
and C++
• A Simple example follows..
• To run these examples
– ns filename.tcl (or) tclsh filename.tcl
19. TCL Example
# Writing a procedure called "test“
proc test {} {
set a 43
set b 27
set c [expr $a + $b]
set d [expr [expr $a - $b] * $c]
for {set k 0} {$k < 10} {incr k} {
if {$k < 5} {
puts "k < 5, pow = [expr pow($d, $k)]"
} else {
puts "k >= 5, mod = [expr $d % $k]"
}}}
# Calling the "test" procedure created above
test
20. OTCL Example
# 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?"
}
21. OTCL Example
# 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?"
}
22. OTCL Example
•
•
•
•
•
# 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
23. OTCL Example
• class keyword is used to create a class
• instproc is used to create a instance procedure
(define a member function)
• $self is similar to “this” in C++
• instvar checks if the variable is already declared in its
class or superclass. If the variable name given is
already declared, the variable is referenced, if not a
new one is declared