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.

Slides:



Advertisements
Similar presentations
Network Simulator and problems in installing. Introduction Problems in installing Wired networks modified example2.tcl commands in OTcl usual problems.
Advertisements

NS2 Tutorial – Part II Internet Computing KUT Youn-Hee Han.
1 Multicast in ns-2 報告者 : 陳沐恩. 2 Multicast 簡介 3 Multicast Routing set ns [new Simulator] $ns multicast Or set ns [new Simulator – multicast on] set mproto.
Wireless Communication : LAB 3
NS-2 (network simulator) NS by example παρουσίαση Κων/νος Τρούλος.
NS2-TCP Internet Computing KUT ( Youn-Hee Han It is licensed under a Creative Commons Attribution.
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.
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.
NS TUTORIAL Padma Haldar USC/ISI 09/04/02.
15-744: Computer Networking ns-2 Tutorial Based on slides from John Heidemann, Polly Huang, and Amit Manjhi.
Network Simulator 2 Tejas Vasavada.
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,
Computer Networks NS. Features F Event driven simulator –developed at UC Berkeley F Network Topologies –nodes (connectivity), links (bandwidth, delay)
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.
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.
1 Introduction to Ns-2 Zhibin WU WINLAB, ECE Dept. Rutgers U.
NS2 - Wireless Network Ming-Feng Yang. 2 2 Outline Basic wireless model Extensions wireless model Example - Ad hoc network Example – WLAN Example – Mobile.
Tutorial: The ns-2 Network Simulator Amirali Habibi Shrif Univesity Adapted from: Michael Welzl Institute of Computer Science University of Innsbruck,
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
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.
NS2-TCP Internet Computing KUT ( Youn-Hee Han It is licensed under a Creative Commons Attribution.
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.
Network Simulation Using NS2
Lab 2, Network Simulator ns2
1 NS-2: the network simulator 15 September 2005 Network Lab., SNU Changjee Joo.
© 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)
Network Simulator Tutorial
Choe, Hyun Jung (Stella)
Introduction to ns-2: “The” Network Simulator
Ns By Kulveer Singh.
Karthik Sadasivam Banuprasad Samudrala
Presentation transcript:

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

USC INFORMATION SCIENCES INSTITUTE 3 NS input & output

USC INFORMATION SCIENCES INSTITUTE 4 Basic Tcl Defining a variable. set var1 1 set var2 “Hello“ Variable Reference puts "var1=$var1, var2=$var2" Assign the results of a function set var3 [expr 5*10]

USC INFORMATION SCIENCES INSTITUTE 5 Basic Tcl For Loop for {set i 0} {$i < 100} {incr i} { puts “I = $i " } While Loop set i 0 while {$i < 10} { set n($i) [new Node] incr i } Procedure proc proc1 {} { puts "in procedure proc1" } proc1

USC INFORMATION SCIENCES INSTITUTE 6 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

USC INFORMATION SCIENCES INSTITUTE 7 Simple Simulation Example

USC INFORMATION SCIENCES INSTITUTE 8 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

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

USC INFORMATION SCIENCES INSTITUTE 10 Tracing Trace packets on all links $ns trace-all [open out.tr w] tcp tcp r tcp

USC INFORMATION SCIENCES INSTITUTE 11 Creating Network Nodes set n0 [$ns node] set n1 [$ns node] Links and queuing $ns duplex-link $n0 $n1 : DropTail, RED, CBQ, FQ, SFQ, DRR

USC INFORMATION SCIENCES INSTITUTE 12 Setup Routing Unicast $ns rtproto : Static, Session, DV, cost, multi- path Multicast $ns multicast (right after [new Simulator]) $ns mrtproto : CtrMcast, DM, ST, BST

USC INFORMATION SCIENCES INSTITUTE 13 Creating Connection: UDP 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

USC INFORMATION SCIENCES INSTITUTE 14 Creating Traffic: On Top of UDP CBR set src [new Application/Traffic/CBR] Exponential or Pareto on-off set src [new Application/Traffic/Exponential] set src [new Application/Traffic/Pareto]

USC INFORMATION SCIENCES INSTITUTE 15 Creating Connection: TCP 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

USC INFORMATION SCIENCES INSTITUTE 16 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

USC INFORMATION SCIENCES INSTITUTE 17 Simple Simulation Example

USC INFORMATION SCIENCES INSTITUTE 18 TCL Script Step 1 #Create a simulator object set ns [new Simulator] #Define different colors for data flows (for NAM) $ns color 1 Blue $ns color 2 Red #Open the NAM trace file set nf [open out.nam w] $ns namtrace-all $nf #Open the All trace file Set f [open out.tr w] $ns trace-all $f

USC INFORMATION SCIENCES INSTITUTE 19 TCL Script Step 2 #Create four nodes set n0 [$ns node] set n1 [$ns node] set n2 [$ns node] set n3 [$ns node] #Create links between the nodes $ns duplex-link $n0 $n2 2Mb 10ms DropTail $ns duplex-link $n1 $n2 2Mb 10ms DropTail $ns duplex-link $n2 $n3 1.7Mb 20ms DropTail

USC INFORMATION SCIENCES INSTITUTE 20 TCL Script Step 3 # Set Queue Size of link (n2-n3) to 10 $ns queue-limit $n2 $n3 10 #Give node position (for NAM) $ns duplex-link-op $n0 $n2 orient right-down $ns duplex-link-op $n1 $n2 orient right-up $ns duplex-link-op $n2 $n3 orient right #Monitor the queue for link (n2-n3). (for NAM) $ns duplex-link-op $n2 $n3 queuePos 0.5

USC INFORMATION SCIENCES INSTITUTE 21 TCL Script Step 4 #Setup a TCP connection set tcp [new Agent/TCP] $ns attach-agent $n0 $tcp set sink [new Agent/TCPSink] $ns attach-agent $n3 $sink $ns connect $tcp $sink $tcp set fid_ 1 #Setup a FTP over TCP connection set ftp [new Application/FTP] $ftp attach-agent $tcp

USC INFORMATION SCIENCES INSTITUTE 22 TCL Script Step 5 #Setup a UDP connection set udp [new Agent/UDP] $ns attach-agent $n1 $udp set null [new Agent/Null] $ns attach-agent $n3 $null $ns connect $udp $null $udp set fid_ 2 #Setup a CBR over UDP connection set cbr [new Application/Traffic/CBR] $cbr attach-agent $udp $cbr set packet_size_ 1000 $cbr set rate_ 1mb

USC INFORMATION SCIENCES INSTITUTE 23 TCL Script Step 6 #Schedule events for the CBR and FTP agents $ns at 0.1 "$cbr start" $ns at 1.0 "$ftp start" $ns at 4.0 "$ftp stop" $ns at 4.5 "$cbr stop" #Call the finish procedure after 5 seconds of simulation time $ns at 5.0 "finish" #Print CBR packet size and interval puts "CBR packet size = [$cbr set packet_size_]" puts "CBR interval = [$cbr set interval_]"

USC INFORMATION SCIENCES INSTITUTE 24 TCL Script Step 7 #Define a 'finish' procedure proc finish {} { global ns nf $ns flush-trace #Close the NAM trace file close $nf #Execute NAM on the trace file exec nam out.nam & exit 0 } #Run the simulation $ns run

USC INFORMATION SCIENCES INSTITUTE 25 NS Directory map

USC INFORMATION SCIENCES INSTITUTE 26 ns Primer – Wired World Basic ns A complete example Multicast routing Visualization

USC INFORMATION SCIENCES INSTITUTE 27 G2 time 1.3s G2 time 1.2s G1 G2 time 1.35s Example: Multicast Routing Dynamic group membership under Dense Mode n0 n1 n2 n3 1.5Mb, 10ms G1 time 1.25s G2 1.5Mb, 10ms

USC INFORMATION SCIENCES INSTITUTE 28 Multicast: Step 1 Scheduler, tracing, and topology # Create scheduler set ns [new Simulator] # Turn on multicast $ns multicast # Turn on Tracing set fd [new “mcast.nam” w] $ns namtrace-all $fd

USC INFORMATION SCIENCES INSTITUTE 29 Multicast: Step 2 Topology # Create nodes set n0 [$ns node] set n1 [$ns node] set n2 [$ns node] set n3 [$ns node] # Create links $ns duplex-link $n0 $n1 1.5Mb 10ms DropTail $ns duplex-link $n0 $n2 1.5Mb 10ms DropTail $ns duplex-link $n0 $n3 1.5Mb 10ms DropTail

USC INFORMATION SCIENCES INSTITUTE 30 Multicast: Step 3 Routing and group setup # Routing protocol: let’s run distance vector $ns mrtproto DM # Allocate group addresses set group1 [Node allocaddr] set group2 [Node allocaddr]

USC INFORMATION SCIENCES INSTITUTE 31 Multicast: Step 4 Sender 0 # Transport agent for the traffic source set udp0 [new Agent/UDP] $ns attach-agent $n1 $udp0 $udp0 set dst_addr_ $group1 $udp0 set dst_port_ 0 # Constant Bit Rate source #0 set cbr0 [new Application/Traffic/CBR] $cbr0 attach-agent $udp0 # Start at time 1.0 second $ns at 1.0 "$cbr0 start"

USC INFORMATION SCIENCES INSTITUTE 32 Multicast: Step 5 Sender 1 # Transport agent for the traffic source set udp1 [new Agent/UDP] $ns attach-agent $n3 $udp1 $udp1 set dst_addr_ $group2 $udp1 set dst_port_ 0 # Constant Bit Rate source #0 set cbr1 [new Application/Traffic/CBR] $cbr1 attach-agent $udp1 # Start at time 1.1 second $ns at 1.1 "$cbr1 start"

USC INFORMATION SCIENCES INSTITUTE 33 Multicast: Step 6 Receiver with dynamic membership # Can also be Agent/Null set rcvr [new Agent/LossMonitor] # Assign it to node $n2 $ns at 1.2 "$n2 join-group $rcvr $group2" $ns at 1.25 "$n2 leave-group $rcvr $group2" $ns at 1.3 "$n2 join-group $rcvr $group2" $ns at 1.35 "$n2 join-group $rcvr $group1"

USC INFORMATION SCIENCES INSTITUTE 34 Multicast: Step 7 End-of-simulation wrapper (as usual) $ns at 2.0 "finish" proc finish {} { global ns fd close $fd $ns flush-trace puts "running nam..." exec nam out.nam & exit 0 } $ns run

USC INFORMATION SCIENCES INSTITUTE 35 ns Primer – Wired World Basic ns Two examples TCP, multicast routing Visualization

USC INFORMATION SCIENCES INSTITUTE 36 Visualization Tools nam-1 (Network AniMator Version 1) Packet-level animation Well supported by ns xgraph Conversion from ns trace to xgraph format

USC INFORMATION SCIENCES INSTITUTE 37 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

USC INFORMATION SCIENCES INSTITUTE 38 Multicast: Define nam color # Colors for packets from two mcast groups $ns color 10 blue $ns color 11 red # Prune packets (predefined) $ns color 30 purple # Graft packets $ns color 31 green

USC INFORMATION SCIENCES INSTITUTE 39 Tracefile for cwnd, rtt # trace file for RTT set f3 [open rtt.tr w] set tcp0 [new Agent/TCP] $tcp0 attach $f3 $tcp0 trace rtt_ # trace file for Congestion Window Size set f4 [open cwnd.tr w] set tcp0 [new Agent/TCP] $tcp0 attach $f4 $tcp0 trace cwnd_

USC INFORMATION SCIENCES INSTITUTE 40 GNUPLOT #simple.gnu set term x11 set xrange [0:200] set yrange [0:0.4] set xlabel 'Time (s)' set ylabel 'Throughput (Mbit/s)' plot 'blm.tr' title 'blm' with l 1, 'tcp.tr' title 'tcp' with l 5 set term postscript set output 'blm.ps' rep %gnuplot simple.gnu

USC INFORMATION SCIENCES INSTITUTE 41