SlideShare a Scribd company logo
1
NS--2 IntroductionIntroduction
byby
Venkatamangarao NampallyVenkatamangarao Nampally
KattangurKattangur
2
OutlineOutline
• BackgroundBackground
• ArchitectureArchitecture
• UsageUsage
• SimulationSimulation
• NS-programmingNS-programming
• ExampleExample
• SummarySummary
3
ns-2, the Network Simulatorns-2, the Network Simulator
• AA discrete event simulatordiscrete event simulator modellingmodelling
network protocolsnetwork protocols
– Packets, links, queues, protocolsPackets, links, queues, protocols
– Visualizer (Visualizer (NAMNAM))
– Trace playbackTrace playback
– Error modelsError models
• Targeted at networking researchTargeted at networking research
• Supports for all types of simulationsSupports for all types of simulations
4
HistoryHistory
• 1989:1989: REALREAL by Keshavby Keshav
• 1995:1995: nsns by Floyd, McCanne at LBLby Floyd, McCanne at LBL
• 1997:1997: ns-2ns-2 by the VINT projectby the VINT project
((Virtual InterNetwork TestbedVirtual InterNetwork Testbed) at) at
LBL, Xerox PARC, UCB, USC/ISILBL, Xerox PARC, UCB, USC/ISI
• 1999: Wireless models added @ CMU1999: Wireless models added @ CMU
• Now:Now: ns-2.29ns-2.29 maintained at USC/ISImaintained at USC/ISI
– ns-2.30ns-2.30 pending releasepending release
NS-2 OverviewNS-2 Overview
• TCP/IP NS2 OSI 7-LayerTCP/IP NS2 OSI 7-Layer
5
•Application
•Presentation
•Session
•Transport
•Network
•Data Link
•Physical
•Application
•Agent
•Node
•Link
•Application
•TCP/UDP
•IP
•Network
•Access
Platforms SupportedPlatforms Supported
• Most UNIX and UNIX-like systemsMost UNIX and UNIX-like systems
 FreeBSDFreeBSD
 LinuxLinux
 SolarisSolaris
• Windows 98/2000/2003/XPWindows 98/2000/2003/XP
– Cygwin requiredCygwin required
– Some work , some doesntSome work , some doesnt
6
User’s PerspectiveUser’s Perspective
• From the user’s perspective, NS−2 isFrom the user’s perspective, NS−2 is
an OTcl interpreter that takes an OTclan OTcl interpreter that takes an OTcl
script as input and produces a tracescript as input and produces a trace
file as output.file as output.
7
8
NS-2 EnvironmentNS-2 Environment
•Simulation
Scenario
•Tcl Script
•C++
Implementation
•1 •2
•set ns_ [new Simulator]
•set node_(0) [$ns_ node]
•set node_(1) [$ns_ node]
•class MobileNode : public Node
•{
• friend class PositionHandler;
•public:
• MobileNode();
• •
• •
•}
9
ComponentsComponents
• ns-2ns-2, the simulator itself, the simulator itself
– Specify simulation, generate tracesSpecify simulation, generate traces
– Depends on Tcl/Tk, OTcl, TclCLDepends on Tcl/Tk, OTcl, TclCL
• namnam, the network animator, the network animator
– Animate traces from simulationAnimate traces from simulation
– GUI for constructing simple simulationsGUI for constructing simple simulations
• Pre-processingPre-processing
– Traffic, topology generationTraffic, topology generation
• Post-processingPost-processing
– Analyse trace output withAnalyse trace output with awkawk, etc, etc
NS ModelsNS Models
• Traffic models and applications:Traffic models and applications:
– Web, FTP, telnet, constant-bit rateWeb, FTP, telnet, constant-bit rate
• Transport protocols:Transport protocols:
– unicast: TCP (Reno, Vegas, etc.), UDPunicast: TCP (Reno, Vegas, etc.), UDP
– Multicast: SRMMulticast: SRM
• Routing and queueing:Routing and queueing:
– Wired routing, ad hoc rtgWired routing, ad hoc rtg
– queueing protocols: RED, drop-tail, etcqueueing protocols: RED, drop-tail, etc
• Physical media:Physical media:
– Wired (point-to-point, LANs), wirelessWired (point-to-point, LANs), wireless
(multiple propagation models), satellite(multiple propagation models), satellite
10
Basic ArchitectureBasic Architecture
11
•An executable command ns
•Input: tcl simulation scripting file
•Output: trace file  Animation by NAM or
plotting graph by Xgraph (gunplot)
NS2-GoalsNS2-Goals
To support networking research andTo support networking research and
educationeducation
–– Protocol design, traffic studies, etc.Protocol design, traffic studies, etc.
–– Protocol comparison;Protocol comparison;
–– New architecture designs are alsoNew architecture designs are also
supported.supported.
•• To provideTo provide collaborativecollaborative environmentenvironment
–– Freely distributed, open source;Freely distributed, open source;
–– Increase confidenceIncrease confidence in resultin result
12
13
UsingUsing nsns
Simulation
model
Define
problem
Post-process
results
Execute
simulation
Extend
simulator
14
UsingUsing nsns
• Create simulationCreate simulation
– Describe network, protocols, sources, sinksDescribe network, protocols, sources, sinks
– Interface via OTcl which controls C++Interface via OTcl which controls C++
• Execute simulationExecute simulation
– Simulator maintains event list (packet list), executesSimulator maintains event list (packet list), executes
next event (packet), repeats until donenext event (packet), repeats until done
– Events happen instantly inEvents happen instantly in virtual timevirtual time but could takebut could take
arbitrarily longarbitrarily long real timereal time
– Single thread of control, no locking, races, etcSingle thread of control, no locking, races, etc
• Post-process resultsPost-process results
– Scripts (awk, perl, python) to process text outputScripts (awk, perl, python) to process text output
– No standard library but some available on webNo standard library but some available on web
15
LanguagesLanguages
• C++ forC++ for datadata
– Per-packet processing, the core ofPer-packet processing, the core of nsns
– Fast to run, detailed, complete controlFast to run, detailed, complete control
• OTcl forOTcl for controlcontrol
– Simulation descriptionSimulation description
– Periodic or triggered actionsPeriodic or triggered actions
– Manipulating existing C++ objectsManipulating existing C++ objects
– Faster to write and change codeFaster to write and change code
» (a matter of opinion)(a matter of opinion)
16
Basic TclBasic Tcl
# Variables:# Variables:
setset x 10x 10
setset xx
putsputs “x is $x”“x is $x”
# Functions and expressions:# Functions and expressions:
setset y [pow x 2]y [pow x 2]
setset y [expr x*x]y [expr x*x]
# Control flow:# Control flow:
ifif {$x > 0} {{$x > 0} { returnreturn $x }$x } elseelse {{
returnreturn [expr -$x] }[expr -$x] }
whilewhile { $x > 0 } {{ $x > 0 } {
putsputs $x$x
incrincr x –1x –1
}}
forfor {{setset i 0} {$i<10} {i 0} {$i<10} {incrincr i} {i} {
putsputs “$i == $i”“$i == $i”
}}
# Procedures:# Procedures:
procproc pow {x n} {pow {x n} {
ifif {$n == 1} {{$n == 1} { returnreturn $x }$x }
setset part [part [powpow x [x [exprexpr $n-1]]$n-1]]
returnreturn [[exprexpr $x*$part]$x*$part]
}}
# Files:# Files:
setset file [file [open “open “nstrace.txt” w]nstrace.txt” w]
setset line [line [getsgets $file]$file]
puts –nonewlineputs –nonewline $file “hello!”$file “hello!”
closeclose $file$file
17
App1
Agent1
App2
Agent2
Node
From Network to SimulationFrom Network to Simulation
Application,
Agent & Node
LinkNode
App1
Agent1
App2
Agent2
Node
App1
Agent1
App2
Agent2
Node
App1
Agent1
App2
Agent2
Node
Node Node Node
Link
Link
Link Link
Link
Link
Link
Link
App1
Agent1
App2
Agent2
Node
App1
Agent1
App2
Agent2
Node
Visualization ToolsVisualization Tools
18
•nam-1 (Network AniMator Version 1)
•Packet-level animation
•Well supported by ns
•xgraph
•Simulation results
NAMNAM
19
Elements for NS-2 simulationElements for NS-2 simulation
20
•Create the event scheduler
•Turn on tracing
•Create network
•Setup routing
•Create transport connection
•Create traffic
•Transmit application-level data
Creating Simulation environmentCreating Simulation environment
21
 Create event scheduler
 set ns [new Simulator]
 Schedule events
 $ns at <time> <event>
 <event>: any legitimate ns/tcl commands
 Start scheduler
 $ns run
