NS-2 網路模擬器介紹與使用 吳賢明國立中興大學 計算機及資訊網路中心中華民國九十三年十月二十七日.

Slides:



Advertisements
Similar presentations
Vacha Dave, University of Texas at Austin 1 Network Simulator Tutorial Advanced Computer Networks (CS378)
Advertisements

Network Simulator and problems in installing. Introduction Problems in installing Wired networks modified example2.tcl commands in OTcl usual problems.
1 NS-2 Tutorial COMP R2 University of Manitoba March 4, 2009.
Katz, Stoica F04 EECS 122 Introduction to Computer Networks (Fall 2004) Network simulator 2 (ns-2) Department of Electrical Engineering and Computer Sciences.
NS2 Tutorial – Part II Internet Computing KUT Youn-Hee Han.
Wireless Communication : LAB 3
NS-2 (network simulator) NS by example παρουσίαση Κων/νος Τρούλος.
Ns Tutorial 成功大學電機所電腦與網路組 博士候選人 柯志亨
Wireless and Mobile Computing Simulations Lecture 27.
Introduction to Network Simulator NS-2 Part I
1 ns-2 Tutorial, part 2 Dave Anderson, Xiaowei Yang (Modified from Polly Huang’s slides)
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.
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.
NS TUTORIAL Padma Haldar USC/ISI 09/04/02.
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.
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)
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
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.
Date : 2010/11/23 Speaker : Chia-Wen Lu 1.  Network Simulation  Introduction to NS2  Simple Simulation Example 2.
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.
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 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.
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.
Network Simulator 2. Introduction Open source network simulator NS uses two languages: C++ and OTcl  C++ is fast to run but slower to change Kernel 
NS-2 Training 4/15/2013. Introduction  NS-2: Network Simulator Generation 2  Latest Release: 2.35 / Nov. 4, 2011 
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.
NS-2 Simulator 최 종 훈 Contents  About NS  Installation  Based on Linux  Based on Windows  Architecture  Using NS-2  Example  References.
ECE 6610 Sandeep Kakumanu GNAN research Lab
DMET 602: Networks and Media Lab
(Modified from Polly Huang’s and last year’s original)
Network Simulator Tutorial
NS-2 Training 4/12/2011.
Simulators for Sensor Networks
Choe, Hyun Jung (Stella)
Introduction to ns-2: “The” Network Simulator
Introduction to NS Srinath Perur.
Ns By Kulveer Singh.
Karthik Sadasivam Banuprasad Samudrala
Ns-3 Tutorial Xin Li.
Presentation transcript:

NS-2 網路模擬器介紹與使用 吳賢明國立中興大學 計算機及資訊網路中心中華民國九十三年十月二十七日

Agenda 淺談網路模擬 淺談網路模擬 NS2 簡介 NS2 簡介 NS2 架構、安裝與使用 NS2 架構、安裝與使用 視覺化實例演練 視覺化實例演練 Q&A Q&A

Methods for network research Analytical Analytical Model Model General expression or close form General expression or close form Emulation Emulation Network testbed Network testbed Lab environment Lab environment Real code Real code Simulation Simulation Virtual network testbed Virtual network testbed

Why Simulation Study of implemented protocols and algorithms Study of implemented protocols and algorithms Behavior Behavior Performance Performance Test of unimplemented new protocols and algorithms Test of unimplemented new protocols and algorithms Comparison of results across research efforts Comparison of results across research efforts

Simulation -- Advantage Inexpensive, Flexible and Reconfigurable Inexpensive, Flexible and Reconfigurable Network phenomena interested can be reproduced Network phenomena interested can be reproduced Opportunity to study large-scale network Opportunity to study large-scale network Easier comparison of results across research efforts Easier comparison of results across research efforts

Simulation -- Disadvantage Important network details may be missed Important network details may be missed Protocols or algorithms must be “added” before simulation can be done Protocols or algorithms must be “added” before simulation can be done High start-up cost High start-up cost Have to be carefully verified before the test results can be used Have to be carefully verified before the test results can be used

Network simulators Specific Purpose Specific Purpose ATM ATM Wireless Wireless TCP/IP TCP/IP General Purpose General Purpose Modifiable modules Modifiable modules Modules extensibility Modules extensibility

What features should a simulator provide ? Easy network topology setup Easy network topology setup Protocols and application implementation Protocols and application implementation TCP,UDP,… TCP,UDP,… FTP, Telnet, Web, CBR, VBR,… FTP, Telnet, Web, CBR, VBR,… Routing protocols Routing protocols Queue management protocols Queue management protocols Configurability Configurability Extensibility Extensibility

