Network Simulator 2(NS2) Yingyue Xu 8/25/2015. Overview: The Network simulator (NS): discrete event simulator for networks. supports wired, wireless,

Slides:



Advertisements
Similar presentations
Introduction to nam Tim Buchheim 21 November 2002 ns tutorial - fall 2002.
Advertisements

Wireless Communication : LAB 3
NS-2 (network simulator) NS by example παρουσίαση Κων/νος Τρούλος.
Introduction to Network Simulator NS-2 Part I
Network Simulation One tool to simulation network protocols for the Internet is the network simulator (NS) The simulation environment needs to be set-
An Introduction to NS-2 * Gayatri Swamynathan CS 276 TA *some slides are from a presentation by Haobo Yu & Nader Salehi, USC/ISI.
NS-2 Shahin Shayandeh December 2004 Session 2. Ns programming  Create the event scheduler  Turn on tracing  Create network  Setup routing  Insert.
Brief Intro to ns2: The most widely used Network Simulator COMP5416 Advanced Network Technologies Based on: Marc Greis's
Ns-2 Tutorial Exercise (1) Multimedia Networking Group, The Department of Computer Science, UVA Jianping Wang Adopted from Nicolas’s slides Jianping Wang,
Ns-2 tutorial Karthik Sadasivam Banuprasad Samudrala CSCI 5931 Network Security Instructor : Dr. T. Andrew Yang.
Network Simulator (NS) Prof. Nelson L. S. da Fonseca State University of Campinas, Brazil.
5-Jul-141 S.Pushpalatha, Associate Professor, PSNACET.
Introduction to NS. Information Main website Documentation, mailing list archive, tutorial Location of Source codes –C++ files.
Dongsoo S. Kim 1.
Introduction to Wireless simulations Shao-Cheng Wang.
Simulation of GPRS MS-BS Interface Using ns-Network Simulator Dual Degree Presentation by Richa Jain (96D07007) Department of Electrical Engineering, Indian.
NS TUTORIAL Padma Haldar USC/ISI 09/04/02.
Network Simulator 2 Tejas Vasavada.
1 Network Simulator (NS-2). 2 講義 Network Simulator (NS2) Part 1: 下載 Part 2: 安裝與測試 Part 3: 劇本 Part 4: 數據.
Katz, Stoica F04 EECS 122 Introduction to Computer Networks (Fall 2003) Network simulator 2 (ns-2) Department of Electrical Engineering and Computer Sciences.
CprE 543x – ns-2 Tutorial Zak Abichar, Dept of Electrical and Computer Engineering Iowa State University Ames,
1 Ns Tutorial Alhussein A. Abouzeid Elect. Eng. Dept./U. of Washington Parts of this educational presentation use examples available.
Day 3 Outline Multicast example (from Day 2) Wireless Misc. utilities
15-744: Computer Networking L-3 The network simulator ns-2 Slides loosely based on a tutorial by Polly Huang, ETH Zurich.
1 Modified Schedule Day 2 Network AniMator (nam) Examples simple.tcl mcast.tcl Day 3 Wireless (ad-hoc)
Submitters: Stella Pantofel Michael Halperin Igor Berman
Jump to first page NS Tutorial: mobile and wireless network simulation Ya Xu USC/ISI September 10th, 1999.
1 Network Simulator (NS-2) Tutorial These slides can be downloaded from:
1 2nd European ns-2 Workshop Polly Huang ETH Zurich April 18 & 19, 2001.
EECS122 - UCB1 Measurements and Modeling Table of Contents 1. Measurements Measurements 2. Modeling and its Shortcomings Modeling and its Shortcomings.
Ns Simulation of IEEE SC546 Project (Fall 2002) SOO IL KIM JISUN YOON
Introduction to Network Simulator NS-2 Part II
Network Simulator (NS2) 1 Tutorial on Network Simulator (NS2) Hemant Kumar Rath Infonet Lab, Dept of Electrical Engineering IIT Bombay, Mumbai
Wireless Networking and Systems CSE 590 ns2 tutorial.
10b_ns: CSci551 SP2002 Friday © 2002 John Heidemann1 NS Tutorial, Class 10 CSci551: Computer Networks SP2002 Friday Section John Heidemann.
Introduction to ns-2 Noun Choi Oct. 11, Outline Background ns-2 Internals Short demo Troubleshooting Reference links Q & A.
1 Introduction to Ns-2 Zhibin WU WINLAB, ECE Dept. Rutgers U.
1 / 10 Mobile Networking in ns Speaker : Mark Yang
NS2 - Wireless Network Ming-Feng Yang. 2 2 Outline Basic wireless model Extensions wireless model Example - Ad hoc network Example – WLAN Example – Mobile.
Define options(1/2) #channel type set val(chan) Channel/WirelessChannel # radio-propagation model set val(prop) Propagation/TwoRayGround # network interface.
MOBILE IP SOMULATION IN NS2 Presenter: 吳寶緣. Outlines  Overview  Hierarchical Address Format  Hierarchical Address Format-ex  MoblieIP Demo  Additional.
NS2 - Appendix Ming-Feng Yang. 2 2 Outline NS2 Models NS2 Directory Structure Extending NS2 in OTcl Extending NS2 in C++ NS2 related links.
Network Simulator-2 Sandeep singla 1998A2A7540. NS-2 A discrete event simulator Focused on modeling network protocols –Wired, wireless –TCP,UDP,unicast,multicast.
NetFlow Very useful for traffic analysis Very useful for traffic analysis Standard sampler: Standard sampler: –Cisco Netflow –Juniper Traffic Sampling.
1 Network Simulator Tutorial. 2 Network Simulation * Motivation: Learn fundamentals of evaluating network performance via simulation Overview: fundamentals.
Internet Computing KUT Youn-Hee Han
Network Simulator ns-2. 2 Agenda Introduction Interface Tcl and OTcl TclCL Simulator Wired network Wireless network Program Assignment.
NS-2 Tutorial. Motivation What’s NS-2 Network simulator –Discrete event simulator It covers multiple layers –Application layer, transport layer, network.
Quality evaluation of MPEG4 video transmission over GPRS networks.. Presented by: Abdullah M. Rana Multimedia Communication.
1 Network Simulation and Testing Polly Huang EE NTU
1 NS Fundamentals. USC INFORMATION SCIENCES INSTITUTE 2 OTcl and C++: The Duality C++ OTcl Pure C++ objects Pure OTcl objects C++/OTcl split objects ns.
Ns-2 Tutorial (1) Multimedia Networking Group, The Department of Computer Science, UVA Jianping Wang Jianping Wang, 2002 cs757 1.
1 Introduction to NS-2 r Tutorial overview of NS m Create basic NS simulation r Walk-through a simple example m Model specification m Execution and trace.
1 ns-2 Tutorial Polly Huang AT&T Labs Research 11 August, 1999.
Lab 2, Network Simulator ns2 Shiv Kalyanaraman Yong Xia (TA) Satish Raghunath Sept 4,
Network Simulator Tutorial Wireless Networks. Acknowledgements Material is taken from the presentations by Jim Kurose, University of Massachusetts, Amherst.
CDA6530: Performance Models of Computers and Networks Chapter 10: Introduction to Network Simulator (NS2) TexPoint fonts used in EMF. Read the TexPoint.
University of Texas at Arlington CSE 5346/4346 High Performance Networks 1 NS-2 Tutorial Choe, Hyun Jung (Stella) Spring 2008 Spring 2008 High Performance.
The Creation of NS2 Simulated Environment ( 1 ) LI Chengbo
TNK092: Network Simulation - Nätverkssimulering Lecture #1: Course basics and a first taste of NS2 Vangelis Angelakis Ph.D.
NS-2 Shahin Shayandeh December 2004 Session 1. Ns-2, the Network Simulator  A discrete event simulator Simple model  Focused on modeling network protocols.
Lab 2, Network Simulator ns2
© Algirdas Pakstas CS3026N Network Analysis, Design and Simulation 1 CT3020: Network Planning and Simulation Week 6b Prof.DrTech. Algirdas Pakštas.
DMET 602: Networks and Media Lab Amr El Mougy Yasmeen EssamAlaa Tarek.
DMET 602: Networks and Media Lab
(Modified from Polly Huang’s and last year’s original)
Introduction to ns-2: “The” Network Simulator
Ns By Kulveer Singh.
Karthik Sadasivam Banuprasad Samudrala
TexPoint fonts used in EMF.
Presentation transcript:

Network Simulator 2(NS2) Yingyue Xu 8/25/2015

Overview: The Network simulator (NS): discrete event simulator for networks. supports wired, wireless, and satellite networks. various routing and multicast protocols. written in C++ and object-oriented tool command language (OTcl). NS output is a file(s) which contains all packet information. It can be viewed using network animator (NAM), xgraph, or processed with custom scripts (Perl, Tcl or Awk ).

User view of NS:

Why two languages: C++ Fast in running. Slow and hard to modify (need to recompile the whole NS ). Used to implement detailed protocols and algorithms, to manipulate bytes since it can run over large number of data OTcl Slow in running Can be quickly changed (no need to recompile). Used to implement the simulation configuration like # of nodes, simulation topology and the dimensions of test area. That’s why NS object called split object! NS via Tclcl (Tcl with classes) provides glue to make objects and variables appear on both languages.

Ns functionalities Wired world Routing DV, LS, PIM-SM Transportation: TCP and UDP Traffic sources:web, ftp, telnet, cbr, stochastic Queuing disciplines:drop-tail, RED, FQ, SFQ, DRR QoS: IntServ and Diffserv Emulation Wireless Ad hoc routing and mobile IP Directed diffusion, sensor-MAC Tracing, visualization, various utilities

Ns Models Traffic models and applications: Web, FTP, telnet, constant-bit rate, real audio Transport protocols: unicast: TCP (Reno, Vegas, etc.), UDP Multicast: SRM Routing and queueing: Wired routing, ad hoc rtg and directed diffusion queueing protocols: RED, drop-tail, etc Physical media: Wired (point-to-point, LANs), wireless (multiple propagation models), satellite