TracingTracing
22
 Turn on tracing on specific links
 $ns trace-queue $n0 $n1
 $ns namtrace-queue $n0 $n1
Creating nodes, links and queuesCreating nodes, links and queues
23
 Nodes
 set n0 [$ns node]
 set n1 [$ns node]
 Links and queuing
 $ns duplex-link $n0 $n1 <bandwidth> <delay>
<queue_type>
 <queue_type>: DropTail, RED, CBQ, FQ, SFQ,
DRR
Creating connection :UDPCreating connection :UDP
24
 UDP
 set udp [new Agent/UDP]
 set null [new Agent/Null]
 $ns attach-agent $n0 $udp
 $ns attach-agent $n1 $null
 $ns connect $udp $null
Creating Traffic : on top of UDPCreating Traffic : on top of UDP
25
 CBR
 set src [new
Application/Traffic/CBR]
Creating connection : TCPCreating connection : TCP
26
 TCP
 set tcp [new Agent/TCP]
 set tcpsink [new Agent/TCPSink]
 $ns attach-agent $n0 $tcp
 $ns attach-agent $n1 $tcpsink
 $ns connect $tcp $tcpsink
Creating Traffic : on top of TCPCreating Traffic : on top of TCP
27
 FTP
 set ftp [new Application/FTP]
 $ftp attach-agent $tcp
 Telnet
 set telnet [new
Application/Telnet]
 $telnet attach-agent $tcp
Simple Simulation ExampleSimple Simulation Example
28
•This network consists of 4 nodes (n0, n1, n2, n3)
•The duplex links between n0 and n2, and n1 and n2 have
•The duplex link between n2 and n3 has 1.7 Mbps of bandwidth and 20 ms of
delay 2 Mbps of bandwidth and 10 ms of delay.
•Each node uses a DropTail queue,of which the maximum size is 10
•ftp session is based on tcp
•tcp agent: generate packet (l=1k bytes)
•sink: generate ack and free packets
•cbr session is based on udp
•udp agent: generate packet (l=1k bytes)
@ 1 Mbps
•null: free packets
Script structureScript structure
29
# parameters and options
set ns [new Simulator]
# [Turn on tracing]
# Create topology
# Setup packet loss, link dynamics
# Create routing agents
# Create:
# - protocol agents
# - application and/or setup traffic sources
# Post-processing procs
# Start simulation
Final Topology Generated (final screenshot)Final Topology Generated (final screenshot)
30
31
SummarySummary
• BackgroundBackground
• ArchitectureArchitecture
• UsageUsage
• SimulationSimulation
• NS-programmingNS-programming
• ExampleExample
• SummarySummary
32
Thank You!Thank You!