Agenda 淺談網路模擬 淺談網路模擬 NS2 簡介 NS2 簡介 NS2 架構、安裝與使用 NS2 架構、安裝與使用 視覺化實例演練 視覺化實例演練 Q&A Q&A

What is NS-2 NEST (Network Simulation Testbed)  REAL (Realistic and Large)  NS-1  NS-2 NEST (Network Simulation Testbed)  REAL (Realistic and Large)  NS-1  NS-2 NS-2 is a common network simulator NS-2 is a common network simulator NS-2 is developed by the VINT project in order to reduce duplication of effort within the network research and develop community NS-2 is developed by the VINT project in order to reduce duplication of effort within the network research and develop community NS2 is publicly available at NS2 is publicly available at

About NS2 1989: REAL network simulator 1989: REAL network simulatorREAL network simulatorREAL network simulator 1995: DARPA VINT project at LBL, Xerox PARC, UCB, and USC/ISI 1995: DARPA VINT project at LBL, Xerox PARC, UCB, and USC/ISIVINT projectVINT project Present: DARPA SAMAN project and NSF CONSER project Present: DARPA SAMAN project and NSF CONSER projectSAMAN CONSERSAMAN CONSER Collaboration with other researchers including CIRI Collaboration with other researchers including CIRI CIRI

Ns Status Periodical release (ns-2.27, Jan 2004) Periodical release (ns-2.27, Jan 2004) ~200K LOC in C++ and Otcl, ~200K LOC in C++ and Otcl, ~120 test suites and 100+ examples ~120 test suites and 100+ examples 392 pages of ns manual 392 pages of ns manual Daily snapshot (with auto-validation) Daily snapshot (with auto-validation) Stability validation Stability validation Platform support Platform support FreeBSD, Linux, Solaris, Windows and Mac FreeBSD, Linux, Solaris, Windows and Mac User base User base > 1k institutes (50 countries), >10k users > 1k institutes (50 countries), >10k users About 300 posts to every month About 300 posts to every

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

“ Ns ” Components Ns, the simulator itself Ns, the simulator itself Nam, the network animator Nam, the network animator Visualize ns (or other) output Visualize ns (or other) output Nam editor: GUI interface to generate ns scripts Nam editor: GUI interface to generate ns scripts Pre-processing: Pre-processing: Traffic and topology generators Traffic and topology generators Post-processing: Post-processing: Simple trace analysis, often in Awk, Perl, or Tcl Simple trace analysis, often in Awk, Perl, or Tcl

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

Agenda 淺談網路模擬 淺談網路模擬 NS2 簡介 NS2 簡介 NS2 架構、安裝與使用 NS2 架構、安裝與使用 視覺化實例演練 視覺化實例演練 Q&A Q&A

NS Architecture Split-Programming Model Split-Programming Model C++ C++ implement the simulation model implement the simulation model Implement data path Implement data path per packet processing, core of ns per packet processing, core of ns fast to run, detailed, complete control fast to run, detailed, complete control OTcl (Tcl script language with Object-oriented extensions developed at MIT ) OTcl (Tcl script language with Object-oriented extensions developed at MIT ) Simulation scenario configurations Simulation scenario configurations Periodic or triggered action Periodic or triggered action Manipulating existing C++ objects Manipulating existing C++ objects fast to write and change fast to write and change

NS Architecture Advantage Advantage Reusability Reusability Maintenance Maintenance Disadvantage Disadvantage Performance (speed and memory) Performance (speed and memory) Careful planning of modularity Careful planning of modularity

User ’ s view of NS2

Architecture view of NS2

Resources and Documentations NS2 and related component NS2 and related component Tcl release (required component) Tcl release (required component) Tk release (required component) Tk release (required component) Otcl release 1.8 (required component) Otcl release 1.8 (required component) TclCL release 1.15 (required component) TclCL release 1.15 (required component) Ns release 2.27 (required component) Ns release 2.27 (required component) Nam release 1.10 (optional component) Nam release 1.10 (optional component) Xgraph version 12 (optional component) Xgraph version 12 (optional component) CWeb version 3.4g (optional component) CWeb version 3.4g (optional component) SGB version 1.0 (?) (optional component, builds sgblib for all UNIX type platforms) SGB version 1.0 (?) (optional component, builds sgblib for all UNIX type platforms) Gt-itm gt-itm and sgb2ns 1.1 (optional component) Gt-itm gt-itm and sgb2ns 1.1 (optional component) Zlib version (optional, but required should Nam be used) Zlib version (optional, but required should Nam be used)

