NS TUTORIAL Padma Haldar USC/ISI 09/04/02.

Slides:



Advertisements
Similar presentations
Katz, Stoica F04 EECS 122 Introduction to Computer Networks (Fall 2004) Network simulator 2 (ns-2) Department of Electrical Engineering and Computer Sciences.
Advertisements

Wireless Communication : LAB 3
NS-2 (network simulator) NS by example παρουσίαση Κων/νος Τρούλος.
Introduction to Network Simulator NS-2 Part I
1 ns-2 Tutorial, part 2 Dave Anderson, Xiaowei Yang (Modified from Polly Huang’s slides)
1 NS Fundamentals (contd..) Padma Haldar USC/ISI.
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.
NS-2 網路模擬器介紹與使用 吳賢明國立中興大學 計算機及資訊網路中心中華民國九十三年十月二十七日.
How to Add a New Protocol in NS2 Xu Leiming CSCW Lab. at CS Dept., Tsinghua Univ. June 1, 2001.
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.
Winter 2008 Evaluation Tools1 Brief Overview of Networking Evaluation Methods and Tools.
15-744: Computer Networking ns-2 Tutorial Based on slides from John Heidemann, Polly Huang, and Amit Manjhi.
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
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.
Wireless Sensor Network for Tracking the Traffic in INTERNET Network Routers Supervisor: Mark Shifrin Students: Yuriy Kipnis Nir Bar-Or Networked Software.
EECS122 - UCB1 Measurements and Modeling Table of Contents 1. Measurements Measurements 2. Modeling and its Shortcomings Modeling and its Shortcomings.
Network Simulator 2(NS2) Yingyue Xu 8/25/2015. Overview: The Network simulator (NS): discrete event simulator for networks. supports wired, wireless,
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 NS2 -Network Simulator- -Prepared by Changyong Jung.
1 Introduction to Ns-2 Zhibin WU WINLAB, ECE Dept. Rutgers U.
NS2 - Appendix Ming-Feng Yang. 2 2 Outline NS2 Models NS2 Directory Structure Extending NS2 in OTcl Extending NS2 in C++ NS2 related links.
JIA-HUI HUANG INSTITUTE OF COMPUTER SCIENCE AND INFORMATION ENGINEERING NATIONAL TAIPEI UNIVERSITY OF TECHNOLOGY Network Simulator – NS-2 1.
Network Simulator-2 Sandeep singla 1998A2A7540. NS-2 A discrete event simulator Focused on modeling network protocols –Wired, wireless –TCP,UDP,unicast,multicast.
TNK092: Network Simulation - Nätverkssimulering Lecture 3: TCP Vangelis Angelakis.
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
NS-2 Tutorial. Motivation What’s NS-2 Network simulator –Discrete event simulator It covers multiple layers –Application layer, transport layer, network.
1 Network Simulation and Testing Polly Huang EE NTU
1 ns-2 Tutorial Haobo Yu, Nader Salehi USC/ISI
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.
The New NS2 Emulation Facility Kevin Fall NS2 is the simulation vehicle for the VINT project: –USC/ISI: Deborah Estrin, Mark Handley,
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.
NS-2 Simulator 최 종 훈 Contents  About NS  Installation  Based on Linux  Based on Windows  Architecture  Using NS-2  Example  References.
DMET 602: Networks and Media Lab
(Modified from Polly Huang’s and last year’s original)
Choe, Hyun Jung (Stella)
Introduction to ns-2: “The” Network Simulator
NS2 (and possible directions for mobile routing simulation) Kevin Fall
Introduction to NS Srinath Perur.
Ns By Kulveer Singh.
Karthik Sadasivam Banuprasad Samudrala
Presentation transcript:

NS TUTORIAL Padma Haldar USC/ISI 09/04/02

Tutorial Outline Part I  NS fundamentals  Wired world  Walk-thru an example NS script Part II  Visualization tools & other utilities  Help and references

What Is NS? Started as REAL in 1989 Discrete event, packet level simulator Written in C++ with Otcl frontend Wired, wireless and emulation modes Link layer and up for most wired Additional lower layers for wireless