More Related Content

What's hot

Network simulator 2
Network simulator 2Network simulator 2
Network simulator 2
Pradeep Kumar TS
 
Working with NS2
Working with NS2Working with NS2
Working with NS2
chanchal214
 
Ns2
Ns2Ns2
Network Simulator Tutorial
Network Simulator TutorialNetwork Simulator Tutorial
Network Simulator Tutorial
cscarcas
 
Ns2
Ns2Ns2
Ns 2 Network Simulator An Introduction
Ns 2 Network Simulator An IntroductionNs 2 Network Simulator An Introduction
Ns 2 Network Simulator An Introduction
Jaipur National University, Jaipur, Rajasthan, India
 
Ns network simulator
Ns network simulatorNs network simulator
Ns network simulator
Dr. Edwin Hernandez
 
Profiling Ruby
Profiling RubyProfiling Ruby
Profiling Ruby
Ian Pointer
 
Ns2 introduction 2
Ns2 introduction 2Ns2 introduction 2
Ns2 introduction 2
Rohini Sharma
 
Ns2
Ns2Ns2
Ns2programs
Ns2programsNs2programs
Ns2programs
Meenakshi Devi
 
Ns fundamentals 1
Ns fundamentals 1Ns fundamentals 1
Ns fundamentals 1
narmada alaparthi
 
Introduction to ns2
Introduction to ns2Introduction to ns2
Introduction to ns2
Pradeep Kumar TS
 
Cs757 ns2-tutorial-exercise
Cs757 ns2-tutorial-exerciseCs757 ns2-tutorial-exercise
Cs757 ns2-tutorial-exercise
Pratik Joshi
 
Simulation and Performance Analysis of AODV using NS-2.34
Simulation and Performance Analysis of AODV using NS-2.34Simulation and Performance Analysis of AODV using NS-2.34
Simulation and Performance Analysis of AODV using NS-2.34
Shaikhul Islam Chowdhury
 
Новый InterSystems: open-source, митапы, хакатоны
Новый InterSystems: open-source, митапы, хакатоныНовый InterSystems: open-source, митапы, хакатоны
Новый InterSystems: open-source, митапы, хакатоны
Timur Safin
 
Real-time streams and logs with Storm and Kafka
Real-time streams and logs with Storm and KafkaReal-time streams and logs with Storm and Kafka
Real-time streams and logs with Storm and Kafka
Andrew Montalenti
 
A22 Introduction to DTrace by Kyle Hailey
A22 Introduction to DTrace by Kyle HaileyA22 Introduction to DTrace by Kyle Hailey
A22 Introduction to DTrace by Kyle Hailey
Insight Technology, Inc.
 
Rust "Hot or Not" at Sioux
Rust "Hot or Not" at SiouxRust "Hot or Not" at Sioux
Rust "Hot or Not" at Sioux
nikomatsakis
 
Network Simulation
Network SimulationNetwork Simulation
Network Simulation
lohch3
 

What's hot (20)

Network simulator 2
Network simulator 2Network simulator 2
Network simulator 2
 
Working with NS2
Working with NS2Working with NS2
Working with NS2
 
Ns2
Ns2Ns2
Ns2
 
Network Simulator Tutorial
Network Simulator TutorialNetwork Simulator Tutorial
Network Simulator Tutorial
 
Ns2
Ns2Ns2
Ns2
 
Ns 2 Network Simulator An Introduction
Ns 2 Network Simulator An IntroductionNs 2 Network Simulator An Introduction
Ns 2 Network Simulator An Introduction
 
Ns network simulator
Ns network simulatorNs network simulator
Ns network simulator
 
Profiling Ruby
Profiling RubyProfiling Ruby
Profiling Ruby
 
Ns2 introduction 2
Ns2 introduction 2Ns2 introduction 2
Ns2 introduction 2
 
Ns2
Ns2Ns2
Ns2
 
Ns2programs
Ns2programsNs2programs
Ns2programs
 
Ns fundamentals 1
Ns fundamentals 1Ns fundamentals 1
Ns fundamentals 1
 
Introduction to ns2
Introduction to ns2Introduction to ns2
Introduction to ns2
 
Cs757 ns2-tutorial-exercise
Cs757 ns2-tutorial-exerciseCs757 ns2-tutorial-exercise
Cs757 ns2-tutorial-exercise
 
Simulation and Performance Analysis of AODV using NS-2.34
Simulation and Performance Analysis of AODV using NS-2.34Simulation and Performance Analysis of AODV using NS-2.34
Simulation and Performance Analysis of AODV using NS-2.34
 
Новый InterSystems: open-source, митапы, хакатоны
Новый InterSystems: open-source, митапы, хакатоныНовый InterSystems: open-source, митапы, хакатоны
Новый InterSystems: open-source, митапы, хакатоны
 
Real-time streams and logs with Storm and Kafka
Real-time streams and logs with Storm and KafkaReal-time streams and logs with Storm and Kafka
Real-time streams and logs with Storm and Kafka
 
A22 Introduction to DTrace by Kyle Hailey
A22 Introduction to DTrace by Kyle HaileyA22 Introduction to DTrace by Kyle Hailey
A22 Introduction to DTrace by Kyle Hailey
 
Rust "Hot or Not" at Sioux
Rust "Hot or Not" at SiouxRust "Hot or Not" at Sioux
Rust "Hot or Not" at Sioux
 
Network Simulation
Network SimulationNetwork Simulation
Network Simulation
 

Similar to Venkat ns2

Ns2pre
Ns2preNs2pre
Ns2pre
Pratik Joshi
 