Resources and Documentation Getting the pieces Getting the pieces Tcl/TK 8.x (Tcl tk-8.4.5): Tcl/TK 8.x (Tcl tk-8.4.5): Otcl(1.8) and TclCL(1.15): Otcl(1.8) and TclCL(1.15): = =30174 ns-2 and nam-1: ns-2 and nam-1: All-at-once All-at-once

Resources and Documents Ns and nam build questions Ns and nam build questions Ns mailing list: Ns mailing list: Ns manual and tutorial (in distribution) Ns manual and tutorial (in distribution) TCL: TCL: Otcl tutorial (in distribution): ftp://ftp.tns.lcs.mit.edu/pub/otcl/doc/tutorial.html 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

Running ns-2 for Windows 9x/2000/XP under Cygwin Cygwin Cygwin Cygwin is a Linux-like environment for Windows Cygwin is a Linux-like environment for Windows ns-2 supports Cygwin ns-2 supports Cygwin Get Cygwin from Get Cygwin from ns-2 installation ns-2 installation From all pieces From all pieces All-at-once All-at-once

Cygwin Installation

ns-2 installation Get the file : tar.gz Get the file : tar.gzhttp:// tar.gzhttp:// tar.gz Install files Install files #tar zxvf ns-allinone-2.27.tar.gz ns-allinone-2.27.tar.gz #cd ns-allinone-2.27 #install Configure system Configure system Update user environment (~/.bashrc) Update user environment (~/.bashrc) export NS_HOME=/home/XXX/ns-allinone-2.27/ export PATH=$NS_HOME/tcl8.4.5/unix:$NS_HOME/tk8.4.5/unix:$NS_HOME/bin:$PATH export LD_LIBRARY_PATH=$NS_HOME/tcl8.4.5/unix:$NS_HOME/tk8.4.5/unix:\ $NS_HOME/otcl-1.8:$NS_HOME/lib:$LD_LIBRARY_PATH export TCL_LIBRARY=$NS_HOME/tcl8.4.5/library For detail, ref to : For detail, ref to :

ns-2 Directory Structure examples C++ source codes validation test Otcl source OTcl code

Tcl Basic – Hello World #Define a process named "helloworld" proc helloworld {} { puts "Hello world!!!" puts "Hello world!!!"} # Call the process helloworld Helloworld

Tcl Basic – Another Example proc pow {x n} { if {$n == 1} { return $x } if {$n == 1} { return $x } set part [pow $x [expr $n-1]] set part [pow $x [expr $n-1]] return [expr $x*$part] return [expr $x*$part]} set x 10 puts "x is $x" set y [pow $x 2] puts "y is $y" while { $x > 0 } { puts $x puts $x incr x -1 incr x -1}

OTcl - An Example from: # Create a class call "mom" and # add a member function call "greet" Class mom mom instproc greet {} { $self instvar age_ $self instvar age_ puts "$age_ years old mom say: puts "$age_ years old mom say: How are you doing?" How are you doing?"} # Create a child class of "mom" called "kid" # and overide the member function "greet" Class kid -superclass mom kid instproc greet {} { $self instvar age_ $self instvar age_ puts "$age_ years old kid say: puts "$age_ years old kid say: What's up, dude?" What's up, dude?"} # 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

Agenda 淺談網路模擬 淺談網路模擬 NS2 簡介 NS2 簡介 NS2 架構、安裝與使用 NS2 架構、安裝與使用 視覺化實例演練 視覺化實例演練 Q&A Q&A

Using ns Problem Simulation model Setup/run simulation with ns Result analysis Modify ns

TCP congestion control

Connection Initialization SSTHRESH Reached Slow Start Congestion Avoidance Fast Retransmission Congestion Notified Retransmit Timeout Exponential Backoff Timeout Again Congestion Window Reduced to 1

Simple Simulation Example I Display Result with nam Animation n0n1 tcp FTP sink FTP sec 1.7 mbps, 20 ms n2 2 mbps, 10 ms