NS installation: NS can work on most UNIX platforms, and also on windows platform. Detailed info for downloading and building NS: Easier way to download all in one package and build NS (this will not work on Windows), this package contains Tcl, Tclcl, OTcl, Tk, and NS source codes. You need to run install from UNIX shell (Bash or C shell).

Basic Tcl variables: set x 10 puts “x is $x” functions and expressions: set y [pow x 2] set y [expr x*x] control flow: if {$x > 0} { return $x } else { return [expr -$x] } while { $x > 0 } { puts $x incr x –1 } procedures: proc pow {x n} { if {$n == 1} { return $x } set part [pow x [expr $n-1]] return [expr $x*$part] } Also lists, associative arrays, etc. => can use a real programming language to build network topologies, traffic models, etc.

Basic otcl Class Person # constructor: Person instproc init {age} { $self instvar age_ set age_ $age } # method: Person instproc greet {} { $self instvar age_ puts “$age_ years old: How are you doing?” } # subclass: Class Kid -superclass Person Kid instproc greet {} { $self instvar age_ puts “$age_ years old kid: What’s up, dude?” } set a [new Person 45] set b [new Kid 15] $a greet $b greet => can easily make variations of existing things (TCP, TCP/Reno)

Ns programming Create the event scheduler Turn on tracing Create network Setup routing Insert errors Create transport connection Create traffic Transmit application-level data

Creating Event Scheduler Create event scheduler set ns [new Simulator] Schedule events $ns at : any legitimate ns/tcl commands $ns at 5.0 “finish” Start scheduler $ns run

Ns programming Create the event scheduler Turn on tracing Create network Setup routing Insert errors Create transport connection Create traffic Transmit application-level data