Introduction to ns2
Introduction to ns2Introduction to ns2
Introduction to ns2
ProfDrSharadSharma
 
NS2-tutorial.pdf
NS2-tutorial.pdfNS2-tutorial.pdf
NS2-tutorial.pdf
srinivasa gowda
 
NS2-tutorial.ppt
NS2-tutorial.pptNS2-tutorial.ppt
NS2-tutorial.ppt
Wajath
 
Network simulator 2
Network simulator 2Network simulator 2
Network simulator 2
AAKASH S
 
Network simulator 2
Network simulator 2Network simulator 2
Network simulator 2
AAKASH S
 
Ns2
Ns2Ns2
Ns2
namitay
 
Ns2 by khan
Ns2 by khan Ns2 by khan
Ns tutorial
Ns tutorialNs tutorial
Ns tutorial
SAMMMATHEW
 
LF_OVS_17_OVS/OVS-DPDK connection tracking for Mobile usecases
LF_OVS_17_OVS/OVS-DPDK connection tracking for Mobile usecasesLF_OVS_17_OVS/OVS-DPDK connection tracking for Mobile usecases
LF_OVS_17_OVS/OVS-DPDK connection tracking for Mobile usecases
LF_OpenvSwitch
 
The Art of Grey-Box Attack
The Art of Grey-Box AttackThe Art of Grey-Box Attack
The Art of Grey-Box Attack
Prathan Phongthiproek
 
Ns2 ns3 training in mohali
Ns2 ns3 training in mohaliNs2 ns3 training in mohali
Ns2 ns3 training in mohali
Arwinder paul singh
 
study-of-network-simulator.pdf
study-of-network-simulator.pdfstudy-of-network-simulator.pdf
study-of-network-simulator.pdf
Jayaprasanna4
 
Dc project 1
Dc project 1Dc project 1
Dc project 1
shwetha mk
 
Protocol T50: Five months later... So what?
Protocol T50: Five months later... So what?Protocol T50: Five months later... So what?
Protocol T50: Five months later... So what?
Nelson Brito
 
Wuala, P2P Online Storage
Wuala, P2P Online StorageWuala, P2P Online Storage
Wuala, P2P Online Storage
adunne
 
cscn1819.pdf
cscn1819.pdfcscn1819.pdf
cscn1819.pdf
Anil Sagar
 
ns2-lecture.ppt
ns2-lecture.pptns2-lecture.ppt
ns2-lecture.ppt
AnniModgil
 
Capturing NIC and Kernel TX and RX Timestamps for Packets in Go
Capturing NIC and Kernel TX and RX Timestamps for Packets in GoCapturing NIC and Kernel TX and RX Timestamps for Packets in Go
Capturing NIC and Kernel TX and RX Timestamps for Packets in Go
ScyllaDB
 
18CSL51 - Network Lab Manual.pdf
18CSL51 - Network Lab Manual.pdf18CSL51 - Network Lab Manual.pdf
18CSL51 - Network Lab Manual.pdf
Selvaraj Seerangan
 

Similar to Venkat ns2 (20)

Ns2pre
Ns2preNs2pre
Ns2pre
 
Introduction to ns2
Introduction to ns2Introduction to ns2
Introduction to ns2
 
NS2-tutorial.pdf
NS2-tutorial.pdfNS2-tutorial.pdf
NS2-tutorial.pdf
 
NS2-tutorial.ppt
NS2-tutorial.pptNS2-tutorial.ppt
NS2-tutorial.ppt
 
Network simulator 2
Network simulator 2Network simulator 2
Network simulator 2
 
Network simulator 2
Network simulator 2Network simulator 2
Network simulator 2
 
Ns2
Ns2Ns2
Ns2
 
Ns2 by khan
Ns2 by khan Ns2 by khan
Ns2 by khan
 
Ns tutorial
Ns tutorialNs tutorial
Ns tutorial
 
LF_OVS_17_OVS/OVS-DPDK connection tracking for Mobile usecases
LF_OVS_17_OVS/OVS-DPDK connection tracking for Mobile usecasesLF_OVS_17_OVS/OVS-DPDK connection tracking for Mobile usecases
LF_OVS_17_OVS/OVS-DPDK connection tracking for Mobile usecases
 
The Art of Grey-Box Attack
The Art of Grey-Box AttackThe Art of Grey-Box Attack
The Art of Grey-Box Attack
 
Ns2 ns3 training in mohali
Ns2 ns3 training in mohaliNs2 ns3 training in mohali
Ns2 ns3 training in mohali
 
study-of-network-simulator.pdf
study-of-network-simulator.pdfstudy-of-network-simulator.pdf
study-of-network-simulator.pdf
 
Dc project 1
Dc project 1Dc project 1
Dc project 1
 
Protocol T50: Five months later... So what?
Protocol T50: Five months later... So what?Protocol T50: Five months later... So what?
Protocol T50: Five months later... So what?
 
Wuala, P2P Online Storage
Wuala, P2P Online StorageWuala, P2P Online Storage
Wuala, P2P Online Storage
 
cscn1819.pdf
cscn1819.pdfcscn1819.pdf
cscn1819.pdf
 
ns2-lecture.ppt
ns2-lecture.pptns2-lecture.ppt
ns2-lecture.ppt
 
Capturing NIC and Kernel TX and RX Timestamps for Packets in Go
Capturing NIC and Kernel TX and RX Timestamps for Packets in GoCapturing NIC and Kernel TX and RX Timestamps for Packets in Go
Capturing NIC and Kernel TX and RX Timestamps for Packets in Go
 