#Create a simulator object set ns [new Simulator] #Define different colors for data flows (for NAM) $ns color 1 Blue #Open the NAM trace file set nf [open out.nam w] $ns namtrace-all $nf #Define a 'finish' procedure proc finish {} { global ns nf global ns nf $ns flush-trace $ns flush-trace #Close the NAM trace file #Close the NAM trace file close $nf close $nf #Execute NAM on the trace file #Execute NAM on the trace file exec nam out.nam & exec nam out.nam & exit 0 exit 0} #Create three nodes set n0 [$ns node] set n1 [$ns node] set n2 [$ns node] #Create links between the nodes $ns duplex-link $n0 $n1 1.7Mb 20ms DropTail $ns duplex-link $n2 $n0 2Mb 10ms DropTail #Set Queue Size of link (n0-n1) to 5 $ns queue-limit $n0 $n1 5 #Give node position (for NAM) $ns duplex-link-op $n0 $n1 orient right $ns duplex-link-op $n2 $n0 orient right #Monitor the queue for link (n0-n1). (for NAM) $ns duplex-link-op $n0 $n1 queuePos 0.5 #Setup a TCP connection set tcp [new Agent/TCP] $tcp set class_ 2 $ns attach-agent $n2 $tcp set sink [new Agent/TCPSink] $ns attach-agent $n1 $sink $ns connect $tcp $sink $tcp set fid_ 1 #Setup a FTP over TCP connection set ftp [new Application/FTP] $ftp attach-agent $tcp $ftp set type_ FTP #Schedule events for the FTP agents $ns at 0.5 "$ftp start" $ns at 3.0 "$ftp stop" #Call the finish procedure after 4 seconds of #simulation time $ns at 4.0 "finish" #Run the simulation $ns run Source of Example I

Simple Simulation Example II Display Result with nam Animation n0n1 tcp1 FTP1 sink1 FTP sec tcp2 FTP2 sink2 n2 n3 3.5 FTP2 2 mbps, 20 ms 2 mbps, 10 ms

….. #Create four nodes …. #Create links between the nodes …. #Set Queue Size of link (n0-n1) to 5 …. #Give node position (for NAM) …. #Monitor the queue for link (n0-n1). (for NAM) …. #Setup a TCP connection set tcp1 [new Agent/TCP] set tcp2 [new Agent/TCP] $tcp1 set class_ 2 $tcp2 set class_ 2 $ns attach-agent $n2 $tcp1 $ns attach-agent $n3 $tcp2 set sink1 [new Agent/TCPSink] set sink2 [new Agent/TCPSink] $ns attach-agent $n1 $sink1 $ns attach-agent $n1 $sink2 $ns connect $tcp1 $sink1 $ns connect $tcp2 $sink2 $tcp1 set fid_ 1 $tcp2 set fid_ 2 #Setup two FTP over TCP connection set ftp1 [new Application/FTP] set ftp2 [new Application/FTP] $ftp1 attach-agent $tcp1 $ftp2 attach-agent $tcp2 $ftp1 set type_ FTP $ftp2 set type_ FTP #Schedule events for the FTP agents $ns at 0 "$ftp2 start" $ns at 0.5 "$ftp1 start" $ns at 3.0 "$ftp1 stop" $ns at 3.5 "$ftp2 stop" #Call the finish procedure after 4 seconds of #simulation time $ns at 4.0 "finish" #Run the simulation $ns run Source of Example II

Simple Simulation Example III Display Result with nam Animation n0n1 tcp FTP sink1 ftp sec udp cbr null n2 n3 3.5 cbr 2 mbps, 20 ms 2 mbps, 10 ms Size : 1 kByte Rate: 1 mbps

…. #Setup a TCP connection set tcp [new Agent/TCP] $tcp set class_ 2 $ns attach-agent $n2 $tcp set sink [new Agent/TCPSink] $ns attach-agent $n1 $sink $ns connect $tcp $sink $tcp set fid_ 1 #Setup a FTP over TCP connection set ftp [new Application/FTP] $ftp attach-agent $tcp $ftp set type_ FTP #Setup a UDP connection set udp [new Agent/UDP] $ns attach-agent $n3 $udp set null [new Agent/Null] $ns attach-agent $n1 $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 type_ CBR $cbr set packet_size_ 1000 $cbr set rate_ 1mb $cbr set random_ false #Schedule events for the CBR and FTP agents $ns at 0 "$cbr start" $ns at 0.5 "$ftp start" $ns at 3.0 "$ftp stop" $ns at 3.5 "$cbr stop" #Call the finish procedure after 4 seconds of #simulation time $ns at 4.0 "finish" #Print CBR packet size and interval puts "CBR packet size = [$cbr set packet_size_]" puts "CBR interval = [$cbr set interval_]" #Run the simulation $ns run Source of Example III