Tracing and Monitoring Packet tracing: On all links: $ns trace-all [open out.tr w] On one specific link: $ns trace-queue $n0 $n1$tr cbr cbr r cbr

Ns programming Create the event scheduler Turn on tracing Create network Setup routing Insert errors Create transport connection Create traffic Transmit application-level data

Creating Network Nodes set n0 [$ns node] set n1 [$ns node] Links and queuing $ns $n0 $n1 : duplex-link, simplex-link : DropTail, RED, CBQ, FQ, SFQ, DRR, diffserv RED queues

Creating Network: LAN $ns make-lan : LL : Queue/DropTail, : MAC/802_3 : Channel

Ns programming Create the event scheduler Turn on tracing Create network Setup routing Insert errors Create transport connection Create traffic Transmit application-level data

Setup Routing Unicast $ns rtproto : Static, Session, DV, cost, multi-path Multicast $ns multicast (right after [new Simulator]) $ns mrtproto : CtrMcast, DM, ST, BST Other types of routing supported: source routing, hierarchical routing

Ns programming Create the event scheduler Turn on tracing Create network Setup routing Insert errors Create transport connection Create traffic Transmit application-level data

Inserting Errors Creating Error Module set loss_module [new ErrorModel] $loss_module set rate_ 0.01 $loss_module unit pkt $loss_module ranvar [new RandomVariable/Uniform] $loss_module drop-target [new Agent/Null] Inserting Error Module $ns lossmodel $loss_module $n0 $n1

Ns programming Create the event scheduler Turn on tracing Create network Setup routing Insert errors Create transport connection Create traffic

Creating Connection and Traffic 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 CBR set src [new Application/Traffic/CBR]

Creating Connection and Traffic II 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 FTP set ftp [new Application/FTP] $ftp attach-agent $tcp Telnet set telnet [new Application/Telnet] $telnet attach-agent $tcp

Summary: Generic Script Structure set ns [new Simulator] # [Turn on tracing] # Create topology # Setup packet loss, link dynamics # Create routing agents # Create: # - multicast groups # - protocol agents # - application and/or setup traffic sources # Post-processing procs # Start simulation

Plumbing: Packet Flow 0 1 n0n1 Addr Classifier Port Classifier entry_ 0 Agent/TCP Addr Classifier Port Classifier entry_ 1 0 Link n0-n1 Link n1-n0 0 Agent/TCPSink dst_=1.0 dst_=0.0 Application/FTP

Getting started with nam Turn on nam tracing in your Tcl script As easy as turning on normal tracing $ns namtrace $file Specify link orientation (or node position for wireless) $ns duplex-link-op $node1 $node2 orient left Execute nam exec nam $filename

Advanced nam capabilities Node options — color, shape, label $node color red $node shape hexagon $node label “my text” $node label-color blue $node label-at up Link options $ns duplex-link-op $n1 $n2 color green $ns duplex-link-op queuePos right $ns duplex-link-op $n1 $n2 label “my text” $ns duplex-link-op $n1 $n2 label-color blue $ns duplex-link-op $n1 $n2 label-at down

Advanced nam capabilities Packet colors $ns color $n blue $agent set fid_ $n Annotation $ns at $time “$ns trace-annotate $text” Control playback $ns set-animation-rate 3ms

The nam user interface

The nam editor Create simple scenarios graphically Good for those who don’t want to learn Tcl, but only a limited subset of ns is available

The nam editor

Wireless model Mobilenode at core of mobility model Mobilenodes can move in a given topology, receive/transmit signals from/to wireless channels Wireless network stack consists of LL, ARP, MAC, IFQ etc Allows simulations of multi-hop ad hoc networks, wireless LANs, sensor networks etc

An Example – Step 1 # Define Global Variables # create simulator set ns [new Simulator] # create a flat topology in a 670m x 670m area set topo [new Topography] $topo load_flatgrid

An Example – Step 2 # Define standard ns/nam trace # ns trace set tracefd [open demo.tr w] $ns trace-all $tracefd # nam trace set namtrace [open demo.nam w] $ns namtrace-all-wireless $namtrace