18CSL51 - Network Lab Manual.pdf
18CSL51 - Network Lab Manual.pdf18CSL51 - Network Lab Manual.pdf
18CSL51 - Network Lab Manual.pdf
 

Recently uploaded

Immersive Learning That Works: Research Grounding and Paths Forward
Immersive Learning That Works: Research Grounding and Paths ForwardImmersive Learning That Works: Research Grounding and Paths Forward
Immersive Learning That Works: Research Grounding and Paths Forward
Leonel Morgado
 
Phenomics assisted breeding in crop improvement
Phenomics assisted breeding in crop improvementPhenomics assisted breeding in crop improvement
Phenomics assisted breeding in crop improvement
IshaGoswami9
 
原版制作(carleton毕业证书)卡尔顿大学毕业证硕士文凭原版一模一样
原版制作(carleton毕业证书)卡尔顿大学毕业证硕士文凭原版一模一样原版制作(carleton毕业证书)卡尔顿大学毕业证硕士文凭原版一模一样
原版制作(carleton毕业证书)卡尔顿大学毕业证硕士文凭原版一模一样
yqqaatn0
 
SAR of Medicinal Chemistry 1st by dk.pdf
SAR of Medicinal Chemistry 1st by dk.pdfSAR of Medicinal Chemistry 1st by dk.pdf
SAR of Medicinal Chemistry 1st by dk.pdf
KrushnaDarade1
 
Bob Reedy - Nitrate in Texas Groundwater.pdf
Bob Reedy - Nitrate in Texas Groundwater.pdfBob Reedy - Nitrate in Texas Groundwater.pdf
Bob Reedy - Nitrate in Texas Groundwater.pdf
Texas Alliance of Groundwater Districts
 
Describing and Interpreting an Immersive Learning Case with the Immersion Cub...
Describing and Interpreting an Immersive Learning Case with the Immersion Cub...Describing and Interpreting an Immersive Learning Case with the Immersion Cub...
Describing and Interpreting an Immersive Learning Case with the Immersion Cub...
Leonel Morgado
 
Basics of crystallography, crystal systems, classes and different forms
Basics of crystallography, crystal systems, classes and different formsBasics of crystallography, crystal systems, classes and different forms
Basics of crystallography, crystal systems, classes and different forms
MaheshaNanjegowda
 
Eukaryotic Transcription Presentation.pptx
Eukaryotic Transcription Presentation.pptxEukaryotic Transcription Presentation.pptx
Eukaryotic Transcription Presentation.pptx
RitabrataSarkar3
 
20240520 Planning a Circuit Simulator in JavaScript.pptx
20240520 Planning a Circuit Simulator in JavaScript.pptx20240520 Planning a Circuit Simulator in JavaScript.pptx
20240520 Planning a Circuit Simulator in JavaScript.pptx
Sharon Liu
 
The binding of cosmological structures by massless topological defects
The binding of cosmological structures by massless topological defectsThe binding of cosmological structures by massless topological defects
The binding of cosmological structures by massless topological defects
Sérgio Sacani
 
Unlocking the mysteries of reproduction: Exploring fecundity and gonadosomati...
Unlocking the mysteries of reproduction: Exploring fecundity and gonadosomati...Unlocking the mysteries of reproduction: Exploring fecundity and gonadosomati...
Unlocking the mysteries of reproduction: Exploring fecundity and gonadosomati...
AbdullaAlAsif1
 
The debris of the ‘last major merger’ is dynamically young
The debris of the ‘last major merger’ is dynamically youngThe debris of the ‘last major merger’ is dynamically young
The debris of the ‘last major merger’ is dynamically young
Sérgio Sacani
 
Oedema_types_causes_pathophysiology.pptx
Oedema_types_causes_pathophysiology.pptxOedema_types_causes_pathophysiology.pptx
Oedema_types_causes_pathophysiology.pptx
muralinath2
 
molar-distalization in orthodontics-seminar.pptx
molar-distalization in orthodontics-seminar.pptxmolar-distalization in orthodontics-seminar.pptx
molar-distalization in orthodontics-seminar.pptx
Anagha Prasad
 
Thornton ESPP slides UK WW Network 4_6_24.pdf
Thornton ESPP slides UK WW Network 4_6_24.pdfThornton ESPP slides UK WW Network 4_6_24.pdf
Thornton ESPP slides UK WW Network 4_6_24.pdf
European Sustainable Phosphorus Platform
 
8.Isolation of pure cultures and preservation of cultures.pdf
8.Isolation of pure cultures and preservation of cultures.pdf8.Isolation of pure cultures and preservation of cultures.pdf
8.Isolation of pure cultures and preservation of cultures.pdf
by6843629
 
Authoring a personal GPT for your research and practice: How we created the Q...
Authoring a personal GPT for your research and practice: How we created the Q...Authoring a personal GPT for your research and practice: How we created the Q...
Authoring a personal GPT for your research and practice: How we created the Q...
Leonel Morgado
 
Compexometric titration/Chelatorphy titration/chelating titration
Compexometric titration/Chelatorphy titration/chelating titrationCompexometric titration/Chelatorphy titration/chelating titration
Compexometric titration/Chelatorphy titration/chelating titration
Vandana Devesh Sharma
 
Deep Software Variability and Frictionless Reproducibility
Deep Software Variability and Frictionless ReproducibilityDeep Software Variability and Frictionless Reproducibility
Deep Software Variability and Frictionless Reproducibility
University of Rennes, INSA Rennes, Inria/IRISA, CNRS
 
Travis Hills' Endeavors in Minnesota: Fostering Environmental and Economic Pr...
Travis Hills' Endeavors in Minnesota: Fostering Environmental and Economic Pr...Travis Hills' Endeavors in Minnesota: Fostering Environmental and Economic Pr...
Travis Hills' Endeavors in Minnesota: Fostering Environmental and Economic Pr...
Travis Hills MN
 

