0% found this document useful (0 votes)
98 views24 pages

Introduction To NS2: T S Pradeep Kumar VIT University-Chennai Campus

This document provides an overview and introduction to NS2 (Network Simulator 2). It discusses that NS2 is an open-source discrete event network simulator used to simulate TCP, routing, and multicast protocols over wired and wireless networks. It describes the NS2 architecture which consists of C++ code for internal operations and OTCL (Object-Oriented Tool Command Language) for the user interface, with TclCL providing the interface between them. It also provides examples of using OTCL to define classes and member functions for simulating objects in NS2.

Uploaded by

kiruthika
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
98 views24 pages

Introduction To NS2: T S Pradeep Kumar VIT University-Chennai Campus

This document provides an overview and introduction to NS2 (Network Simulator 2). It discusses that NS2 is an open-source discrete event network simulator used to simulate TCP, routing, and multicast protocols over wired and wireless networks. It describes the NS2 architecture which consists of C++ code for internal operations and OTCL (Object-Oriented Tool Command Language) for the user interface, with TclCL providing the interface between them. It also provides examples of using OTCL to define classes and member functions for simulating objects in NS2.

Uploaded by

kiruthika
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
You are on page 1/ 24

Introduction to NS2

T S Pradeep Kumar
VIT University- Chennai campus
http://www.pradeepkumar.org
[email protected]
Overview
•Linux Vs Windows
•Network Simulation
•Introduction to NS2
•About NS2
•NS2 Architecture
•OTCL
Versus

Linux for Windows for


NS2 NS2
Why not Windows?
•Support has been stopped
beyond NS-2.27
•Package Configuration is tedious
•Use NS2 at your own risk
• Verss
 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
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
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
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
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
Network Simulation
• Network Simulation

– Event Driven
• Every event provide a reference to the next event (Example: using
pointer)

A B C

• Simulation finishes
– When there are no more events
– At pre-specified time

TS PRADEEP KUMAR
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
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
TS PRADEEP KUMAR
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
NS2 Architecture

TS PRADEEP KUMAR
NS2 Architecture

TS PRADEEP KUMAR
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
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
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?"
}
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?"
}
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
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
Lets practice Linux for
sometime…..

TS PRADEEP KUMAR

You might also like