Trace Analysis Open NAM trace file Open NAM trace file set nam_file_var [open out_nam_file w] $ns namtrace-all $file_var Open raw data trace file Open raw data trace file set data_file_var [open out_data_file w] $ns trace-all $data_file_var

NAM trace file example …. V -t * -v 1.0a5 -a 0 A -t * -n 1 -p 0 -o 0xffffffff -c 31 -a 1 A -t * -h 1 -m s 0 c -t * -i 1 -n Blue n -t * -a 0 -s 0 -S UP -v circle -c black -i black n -t * -a 1 -s 1 -S UP -v circle -c black -i black n -t * -a 2 -s 2 -S UP -v circle -c black -i black l -t * -s 0 -d 1 -S UP -r D c black -o right l -t * -s 2 -d 0 -S UP -r D c black -o right q -t * -s 1 -d 0 -a 0.5 q -t * -s 0 -d 1 -a t 0.5 -s 2 -d 0 -p tcp -e 40 -c 1 -i 0 -a 1 -x { null} - -t 0.5 -s 2 -d 0 -p tcp -e 40 -c 1 -i 0 -a 1 -x { null} h -t 0.5 -s 2 -d 0 -p tcp -e 40 -c 1 -i 0 -a 1 -x { null} r -t s 2 -d 0 -p tcp -e 40 -c 1 -i 0 -a 1 -x { null} + -t s 0 -d 1 -p tcp -e 40 -c 1 -i 0 -a 1 -x { null} - -t s 0 -d 1 -p tcp -e 40 -c 1 -i 0 -a 1 -x { null} h -t s 0 -d 1 -p tcp -e 40 -c 1 -i 0 -a 1 -x { null} …. Read and interpreted by NAM for animation display

Raw data trace file format and example (from example III) … cbr cbr r cbr cbr cbr r cbr cbr cbr r cbr cbr cbr r cbr …. eventtimefromnodetonodepkttypepktsizeflagsfidsrcaddrdstaddrseqnumpktid r : receive (at to node) +: enqueue (at queue) - : dequeue (at queue) d : drop (at queue) node.port

Jitter Monitor

RED Queue Monitor Example An example by Polly Huang from r1r2 tcp1 ftp1 sink1 ftp sec tcp2 ftp2 sink2 s1 s2 ftp1 1.5 mbps, 20 ms 10 mbps, 2 ms 10 mbps, 3 ms 0 s3 max_win=15 max_win=15 RED(size=25) 10 mbps, 4 ms

.... set tcp1 [$ns create-connection TCP/Reno $node_(s1) TCPSink $node_(s3) 0] $tcp1 set window_ 15 set tcp2 [$ns create-connection TCP/Reno $node_(s2) TCPSink $node_(s3) 1] $tcp2 set window_ 15 set ftp1 [$tcp1 attach-source FTP] set ftp2 [$tcp2 attach-source FTP] # Tracing a queue set redq [[$ns link $node_(r1) $node_(r2)] queue] set tchan_ [open all.q w] $redq trace curq_ $redq trace ave_ $redq attach $tchan_.... proc finish {} { global tchan_ global tchan_ set awkCode { set awkCode {{ if ($1 == "Q" && NF>2) { if ($1 == "Q" && NF>2) { print $2, $3 >> "temp.q"; set end $2 } else if ($1 == "a" && NF>2) else if ($1 == "a" && NF>2) print $2, $3 >> "temp.a"; print $2, $3 >> "temp.a";} } set f [open temp.queue w] puts $f "TitleText: red" puts $f "Device: Postscript" if { [info exists tchan_] } { close $tchan_ } exec rm -f temp.q temp.a exec touch temp.a temp.q exec awk $awkCode all.q puts $f \"queue exec cat temp.q $f puts $f \n\"ave_queue exec cat temp.a $f close $f exec xgraph -bb -tk -x time -y queue temp.queue & exit 0 } $ns run

RED Queue Monitor Example

More … OTcl linkage (with C++ classes) OTcl linkage (with C++ classes) Variable export Variable export Control command export Control command export Recompilation Recompilation Extend NS-2 Extend NS-2 Modify existed object Modify existed object Add new application Add new application Add new agent Add new agent … NS-2 main page NS-2 main page

Q & A