Recently uploaded (20)

Immersive Learning That Works: Research Grounding and Paths Forward
Immersive Learning That Works: Research Grounding and Paths ForwardImmersive Learning That Works: Research Grounding and Paths Forward
Immersive Learning That Works: Research Grounding and Paths Forward
 
Phenomics assisted breeding in crop improvement
Phenomics assisted breeding in crop improvementPhenomics assisted breeding in crop improvement
Phenomics assisted breeding in crop improvement
 
原版制作(carleton毕业证书)卡尔顿大学毕业证硕士文凭原版一模一样
原版制作(carleton毕业证书)卡尔顿大学毕业证硕士文凭原版一模一样原版制作(carleton毕业证书)卡尔顿大学毕业证硕士文凭原版一模一样
原版制作(carleton毕业证书)卡尔顿大学毕业证硕士文凭原版一模一样
 
SAR of Medicinal Chemistry 1st by dk.pdf
SAR of Medicinal Chemistry 1st by dk.pdfSAR of Medicinal Chemistry 1st by dk.pdf
SAR of Medicinal Chemistry 1st by dk.pdf
 
Bob Reedy - Nitrate in Texas Groundwater.pdf
Bob Reedy - Nitrate in Texas Groundwater.pdfBob Reedy - Nitrate in Texas Groundwater.pdf
Bob Reedy - Nitrate in Texas Groundwater.pdf
 
Describing and Interpreting an Immersive Learning Case with the Immersion Cub...
Describing and Interpreting an Immersive Learning Case with the Immersion Cub...Describing and Interpreting an Immersive Learning Case with the Immersion Cub...
Describing and Interpreting an Immersive Learning Case with the Immersion Cub...
 
Basics of crystallography, crystal systems, classes and different forms
Basics of crystallography, crystal systems, classes and different formsBasics of crystallography, crystal systems, classes and different forms
Basics of crystallography, crystal systems, classes and different forms
 
Eukaryotic Transcription Presentation.pptx
Eukaryotic Transcription Presentation.pptxEukaryotic Transcription Presentation.pptx
Eukaryotic Transcription Presentation.pptx
 
20240520 Planning a Circuit Simulator in JavaScript.pptx
20240520 Planning a Circuit Simulator in JavaScript.pptx20240520 Planning a Circuit Simulator in JavaScript.pptx
20240520 Planning a Circuit Simulator in JavaScript.pptx
 
The binding of cosmological structures by massless topological defects
The binding of cosmological structures by massless topological defectsThe binding of cosmological structures by massless topological defects
The binding of cosmological structures by massless topological defects
 
Unlocking the mysteries of reproduction: Exploring fecundity and gonadosomati...
Unlocking the mysteries of reproduction: Exploring fecundity and gonadosomati...Unlocking the mysteries of reproduction: Exploring fecundity and gonadosomati...
Unlocking the mysteries of reproduction: Exploring fecundity and gonadosomati...
 
The debris of the ‘last major merger’ is dynamically young
The debris of the ‘last major merger’ is dynamically youngThe debris of the ‘last major merger’ is dynamically young
The debris of the ‘last major merger’ is dynamically young
 
Oedema_types_causes_pathophysiology.pptx
Oedema_types_causes_pathophysiology.pptxOedema_types_causes_pathophysiology.pptx
Oedema_types_causes_pathophysiology.pptx
 
molar-distalization in orthodontics-seminar.pptx
molar-distalization in orthodontics-seminar.pptxmolar-distalization in orthodontics-seminar.pptx
molar-distalization in orthodontics-seminar.pptx
 
Thornton ESPP slides UK WW Network 4_6_24.pdf
Thornton ESPP slides UK WW Network 4_6_24.pdfThornton ESPP slides UK WW Network 4_6_24.pdf
Thornton ESPP slides UK WW Network 4_6_24.pdf
 
8.Isolation of pure cultures and preservation of cultures.pdf
8.Isolation of pure cultures and preservation of cultures.pdf8.Isolation of pure cultures and preservation of cultures.pdf
8.Isolation of pure cultures and preservation of cultures.pdf
 
Authoring a personal GPT for your research and practice: How we created the Q...
Authoring a personal GPT for your research and practice: How we created the Q...Authoring a personal GPT for your research and practice: How we created the Q...
Authoring a personal GPT for your research and practice: How we created the Q...
 
Compexometric titration/Chelatorphy titration/chelating titration
Compexometric titration/Chelatorphy titration/chelating titrationCompexometric titration/Chelatorphy titration/chelating titration
Compexometric titration/Chelatorphy titration/chelating titration
 
Deep Software Variability and Frictionless Reproducibility
Deep Software Variability and Frictionless ReproducibilityDeep Software Variability and Frictionless Reproducibility
Deep Software Variability and Frictionless Reproducibility
 
Travis Hills' Endeavors in Minnesota: Fostering Environmental and Economic Pr...
Travis Hills' Endeavors in Minnesota: Fostering Environmental and Economic Pr...Travis Hills' Endeavors in Minnesota: Fostering Environmental and Economic Pr...
Travis Hills' Endeavors in Minnesota: Fostering Environmental and Economic Pr...
 