Platforms Most UNIX and UNIX-like systems  Linux  FreeBSD  SunOS/Solaris  HP/SGI (with some tweaking) Windows 95/98/NT/ME/2000  Tips on build available  However validation tests don’t work

Architecture in NS Object-oriented (C++ and Otcl)  Algorithms over large data sets, per packet handling in C++  Configuration, “one-time” stuff in Otcl  Fast to run, quick to re-configure  Fine grained object composition

C++ and OTcl Separation C++ for “data” Per packet action OTcl for control Configuration, “one-time” task + Compromise between composibility and speed – Learning and debugging

OTcl and C++: The Duality C++ OTcl Pure C++ objects Pure OTcl objects C++/OTcl split objects ns

Basic tcl set a 43 set b 27 proc test { a b } { 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]” }

Basic OTcl Class Mom Mom instproc greet {} { $self instvar age_ puts “$age_ years old mom: How are you doing?” } Class Kid -superclass Mom Kid instproc greet {} { $self instvar age_ puts “$age_ years old kid: What’s up, dude?” } set mom [new Mom] $mom set age_ 45 set kid [new Kid] $kid set age_ 15 $mom greet $kid greet

Hello World - Interactive Mode swallow 71% ns % set ns [new Simulator] _o3 % $ns at 1 “puts \“Hello World!\”” 1 % $ns at 1.5 “exit” 2 % $ns run Hello World! swallow 72%

Hello World - Batch Mode simple.tcl set ns [new Simulator] $ns at 1 “puts \“Hello World!\”” $ns at 1.5 “exit” $ns run swallow 74% ns simple.tcl Hello World! swallow 75%

Event Driven Simulation Scheduler – main controller of events Scheduler clock - simulator virtual time [$ns_ now] returns the current simulator time Event queue - holds events in the order of their firing times Events have a firing time and a handler function Two types of events possible – packets and “at-events”

Discrete Event Scheduler time_, uid_, next_, handler_ Head_ -> handler_ -> handle() time_, uid_, next_, handler_ Insert Four types of scheduler: List: simple linked list, order- preserving, O(N) Heap: O(logN) Calendar: hash-based, fastest, default, O(1) Real-time: subclass of list, sync with real-time, O(N) Event Queue Deque Dispatch Reschedule

Elements of Ns-2 Create the event scheduler [Turn on tracing] Create network Setup routing Insert errors Create transport connection Create traffic

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

Tracing Trace packets on all links $ns trace-all [open test.out w] cbr cbr r cbr Trace packets on all links in nam format $ns namtrace-all [open test.nam w] $ns namtrace-all-wireless [open wtest.nam w]

Tracing Turn on tracing on specific links $ns trace-queue $n0 $n1 $ns namtrace-queue $n0 $n1 Trace-all commands must appear immediately after creating scheduler

Tracing Event tracing $ns eventtrace-all [$file] Add eventtrace after trace-all as trace-all file is used as default Example script: ~ns/tcl/ex/tcp-et.tcl

Creating Network Topology Nodes set n0 [$ns node] set n1 [$ns node] Links and queuing $ns duplex-link $n0 $n1 : DropTail, RED, CBQ, FQ, SFQ, DRR $ns duplex-link $n0 $n1 5Mb 2ms DropTail

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

Network Dynamics Link failures Hooks in routing module to reflect routing changes Four models $ns rtmodel Trace $n0 $n1 $ns rtmodel Exponential { } $n0 $n1 $ns rtmodel Deterministic { } $n0 $n1 $ns rtmodel-at up|down $n0 $n1 Parameter list [ ] [ ]

Setup Routing Unicast $ns rtproto : Static, Session, DV, LS, Manual or hierarchical Multicast $ns multicast (right after [new Simulator]) $ns mrtproto : CtrMcast, DM, ST, BST

Creating Connection: TCP One-way TCP sending agent [Tahoe, Reno, NewReno, Sack, Vegas and Fack] 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 TCP FTP set ftp [new Application/FTP] $ftp attach-agent $tcp Telnet set telnet [new Application/Telnet] $telnet attach-agent $tcp

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

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

