University of Texas at Arlington CSE 5346/4346 High Performance Networks 1 NS-2 Tutorial Choe, Hyun...
-
Upload
berenice-hodge -
Category
Documents
-
view
213 -
download
0
Transcript of University of Texas at Arlington CSE 5346/4346 High Performance Networks 1 NS-2 Tutorial Choe, Hyun...
![Page 1: 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.](https://reader035.fdocuments.net/reader035/viewer/2022070418/5697bfae1a28abf838c9c6b6/html5/thumbnails/1.jpg)
University of Texas at Arlington
CSE 5346/4346 High Performance Networks
1
NS-2 TutorialNS-2 Tutorial
Choe, Hyun Jung (Stella)Choe, Hyun Jung (Stella) Spring 2008Spring 2008
High Performance NetworksHigh Performance NetworksDepartment of Computer Science and EngineeringDepartment of Computer Science and Engineering
The University of Texas at ArlingtonThe University of Texas at Arlington
![Page 2: 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.](https://reader035.fdocuments.net/reader035/viewer/2022070418/5697bfae1a28abf838c9c6b6/html5/thumbnails/2.jpg)
University of Texas at Arlington
CSE 5346/4346 High Performance Networks
2
OutlineOutline
• NS-2 Overview
• How to Run NS-2
• How to Program
• Simulation Examples
• Project Overview
• Q & A
![Page 3: 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.](https://reader035.fdocuments.net/reader035/viewer/2022070418/5697bfae1a28abf838c9c6b6/html5/thumbnails/3.jpg)
University of Texas at Arlington
NS-2 OverviewNS-2 Overview
![Page 4: 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.](https://reader035.fdocuments.net/reader035/viewer/2022070418/5697bfae1a28abf838c9c6b6/html5/thumbnails/4.jpg)
University of Texas at Arlington
CSE 5346/4346 High Performance Networks
4
What is NS-2?What is NS-2?
• VINT Project
- UC Berkeley, LBL, USC/ISI, and Xerox PARC
• Goals
- Support networking research and education
- Freely distributed, open source Share code, protocols, models, etc
• a Discrete Event Simulator
• Link layer and up
• Wired and Wireless
![Page 5: 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.](https://reader035.fdocuments.net/reader035/viewer/2022070418/5697bfae1a28abf838c9c6b6/html5/thumbnails/5.jpg)
University of Texas at Arlington
CSE 5346/4346 High Performance Networks
5
NS ModelsNS Models
•Wired- Routing: DV, LS, PIM-SM etc.- Transportation: TCP and UDP- Traffic sources: web, ftp, telnet, cbr, stochastic
etc.- Queuing disciplines: drop-tail, RED, FQ, SFQ, DRR
etc.- QoS: IntServ and Diffserv …- Emulation
• Wireless- Ad hoc routing, mobile IP and Satellite- Directed diffusion, sensor-MAC
![Page 6: 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.](https://reader035.fdocuments.net/reader035/viewer/2022070418/5697bfae1a28abf838c9c6b6/html5/thumbnails/6.jpg)
University of Texas at Arlington
CSE 5346/4346 High Performance Networks
6
NS ArchitectureNS Architecture
• Object-oriented (C++, OTcl)
• data / control separation- C++ for data:
per packet processing, core of ns
fast to run, detailed, complete control
- OTcl for control: Simulation scenario configurations
Periodic or triggered action
Manipulating existing C++ objects
fast to write and change
![Page 7: 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.](https://reader035.fdocuments.net/reader035/viewer/2022070418/5697bfae1a28abf838c9c6b6/html5/thumbnails/7.jpg)
University of Texas at Arlington
CSE 5346/4346 High Performance Networks
7
OTcl and C++: The DualityOTcl and C++: The Duality
C++
otcl
C++/OTcl split objects Pure C++
objects
Pure OTclobjects
! OTcl (object variant of Tcl) and C++ share class hierarchy !
![Page 8: 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.](https://reader035.fdocuments.net/reader035/viewer/2022070418/5697bfae1a28abf838c9c6b6/html5/thumbnails/8.jpg)
University of Texas at Arlington
CSE 5346/4346 High Performance Networks
8
NS ComponentsNS Components
- visualize ns (or other) outputPre-processing:- Traffic and topology generators
Post-processing:- simple trace analysis, often in Tcl, Awk or Perl
![Page 9: 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.](https://reader035.fdocuments.net/reader035/viewer/2022070418/5697bfae1a28abf838c9c6b6/html5/thumbnails/9.jpg)
University of Texas at Arlington
Part II: How to Run NS-2Part II: How to Run NS-2
![Page 10: 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.](https://reader035.fdocuments.net/reader035/viewer/2022070418/5697bfae1a28abf838c9c6b6/html5/thumbnails/10.jpg)
University of Texas at Arlington
CSE 5346/4346 High Performance Networks
10
How to Run NS-2How to Run NS-2
① gamma2 server- Version: 2.30- Please use /tmp for your trace files (not codes)
(later)- xdisplay for graphical results
② If you want to install NS2 in your own PC- Current release: ns-2.31, Mar 10, 2007)
http://www.isi.edu/nsnam/ns/ns-build.html
- Platforms Most Unix and Linux Windows and Mac
![Page 11: 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.](https://reader035.fdocuments.net/reader035/viewer/2022070418/5697bfae1a28abf838c9c6b6/html5/thumbnails/11.jpg)
University of Texas at Arlington
CSE 5346/4346 High Performance Networks
11
How to Setup PathHow to Setup Path
• ls –a• .cshrcsetenv LD_LIBRARY_PATH /opt/ns-allinone-2.30/…
• .bash_profileexport PATH=/opt/ns-allinone-2.30/bin:$PATHexport LD_LIBRARY_PATH=/opt/ns-allinone-2.30/otcl-1.12:/opt/ns-allinone-2.30/lib:$LD_LIBRARY_PATH
export TCL_LIBRARY=/opt/ns-allinone-2.30/tcl8.4.13/library
![Page 12: 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.](https://reader035.fdocuments.net/reader035/viewer/2022070418/5697bfae1a28abf838c9c6b6/html5/thumbnails/12.jpg)
University of Texas at Arlington
CSE 5346/4346 High Performance Networks
12
gamma /tmp gamma /tmp
• for Temporary Usage only- Do Not save your scripts under /tmp
• Use Your Own directory- mkdir /tmp/your_dir/
• Exampleset nf [open /tmp/your_dir/out.nam w]
![Page 13: 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.](https://reader035.fdocuments.net/reader035/viewer/2022070418/5697bfae1a28abf838c9c6b6/html5/thumbnails/13.jpg)
University of Texas at Arlington
CSE 5346/4346 High Performance Networks
13
How to Install NS-2 (Under How to Install NS-2 (Under Windows)Windows)• http://nsnam.isi.edu/nsnam/index.php/Running_Ns_a
nd_Nam_Under_Windows_9x/2000/XP_Using_Cygwin
• Cygwin-1.3.12 or later required Select “UNIX” text type to check current mode, type “mount | grep textmode” C:\Cygwin (not C:\Program Files\Cygwin) “Install” <X11> and <Devel> Categories (next page)
and others (e.g., vim) in <Editor> Download NS-2 under Cygwin (E.g., under /usr/local/)• tar zxvf ns-allinone-2.2x.x.tar.gz• cd ns-allinone-2.2x• ./install
![Page 14: 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.](https://reader035.fdocuments.net/reader035/viewer/2022070418/5697bfae1a28abf838c9c6b6/html5/thumbnails/14.jpg)
University of Texas at Arlington
CSE 5346/4346 High Performance Networks
14
![Page 15: 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.](https://reader035.fdocuments.net/reader035/viewer/2022070418/5697bfae1a28abf838c9c6b6/html5/thumbnails/15.jpg)
University of Texas at Arlington
CSE 5346/4346 High Performance Networks
15
Error?Error?
• error near unexpected token `)'./configure: line 7624: ` OSF*)'tcl8.3.2 configuration failed! Exiting ...Tcl is not part of the ns project. Please see
www.Scriptics.comto see if they have a fix for your platform.
- Remove ‘ only if there are two ‘ at the end of relid
- find . | xargs -n 1 grep -H relid\‘
• Others-
http://ns-2.blogspot.com/2006/05/problem-in-installing-ns-2292-allinone.html
- http://www.isi.edu/nsnam/ns/ns-cygwin-old.html
![Page 16: 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.](https://reader035.fdocuments.net/reader035/viewer/2022070418/5697bfae1a28abf838c9c6b6/html5/thumbnails/16.jpg)
University of Texas at Arlington
CSE 5346/4346 High Performance Networks
16
How to Use Cygwin-XHow to Use Cygwin-X
• http://xfree86.cygwin.com/docs/ug//usr/X11R6/
• Run /usr/X11R6/bin/startxwin.bat
• % sh /usr/X11R6/bin/startxwin.sh
• % cp /etc/X11/xinit/xinitrc ~/.xinitrc
• PATH=%PATH:/usr/X11R6/bin
• % startx &
![Page 17: 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.](https://reader035.fdocuments.net/reader035/viewer/2022070418/5697bfae1a28abf838c9c6b6/html5/thumbnails/17.jpg)
University of Texas at Arlington
CSE 5346/4346 High Performance Networks
17
NS-2 Directory StructureNS-2 Directory Structure
TK8.4.13 OTcl tclclTcl8.4.13 ns-2 nam-1.12
tcl
ex test lib
...
...
examples validation tests
C++ code
OTcl code
ns-allinone
mcast
/opt/ns-allinone-2.30/
...
![Page 18: 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.](https://reader035.fdocuments.net/reader035/viewer/2022070418/5697bfae1a28abf838c9c6b6/html5/thumbnails/18.jpg)
University of Texas at Arlington
Part III: How to ProgramPart III: How to Program
![Page 19: 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.](https://reader035.fdocuments.net/reader035/viewer/2022070418/5697bfae1a28abf838c9c6b6/html5/thumbnails/19.jpg)
University of Texas at Arlington
CSE 5346/4346 High Performance Networks
19
Basic Tcl ProgrammingBasic Tcl Programming
• set b 0- “b = 0” in C
• set x $b• set x [expr $a + $b]
• http://www-sop.inria.fr/maestro/personnel/Eitan.Altman/COURS-NS/n3.pdf
•
![Page 20: 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.](https://reader035.fdocuments.net/reader035/viewer/2022070418/5697bfae1a28abf838c9c6b6/html5/thumbnails/20.jpg)
University of Texas at Arlington
CSE 5346/4346 High Performance Networks
20
Basic TclBasic Tcl
# Command arg1 arg2 arg3 …set a 43set b 27proc 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]” } }}
![Page 21: 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.](https://reader035.fdocuments.net/reader035/viewer/2022070418/5697bfae1a28abf838c9c6b6/html5/thumbnails/21.jpg)
University of Texas at Arlington
CSE 5346/4346 High Performance Networks
21
Elements of NS-2Elements of NS-2
• Create the event scheduler
• [Turn on tracing]
• Create network
• Setup routing
• Insert errors
• Create transport connection
• Create traffic
• Transmit application-level data
![Page 22: 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.](https://reader035.fdocuments.net/reader035/viewer/2022070418/5697bfae1a28abf838c9c6b6/html5/thumbnails/22.jpg)
University of Texas at Arlington
CSE 5346/4346 High Performance Networks
22
How to SimulateHow to Simulate
•Create event scheduler- set ns [new Simulator]
• Schedule events- $ns at <time> <event>
<event>:any legitimate ns/tcl commands
- $ns at 5.0 “finish”
• Start scheduler- $ns run
• TclCL- C++ and OTcl linkage - glue library that makes it easy to share
functions, variables, etc
NS-2NS-2
Tcl
OTcl
TclCL
Event
Sch
edu
ler
Network Components
C/C++
![Page 23: 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.](https://reader035.fdocuments.net/reader035/viewer/2022070418/5697bfae1a28abf838c9c6b6/html5/thumbnails/23.jpg)
University of Texas at Arlington
CSE 5346/4346 High Performance Networks
23
Example: Example: helloWorld.tclhelloWorld.tcl
set ns [new Simulator]
$ns at 1 “puts \“Hello World!\””
$ns at 1.5 “exit”
$ns run
% ns simple.tcl
Hello World!
%
![Page 24: 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.](https://reader035.fdocuments.net/reader035/viewer/2022070418/5697bfae1a28abf838c9c6b6/html5/thumbnails/24.jpg)
University of Texas at Arlington
CSE 5346/4346 High Performance Networks
24
Creating NetworkCreating Network
• 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- $ns duplex-link-op $no $n1 OPTIONS
n0 n1
![Page 25: 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.](https://reader035.fdocuments.net/reader035/viewer/2022070418/5697bfae1a28abf838c9c6b6/html5/thumbnails/25.jpg)
University of Texas at Arlington
CSE 5346/4346 High Performance Networks
25
Setup RoutingSetup Routing
• Unicast- $ns rtproto <type>- <type>: Static, Session, DV, cost, multi-path
• Multicast- $ns multicast (right after [new Simulator])- $ns mrtproto <type>- <type>: CtrMcast, DM, ST, BST
![Page 26: 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.](https://reader035.fdocuments.net/reader035/viewer/2022070418/5697bfae1a28abf838c9c6b6/html5/thumbnails/26.jpg)
University of Texas at Arlington
CSE 5346/4346 High Performance Networks
26
Creating Connection: UDPCreating 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
n0 n1UDP null
![Page 27: 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.](https://reader035.fdocuments.net/reader035/viewer/2022070418/5697bfae1a28abf838c9c6b6/html5/thumbnails/27.jpg)
University of Texas at Arlington
CSE 5346/4346 High Performance Networks
27
Creating Traffic: On Top of UDPCreating Traffic: On Top of UDP
• CBR- set src [new Application/Traffic/CBR]- $src attach-agent $udp0
• Exponential or Pareto on-off- set src [new Application/Traffic/Exponential]- set src [new Application/Traffic/Pareto]- $src attach-agent $udp0
n0 n1UDP null
CBR
![Page 28: 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.](https://reader035.fdocuments.net/reader035/viewer/2022070418/5697bfae1a28abf838c9c6b6/html5/thumbnails/28.jpg)
University of Texas at Arlington
CSE 5346/4346 High Performance Networks
28
Structure of a Unicast NodeStructure of a Unicast Node
![Page 29: 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.](https://reader035.fdocuments.net/reader035/viewer/2022070418/5697bfae1a28abf838c9c6b6/html5/thumbnails/29.jpg)
University of Texas at Arlington
CSE 5346/4346 High Performance Networks
29
Structure of a Simplex LinkStructure of a Simplex Link
![Page 30: 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.](https://reader035.fdocuments.net/reader035/viewer/2022070418/5697bfae1a28abf838c9c6b6/html5/thumbnails/30.jpg)
University of Texas at Arlington
CSE 5346/4346 High Performance Networks
30
Creating Connection: TCPCreating 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
n0 n1TCP sink
![Page 31: 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.](https://reader035.fdocuments.net/reader035/viewer/2022070418/5697bfae1a28abf838c9c6b6/html5/thumbnails/31.jpg)
University of Texas at Arlington
CSE 5346/4346 High Performance Networks
31
Creating Traffic: On Top of TCPCreating 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
n0 n1TCP sink
FTP
![Page 32: 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.](https://reader035.fdocuments.net/reader035/viewer/2022070418/5697bfae1a28abf838c9c6b6/html5/thumbnails/32.jpg)
University of Texas at Arlington
CSE 5346/4346 High Performance Networks
32
A simulation exampleA simulation example
n0
n1
n2 n3
n4
n5
tcp
tcp
sink
sink
ftp
ftp
5Mb, 15ms10Mb,2ms 10Mb,2ms
W=32
W=32
![Page 33: 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.](https://reader035.fdocuments.net/reader035/viewer/2022070418/5697bfae1a28abf838c9c6b6/html5/thumbnails/33.jpg)
University of Texas at Arlington
CSE 5346/4346 High Performance Networks
33
TCP AgentsTCP Agents
• ns has several variants of TCP available: - -- Agent/TCP/Tahoe a ``tahoe'' TCP sender - -- Agent/TCP/Reno a ``Reno'' TCP sender - -- Agent/TCP/NewReno Reno with a modification - -- Agent/TCP/Sack1 TCP with selective repeat (follows RFC2018) - -- Agent/TCP/Vegas TCP Vegas - -- Agent/TCP/Fack Reno TCP with ``forward acknowledge ment''
• The oneway TCP receiving agents currently supported are: - -- Agent/TCPSink TCP sink with one ACK per packet - -- Agent/TCPSink/DelAck TCP sink with configurable delay per ACK - -- Agent/TCPSink/Sack1 selective ACK sink (follows RFC2018) - -- Agent/TCPSink/Sack1/DelAck Sack1 with DelAck
• The twoway experimental sender currently supports only a Reno form of TCP: - -- Agent/TCP/FullTcp
![Page 34: 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.](https://reader035.fdocuments.net/reader035/viewer/2022070418/5697bfae1a28abf838c9c6b6/html5/thumbnails/34.jpg)
University of Texas at Arlington
CSE 5346/4346 High Performance Networks
34
TCP Agent ParametersTCP Agent Parameters
• Agent/TCP set tcpTick— 0.1 ;# timer granularity in sec (.1 is NONST ANDARD)
• Agent/TCP set maxrto— 64 ;# bound on RTO (seconds) • Agent/TCP set dupacks— 0 ;# duplicate ACK counter
• Agent/TCP set ack— 0 ;# highest ACK received
• Agent/TCP set cwnd— 0 ;# congestion window (packets)
• Agent/TCP set awnd— 0 ;# averaged cwnd (experimental) • Agent/TCP set ssthresh— 0 ;# slowstat threshold (packets) • Agent/TCP set rtt— 0 ;# rtt sample
• Agent/TCP set srtt— 0 ;# smoothed (averaged) rtt • Agent/TCP set rttvar— 0 ;# mean deviation of rtt samples • Agent/TCP set backoff— 0 ;# current RTO backoff factor • Agent/TCP set maxseq— 0 ;# max (packet) seq number sent
![Page 35: 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.](https://reader035.fdocuments.net/reader035/viewer/2022070418/5697bfae1a28abf838c9c6b6/html5/thumbnails/35.jpg)
University of Texas at Arlington
CSE 5346/4346 High Performance Networks
35
Tracing and Monitoring ITracing and Monitoring I
• Trace packets on all links • #Open the NAM trace file #Open the Trace file
- set nf [open out.nam w] set tf [open out.tr w]
- $ns namtrace-all $nf $ns trace-all $tf
• Must appear immediately after creating scheduler• Turn on tracing on specific links
- $ns trace-queue $n0 $n1- $ns namtrace-queue $n0 $n1
• Event tracing (support TCP right now)- Record “event” in trace file: $ns eventtrace-all
![Page 36: 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.](https://reader035.fdocuments.net/reader035/viewer/2022070418/5697bfae1a28abf838c9c6b6/html5/thumbnails/36.jpg)
University of Texas at Arlington
CSE 5346/4346 High Performance Networks
36
Tracing and Monitoring IITracing and Monitoring II
![Page 37: 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.](https://reader035.fdocuments.net/reader035/viewer/2022070418/5697bfae1a28abf838c9c6b6/html5/thumbnails/37.jpg)
University of Texas at Arlington
CSE 5346/4346 High Performance Networks
37
Tracing and Monitoring IIITracing and Monitoring III
• Queue monitor set qmon [$ns monitor-queue $n0 $n1 $q_f $sample_interval] - Get statistics for a queue
$qmon set pdrops_
- Record to trace file as an optional29.000000000000142 0 1 0.0 0.0 4 4 0 1160 1160 0
• Flow monitorset fmon [$ns_ makeflowmon Fid]$ns_ attach-fmon $slink $fmon$fmon set pdrops_
![Page 38: 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.](https://reader035.fdocuments.net/reader035/viewer/2022070418/5697bfae1a28abf838c9c6b6/html5/thumbnails/38.jpg)
University of Texas at Arlington
CSE 5346/4346 High Performance Networks
38
Tracing and Monitoring IVTracing and Monitoring IV
• Variable tracing in namAgent/TCP set nam_tracevar_ true$tcp tracevar srtt_$tcp tracevar cwnd_
• Monitor agent variables in nam$ns add-agent-trace $tcp $tcp$ns add-agent-trace $tcp $tcp$ns monitor-agent-trace $tcp$ns monitor-agent-trace $tcp$srm0 tracevar cwnd_$srm0 tracevar cwnd_…………$ns delete-agent-trace $tcp$ns delete-agent-trace $tcp
![Page 39: 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.](https://reader035.fdocuments.net/reader035/viewer/2022070418/5697bfae1a28abf838c9c6b6/html5/thumbnails/39.jpg)
University of Texas at Arlington
CSE 5346/4346 High Performance Networks
39
Visualization ToolsVisualization Tools
• nam-1 (Network AniMator Version 1)- Packet-level animation- Well supported by ns
• xgraph- Conversion from ns trace to xgraph format
![Page 40: 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.](https://reader035.fdocuments.net/reader035/viewer/2022070418/5697bfae1a28abf838c9c6b6/html5/thumbnails/40.jpg)
University of Texas at Arlington
CSE 5346/4346 High Performance Networks
40
xgraphxgraph
• The xgraph program draws a graph on an X display given data read from either data files. - To run it: xgraph dataFileName
• You can save the hardcopy of the graph as a postscript file.
• Xgraph is available on gamma:
- /opt/ns-allinone-2.30/xgraph-12.1
![Page 41: 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.](https://reader035.fdocuments.net/reader035/viewer/2022070418/5697bfae1a28abf838c9c6b6/html5/thumbnails/41.jpg)
University of Texas at Arlington
CSE 5346/4346 High Performance Networks
41
namnam
• Basic visualization- Topology layout- Animation control- Synchronous replay
• Fine-tune layout• TCP/SRM visualization• Editor: generate ns simulation scripts
![Page 42: 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.](https://reader035.fdocuments.net/reader035/viewer/2022070418/5697bfae1a28abf838c9c6b6/html5/thumbnails/42.jpg)
University of Texas at Arlington
CSE 5346/4346 High Performance Networks
42
nsnsnam Interfacenam Interface
• Color• Node manipulation• Link manipulation• Topology layout• Protocol state• Misc
![Page 43: 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.](https://reader035.fdocuments.net/reader035/viewer/2022070418/5697bfae1a28abf838c9c6b6/html5/thumbnails/43.jpg)
University of Texas at Arlington
CSE 5346/4346 High Performance Networks
43
nam Interface: Colornam Interface: Color
• Color mapping$ns color 1 red$ns color 1 red
$ns color 2 blue$ns color 2 blue
$ns color 3 chocolate$ns color 3 chocolate
• Color flow id association$tcp0 set fid_ 1$tcp0 set fid_ 1 ;# red packets;# red packets
$tcp1 set fid_ 2$tcp1 set fid_ 2 ;# blue packets;# blue packets
![Page 44: 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.](https://reader035.fdocuments.net/reader035/viewer/2022070418/5697bfae1a28abf838c9c6b6/html5/thumbnails/44.jpg)
University of Texas at Arlington
CSE 5346/4346 High Performance Networks
44
nam Interface: Nodesnam Interface: Nodes
• Color$node color red$node color red
• Shape (can’t be changed after sim starts)$node shape box$node shape box ;# circle, box, hexagon;# circle, box, hexagon
• Marks (concentric “shapes”)$ns at 1.0 “$n0 add-mark m0 blue box”$ns at 1.0 “$n0 add-mark m0 blue box”
$ns at 2.0 “$n0 delete-mark m0”$ns at 2.0 “$n0 delete-mark m0”
• Label (single string)$ns at 1.1 “$n0 label \”web cache 0\””$ns at 1.1 “$n0 label \”web cache 0\””
![Page 45: 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.](https://reader035.fdocuments.net/reader035/viewer/2022070418/5697bfae1a28abf838c9c6b6/html5/thumbnails/45.jpg)
University of Texas at Arlington
CSE 5346/4346 High Performance Networks
45
nam Interfaces: Linksnam Interfaces: Links
• Color$ns duplex-link-op $n0 $n1 color "green"$ns duplex-link-op $n0 $n1 color "green"
• Label$ns duplex-link-op $n0 $n1 label "abced"$ns duplex-link-op $n0 $n1 label "abced"
• Dynamics (automatically handled)$ns rtmodel Deterministic {2.0 0.9 0.1} $n0 $n1$ns rtmodel Deterministic {2.0 0.9 0.1} $n0 $n1
• Asymmetric links not allowed
![Page 46: 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.](https://reader035.fdocuments.net/reader035/viewer/2022070418/5697bfae1a28abf838c9c6b6/html5/thumbnails/46.jpg)
University of Texas at Arlington
CSE 5346/4346 High Performance Networks
46
nam Interface: Topo Layoutnam Interface: Topo Layout
• “Manual” layout: specify everything
$ns duplex-link-op $n(0) $n(1) orient right$ns duplex-link-op $n(0) $n(1) orient right
$ns duplex-link-op $n(1) $n(2) orient right$ns duplex-link-op $n(1) $n(2) orient right
$ns duplex-link-op $n(2) $n(3) orient right$ns duplex-link-op $n(2) $n(3) orient right
$ns duplex-link-op $n(3) $n(4) orient 60deg$ns duplex-link-op $n(3) $n(4) orient 60deg
• If anything missing automatic layout
![Page 47: 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.](https://reader035.fdocuments.net/reader035/viewer/2022070418/5697bfae1a28abf838c9c6b6/html5/thumbnails/47.jpg)
University of Texas at Arlington
CSE 5346/4346 High Performance Networks
47
nam Interface: Protocol Statenam Interface: Protocol State
• Monitor values of agent variables
$ns add-agent-trace $srm0 srm_agent0$ns add-agent-trace $srm0 srm_agent0
$ns monitor-agent-trace $srm0$ns monitor-agent-trace $srm0
$srm0 tracevar C1_$srm0 tracevar C1_
$srm0 tracevar C2_$srm0 tracevar C2_
# … …# … …
$ns delete-agent-trace $tcp1$ns delete-agent-trace $tcp1
![Page 48: 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.](https://reader035.fdocuments.net/reader035/viewer/2022070418/5697bfae1a28abf838c9c6b6/html5/thumbnails/48.jpg)
University of Texas at Arlington
CSE 5346/4346 High Performance Networks
48
nam Interface: Miscnam Interface: Misc
• Annotation- Add textual explaination to your sim
$ns at 3.5 "$ns trace-annotate \“packet drop\"“$ns at 3.5 "$ns trace-annotate \“packet drop\"“
• Set animation rate
$ns at 0.0 "$ns set-animation-rate 0.1ms"$ns at 0.0 "$ns set-animation-rate 0.1ms"
![Page 49: 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.](https://reader035.fdocuments.net/reader035/viewer/2022070418/5697bfae1a28abf838c9c6b6/html5/thumbnails/49.jpg)
University of Texas at Arlington
CSE 5346/4346 High Performance Networks
49
![Page 50: 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.](https://reader035.fdocuments.net/reader035/viewer/2022070418/5697bfae1a28abf838c9c6b6/html5/thumbnails/50.jpg)
University of Texas at Arlington
CSE 5346/4346 High Performance Networks
50
Summary: Generic Script StructureSummary: Generic Script Structure
set ns [new Simulator]set ns [new Simulator]
# [Turn on tracing]# [Turn on tracing]
# Create topology# Create topology
# Setup packet loss, link dynamics# Setup packet loss, link dynamics
# Create routing agents# Create routing agents
# Create: # Create:
# - multicast groups# - multicast groups
# - protocol agents# - protocol agents
# - application and/or setup traffic sources# - application and/or setup traffic sources
# Post-processing procs# Post-processing procs
# Start simulation# Start simulation