Venkat ns2

  • 2. 2 OutlineOutline • BackgroundBackground • ArchitectureArchitecture • UsageUsage • SimulationSimulation • NS-programmingNS-programming • ExampleExample • SummarySummary
  • 3. 3 ns-2, the Network Simulatorns-2, the Network Simulator • AA discrete event simulatordiscrete event simulator modellingmodelling network protocolsnetwork protocols – Packets, links, queues, protocolsPackets, links, queues, protocols – Visualizer (Visualizer (NAMNAM)) – Trace playbackTrace playback – Error modelsError models • Targeted at networking researchTargeted at networking research • Supports for all types of simulationsSupports for all types of simulations
  • 4. 4 HistoryHistory • 1989:1989: REALREAL by Keshavby Keshav • 1995:1995: nsns by Floyd, McCanne at LBLby Floyd, McCanne at LBL • 1997:1997: ns-2ns-2 by the VINT projectby the VINT project ((Virtual InterNetwork TestbedVirtual InterNetwork Testbed) at) at LBL, Xerox PARC, UCB, USC/ISILBL, Xerox PARC, UCB, USC/ISI • 1999: Wireless models added @ CMU1999: Wireless models added @ CMU • Now:Now: ns-2.29ns-2.29 maintained at USC/ISImaintained at USC/ISI – ns-2.30ns-2.30 pending releasepending release
  • 5. NS-2 OverviewNS-2 Overview • TCP/IP NS2 OSI 7-LayerTCP/IP NS2 OSI 7-Layer 5 •Application •Presentation •Session •Transport •Network •Data Link •Physical •Application •Agent •Node •Link •Application •TCP/UDP •IP •Network •Access
  • 6. Platforms SupportedPlatforms Supported • Most UNIX and UNIX-like systemsMost UNIX and UNIX-like systems  FreeBSDFreeBSD  LinuxLinux  SolarisSolaris • Windows 98/2000/2003/XPWindows 98/2000/2003/XP – Cygwin requiredCygwin required – Some work , some doesntSome work , some doesnt 6
  • 7. User’s PerspectiveUser’s Perspective • From the user’s perspective, NS−2 isFrom the user’s perspective, NS−2 is an OTcl interpreter that takes an OTclan OTcl interpreter that takes an OTcl script as input and produces a tracescript as input and produces a trace file as output.file as output. 7
  • 8. 8 NS-2 EnvironmentNS-2 Environment •Simulation Scenario •Tcl Script •C++ Implementation •1 •2 •set ns_ [new Simulator] •set node_(0) [$ns_ node] •set node_(1) [$ns_ node] •class MobileNode : public Node •{ • friend class PositionHandler; •public: • MobileNode(); • • • • •}
  • 9. 9 ComponentsComponents • ns-2ns-2, the simulator itself, the simulator itself – Specify simulation, generate tracesSpecify simulation, generate traces – Depends on Tcl/Tk, OTcl, TclCLDepends on Tcl/Tk, OTcl, TclCL • namnam, the network animator, the network animator – Animate traces from simulationAnimate traces from simulation – GUI for constructing simple simulationsGUI for constructing simple simulations • Pre-processingPre-processing – Traffic, topology generationTraffic, topology generation • Post-processingPost-processing – Analyse trace output withAnalyse trace output with awkawk, etc, etc
  • 10. NS ModelsNS Models • Traffic models and applications:Traffic models and applications: – Web, FTP, telnet, constant-bit rateWeb, FTP, telnet, constant-bit rate • Transport protocols:Transport protocols: – unicast: TCP (Reno, Vegas, etc.), UDPunicast: TCP (Reno, Vegas, etc.), UDP – Multicast: SRMMulticast: SRM • Routing and queueing:Routing and queueing: – Wired routing, ad hoc rtgWired routing, ad hoc rtg – queueing protocols: RED, drop-tail, etcqueueing protocols: RED, drop-tail, etc • Physical media:Physical media: – Wired (point-to-point, LANs), wirelessWired (point-to-point, LANs), wireless (multiple propagation models), satellite(multiple propagation models), satellite 10
  • 11. Basic ArchitectureBasic Architecture 11 •An executable command ns •Input: tcl simulation scripting file •Output: trace file  Animation by NAM or plotting graph by Xgraph (gunplot)
  • 12. NS2-GoalsNS2-Goals To support networking research andTo support networking research and educationeducation –– Protocol design, traffic studies, etc.Protocol design, traffic studies, etc. –– Protocol comparison;Protocol comparison; –– New architecture designs are alsoNew architecture designs are also supported.supported. •• To provideTo provide collaborativecollaborative environmentenvironment –– Freely distributed, open source;Freely distributed, open source; –– Increase confidenceIncrease confidence in resultin result 12
  • 14. 14 UsingUsing nsns • Create simulationCreate simulation – Describe network, protocols, sources, sinksDescribe network, protocols, sources, sinks – Interface via OTcl which controls C++Interface via OTcl which controls C++ • Execute simulationExecute simulation – Simulator maintains event list (packet list), executesSimulator maintains event list (packet list), executes next event (packet), repeats until donenext event (packet), repeats until done – Events happen instantly inEvents happen instantly in virtual timevirtual time but could takebut could take arbitrarily longarbitrarily long real timereal time – Single thread of control, no locking, races, etcSingle thread of control, no locking, races, etc • Post-process resultsPost-process results – Scripts (awk, perl, python) to process text outputScripts (awk, perl, python) to process text output – No standard library but some available on webNo standard library but some available on web
  • 15. 15 LanguagesLanguages • C++ forC++ for datadata – Per-packet processing, the core ofPer-packet processing, the core of nsns – Fast to run, detailed, complete controlFast to run, detailed, complete control • OTcl forOTcl for controlcontrol – Simulation descriptionSimulation description – Periodic or triggered actionsPeriodic or triggered actions – Manipulating existing C++ objectsManipulating existing C++ objects – Faster to write and change codeFaster to write and change code » (a matter of opinion)(a matter of opinion)
  • 16. 16 Basic TclBasic Tcl # Variables:# Variables: setset x 10x 10 setset xx putsputs “x is $x”“x is $x” # Functions and expressions:# Functions and expressions: setset y [pow x 2]y [pow x 2] setset y [expr x*x]y [expr x*x] # Control flow:# Control flow: ifif {$x > 0} {{$x > 0} { returnreturn $x }$x } elseelse {{ returnreturn [expr -$x] }[expr -$x] } whilewhile { $x > 0 } {{ $x > 0 } { putsputs $x$x incrincr x –1x –1 }} forfor {{setset i 0} {$i<10} {i 0} {$i<10} {incrincr i} {i} { putsputs “$i == $i”“$i == $i” }} # Procedures:# Procedures: procproc pow {x n} {pow {x n} { ifif {$n == 1} {{$n == 1} { returnreturn $x }$x } setset part [part [powpow x [x [exprexpr $n-1]]$n-1]] returnreturn [[exprexpr $x*$part]$x*$part] }} # Files:# Files: setset file [file [open “open “nstrace.txt” w]nstrace.txt” w] setset line [line [getsgets $file]$file] puts –nonewlineputs –nonewline $file “hello!”$file “hello!” closeclose $file$file
  • 17. 17 App1 Agent1 App2 Agent2 Node From Network to SimulationFrom Network to Simulation Application, Agent & Node LinkNode App1 Agent1 App2 Agent2 Node App1 Agent1 App2 Agent2 Node App1 Agent1 App2 Agent2 Node Node Node Node Link Link Link Link Link Link Link Link App1 Agent1 App2 Agent2 Node App1 Agent1 App2 Agent2 Node
  • 18. Visualization ToolsVisualization Tools 18 •nam-1 (Network AniMator Version 1) •Packet-level animation •Well supported by ns •xgraph •Simulation results
  • 20. Elements for NS-2 simulationElements for NS-2 simulation 20 •Create the event scheduler •Turn on tracing •Create network •Setup routing •Create transport connection •Create traffic •Transmit application-level data
  • 21. Creating Simulation environmentCreating Simulation environment 21  Create event scheduler  set ns [new Simulator]  Schedule events  $ns at <time> <event>  <event>: any legitimate ns/tcl commands  Start scheduler  $ns run
  • 22. TracingTracing 22  Turn on tracing on specific links  $ns trace-queue $n0 $n1  $ns namtrace-queue $n0 $n1
  • 23. Creating nodes, links and queuesCreating nodes, links and queues 23  Nodes  set n0 [$ns node]  set n1 [$ns node]  Links and queuing  $ns duplex-link $n0 $n1 <bandwidth> <delay> <queue_type>  <queue_type>: DropTail, RED, CBQ, FQ, SFQ, DRR
  • 24. Creating connection :UDPCreating connection :UDP 24  UDP  set udp [new Agent/UDP]  set null [new Agent/Null]  $ns attach-agent $n0 $udp  $ns attach-agent $n1 $null  $ns connect $udp $null
  • 25. Creating Traffic : on top of UDPCreating Traffic : on top of UDP 25  CBR  set src [new Application/Traffic/CBR]
  • 26. Creating connection : TCPCreating connection : TCP 26  TCP  set tcp [new Agent/TCP]  set tcpsink [new Agent/TCPSink]  $ns attach-agent $n0 $tcp  $ns attach-agent $n1 $tcpsink  $ns connect $tcp $tcpsink
  • 27. Creating Traffic : on top of TCPCreating Traffic : on top of TCP 27  FTP  set ftp [new Application/FTP]  $ftp attach-agent $tcp  Telnet  set telnet [new Application/Telnet]  $telnet attach-agent $tcp
  • 28. Simple Simulation ExampleSimple Simulation Example 28 •This network consists of 4 nodes (n0, n1, n2, n3) •The duplex links between n0 and n2, and n1 and n2 have •The duplex link between n2 and n3 has 1.7 Mbps of bandwidth and 20 ms of delay 2 Mbps of bandwidth and 10 ms of delay. •Each node uses a DropTail queue,of which the maximum size is 10 •ftp session is based on tcp •tcp agent: generate packet (l=1k bytes) •sink: generate ack and free packets •cbr session is based on udp •udp agent: generate packet (l=1k bytes) @ 1 Mbps •null: free packets
  • 29. Script structureScript structure 29 # parameters and options set ns [new Simulator] # [Turn on tracing] # Create topology # Setup packet loss, link dynamics # Create routing agents # Create: # - protocol agents # - application and/or setup traffic sources # Post-processing procs # Start simulation
  • 30. Final Topology Generated (final screenshot)Final Topology Generated (final screenshot) 30
  • 31. 31 SummarySummary • BackgroundBackground • ArchitectureArchitecture • UsageUsage • SimulationSimulation • NS-programmingNS-programming • ExampleExample • SummarySummary

Editor's Notes

  1. what is it? -- history -- code stats -- tree layout goals, accomplishments, status ns architecture/history/perspective target audience, tutorial outline state of the software and distributions
  2. what does it do? -- tcp, higher protocols, packets, links, queuing disciplines -- visualizer (NAM) -- trace playback -- error models what does it not do? -- routing, ip, L2, routing
  3. basic structure -- setup simulation -- objects -&amp;gt; events -&amp;gt; schedule -&amp;gt; repeat -- trace files -&amp;gt; post processing -&amp;gt; graphs -- (example trace) Model world as events Simulator has list of events Process: take next one, run it, until done Each event happens in an instant of virtual (simulated) time, but takes an arbitrary amount of real time Ns uses simple model: single thread of control =&amp;gt; no locking or race conditions to worry about (very easy)