GOD ( General Operations Director ) Stores smallest number of hops from one node to another Optimal case to compare routing protocol performance Automatically generated by scenario file set god [create-god ] $god set-dist

Example –Step 3 Create God set god [create-god 3] $ns at “$god setdist 2 3 1”

An Example – Step 4 # Define how a mobile node is configured $ns node-config \ -adhocRouting DSDV \ -llType LL \ -macType Mac/802_11 \ -ifqLen 50 \ -ifqType Queue/DropTail/PriQueue \ -antType Antenna/OmniAntenna \ -propType Propagation/TwoRayGround \ -phyType Phy/WirelessPhy \ -channelType Channel/WirelessChannel \ -topoInstance $topo -agentTrace ON \ -routerTrace OFF \ -macTrace OFF

An Example – Step 5 # Next create a mobile node, attach it to the channel set node(0) [$ns node] # disable random motion $node(0) random-motion 0 # Use “for” loop to create 3 nodes: for {set i < 0} {$i < 3} {incr i} { set node($i) [$ns node] $node($i) random-motion 0 }

Mobilenode Movement Node position defined in a 3-D model However z axis not used $node set X_ $node set Y_ $node set Z_ $node at $time setdest Node movement may be logged

Scenario Generator: Movement Mobile Movement Generator setdest -n -p pausetime -s -t -x -y setdest -n -p pausetime -s -t -x -y ns-2/indep-utils/cmu-scen- gen/setdest/ Source: ns-2/indep-utils/cmu-scen- gen/setdest/ Random movement $node random-motion 1 $node start $node start

A Movement File $node_(2) set Z_ $node_(2) set Y_ $node_(2) set X_ $node_(1) set Z_ $node_(1) set Y_ $node_(1) set X_ $node_(0) set Z_ $node_(0) set Y_ $node_(0) set X_ $ns_ at "$node_(2) setdest " $ns_ at "$node_(1) setdest " $ns_ at "$node_(0) setdest "

Scenario Generator: Traffic Generating traffic pattern files CBR traffic ns cbrgen.tcl [-type cbr|tcp] [-nn nodes] [-seed seed] [-mc connections] [-rate rate] TCP traffic ns tcpgen.tcl [-nn nodes] [-seed seed] ns-2/indep-utils/cmu-scen- gen/ Source: ns-2/indep-utils/cmu-scen- gen/

A Traffic Scenario set udp_(0) [new Agent/UDP] $ns_ attach-agent $node_(0) $udp_(0) set null_(0) [new Agent/Null] $ns_ attach-agent $node_(2) $null_(0) set cbr_(0) [new Application/Traffic/CBR] $cbr_(0) set packetSize_ 512 $cbr_(0) set interval_ 4.0 $cbr_(0) set random_ 1 $cbr_(0) set maxpkts_ $cbr_(0) attach-agent $udp_(0) $ns_ connect $udp_(0) $null_(0) $ns_ at "$cbr_(0) start" …….

An Example – Step 6 # Define node movement model source # Define traffic model source

An Example – Step 7 # Tell ns/nam the simulation stop time $ns at “$ns nam-end-wireless 200.0” $ns at “$ns halt” # Start your simulation $ns run

nam Visualization Replace $ns namtrace-all $fd with $ns namtrace-all-wireless $fd At the end of simulation, do $ns nam-end-wireless [$ns now]

Wireless Trace Support Original cmu trace format A separate wireless trace format developed later at ISI Current ongoing effort to have ONE format to combine all wired and wireless formats

Useful links: Tutorials: NS2-Manual Network Animator (NAM ): OTcl Tutorial:

Help and Resources Ns and nam build questions Ns mailing list: TCL: Otcl tutorial (in distribution): ftp://ftp.tns.lcs.mit.edu/pub/otcl/doc/tutorial.html ftp://ftp.tns.lcs.mit.edu/pub/otcl/doc/tutorial.html