Example - TCP Simple scenario with TCP and UDP connections n0 TCP n4 UDP n1 n2 n5 UDP recvr n3 TCPSink 1.5Mb 10ms 5Mb 2ms 5Mb 2ms

TCP : Step 1 Scheduler & tracing #Create scheduler Set ns [new Simulator] #Turn on tracing set f [open out.tr w] $ns trace-all $f Set nf [open out.nam w] $ns namtrace-all $nf

TCP : Step 2 Create topology #create nodes set n0 [$ns node] set n1 [$ns node] set n3 [$ns node] set n4 [$ns node]

TCP : Step 3 #create links $ns duplex-link $n0 $n1 5Mb 2ms DropTail $ns duplex-link $n1 $n2 1.5Mb 10ms DropTail $ns duplex-link $n2 $n3 5Mb 2ms DropTail $ns queue-limit $n1 $n2 25 $ns queue-limit $n2 $n1 25

TCP : Step 4 Create TCP agents set tcp [new Agent/TCP] set sink [new Agent/TCPSink] $ns attach-agent $n0 $tcp $ns attach-agent $n3 $sink $ns connect $tcp $sink

TCP : Step 5 Attach traffic set ftp [new Application/FTP] $ftp attach-agent $tcp #start application traffic $ns at 1.1 “$ftp start”

TCP : Step 6 End of simulation wrapper (as usual) $ns at 2.0 “finish” Proc finish {} { global ns f nf close $f close $nf puts “Running nam…” exec nam out.nam & exit 0 } $ns run

Viz Tools Nam-1 (Network AniMator Version 1)  Packet-level animation  Well-supported by ns Xgraph  Convert trace output into xgraph format

Ns-nam Interface Color Node manipulation Link manipulation Topology layout Protocol state Misc

Nam Interface: Color Color mapping $ns color 40 red $ns color 41 blue $ns color 42 chocolate Color  flow id association $tcp0 set fid_ 40;# red packets $tcp1 set fid_ 41;# blue packets

Nam Interface: Nodes Color $node color red Shape (can’t be changed after sim starts) $node shape box;# circle, box, hexagon Marks (concentric “shapes”) $ns at 1.0 “$n0 add-mark m0 blue box” $ns at 2.0 “$n0 delete-mark m0” Label (single string) $ns at 1.1 “$n0 label \”web cache 0\””

nam Interfaces: Links Color $ns duplex-link-op $n0 $n1 color "green" Label $ns duplex-link-op $n0 $n1 label "abced" Dynamics (automatically handled) $ns rtmodel Deterministic { } $n0 $n1 Asymmetric links not allowed

Nam Interface: Topo Layout “Manual” layout: specify everything $ns duplex-link-op $n(0) $n(1) orient right $ns duplex-link-op $n(1) $n(2) orient right-up $ns duplex-link-op $n(2) $n(3) orient down $ns duplex-link-op $n(3) $n(4) orient 60deg If anything missing  automatic layout

Nam Interface: Protocol State Monitor values of agent variables $ns add-agent-trace $srm0 srm_agent0 $ns monitor-agent-trace $srm0 $srm0 tracevar C1_ $srm0 tracevar C2_ # … … $ns delete-agent-trace $tcp1

Nam Interface: Misc Annotation Add textual explanation to your sim $ns at 3.5 "$ns trace-annotate \“packet drop\"“ Set animation rate $ns at 0.0 "$ns set-animation-rate 0.1ms"

Other Utilities in Ns Nam editor Available as part of nam-1 Tcl debugger For source and documentation, see Topology generator Scenario generator

Other Ns Features Other areas in wired domain LANs Diffserv Multicast Full TCP Applications like web-caching Wireless domain Ad hoc routing Mobile IP Satellite networking Directed diffusion (sensor networks)

Other Ns Features Emulator Connect simulator in a real network Can receive and send out live packets from/into the real world

Resources Ns distribution download Installation problems and bug-fix Ns-users mailing list See Archives from above URL

Resources (contd..) Marc Greis’ tutorial Ns-users archive Ns-manual documentation.html Tcl (Tool Command Language) Practical programming in Tcl and Tk, Brent Welch Otcl (MIT Object Tcl) ~otcl/doc/tutorial.html (in distribution)