The NS (v2) Sim ulator W orkshop br ought to you by Kevin F all La wrence Berk eley National Lab oratory kfal l@e e.lbl.gov http://www-nr g.e e.lbl.gov/kfal l AND Kannan V aradhan USC/ISI kannan@c atarina.usc.e du http://www.isi.e du/~kannan Septem b er 18, 1997
Audience and Outline � Audience net w ork researc hers { educators { dev elop ers { � T opics for to da y VINT pro ject goals and status (Sally) { { arc hitecture plus some history (Stev en) { o v erview of ma jor comp onen ts (Kevin) pro ject/co de status (Kevin) { details of ma jor comp onen ts (Kevin) { C++/OTcl link age and sim ulation debugging (Kannan) { top ology generation and session-lev el supp ort (Kannan) { m ulticast and reliable m ulticast (Kannan) { a complex link: CBQ (Kevin) { discussion and futures (Ev ery one) { NSv2 W orkshop kfal l@e e.lbl.gov Slide 2
NSv2 Arc hitecture � Ob ject-orien ted structure { ev olution from NSv1 (C++ with regular Tcl) { ob jects implemen ted in C++ and \OTcl" { OTcl: ob ject-orien ted extension to Tcl (from Da vid W etherall at MIT/LCS for V uSystem) � Con trol/\Data" separation con trol op erations in OTcl { data pass through C++ ob jects (for sp eed) { � Mo dular approac h �ne-grain ob ject decomp osition { { p ositives : comp osible, re-usable { negatives : m ust \plum b" in OTcl, dev elop er m ust b e comfortable with b oth en vironmen ts, to ols NSv2 W orkshop kfal l@e e.lbl.gov Slide 3
Dev elopmen t Status � sim ulator co de basis for VINT Pro ject � 5ish p eople activ ely con tributing to the co de base � other con tributions from Xero x P AR C, USC/ISI, UCB, LBNL � Some appro ximate n um b ers: 27K lines of C++ co de { 12K lines of OTcl supp ort co de { 18K lines of test suites, examples { 5K lines of do cumen tation! { � See main VINT and NS-2 w eb pages at: http://netweb.usc.edu/vint http://www-mash.cs.berkeley.edu/ns/ ns.htm l � Op en mailing lists: { ns-users@mash.cs.b erk eley .edu ns-announce@mash.cs.b erk eley .edu { � T o subscrib e: ma jordomo@mash.cs.b erk eley .edu { NSv2 W orkshop kfal l@e e.lbl.gov Slide 4
Directory Structure � directory shared b et w een MASH (UCB) and VINT pro jects common WORK vint common doc Tcl ns-2 nam www conf tcl bin ... lib test ex NSv2 W orkshop kfal l@e e.lbl.gov Slide 5
Class Hierarc h y � T op-lev el classes implemen t simple abstractions: Shared with MASH Project: TclObject NsObject Connector Classifier ... Queue McastClassifier Agent Trace AddrClassifier Delay Replicator Trace/Enq DropTail Trace/Deq Agent/TCP Agent/Message ... Trace/Hop RED Trace/Drop Reno Agent/Message/Prober NewReno NSv2 W orkshop kfal l@e e.lbl.gov Slide 6
Example: a no de � de : a collection of agents and classi�ers No � Agen ts: usually proto col endp oin ts and related ob jects � Classi�ers: pac k et dem ultiplexers Node Agent Port Classifier Agent Local Addr Node.entry Agent Addr Classifier Link Link � Note that the no de \routes" to itself or to do wnstream links NSv2 W orkshop kfal l@e e.lbl.gov Slide 7
Example: a link � k eeps trac k of \from" and \to" ob jects No de � generally encapsulates a queue, dela y and p ossibly ttl c hec k er Link (OTcl class) Queue Delay split classes � Man y more complex ob jects built from this base NSv2 W orkshop kfal l@e e.lbl.gov Slide 8
Example: routers � routers (unicast and m ulticast) b y \plum bing" Node Node Link Node.entry ... Link ... Link � m ulticast router adds additional classi�ers and replicators � Replicators: dem uxers with m ultiple fanout MulticastNode Addr Classifier Link unicast? Node.entry Link Replicator multicast? Addr Classifier (S1, G1) Replicator (S2, G2) Mcast Link Classifier (S3, G3) ... ... NSv2 W orkshop kfal l@e e.lbl.gov Slide 9
OTcl Basics � See the page at ftp://ftp.tns.lcs.mit.edu/pub/otcl/ � ob ject orien ted extension to tcl � classes are ob jects with supp ort for inheritance � Analogs to C++: C++ has single class decl ) { OTcl attac hes metho ds to ob ject or class { C++ constructor/destructor ) OTcl init/destro y metho ds this ) $ self { { OTcl metho ds alw a ys \virtual" C++ shado w ed metho ds called explicitly with scop e op erator { ) OTcl metho ds com bined implicitly with $ self next C++ static v ariables ) OTcl class v ariables { { (m ultiple inheritance is supp orted) NSv2 W orkshop kfal l@e e.lbl.gov Slide 10
OTcl Basics (con td) � use instvar and instpr o c to de�ne/access mem b er functions and v ariables � Example: Class Counter Counter instproc init fg f $self instvar cnt set cnt 0 g Counter instproc bump fg f $self instvar cnt incr cnt g fg f Counter instproc val $self instvar cnt return $cnt g Counter c ! c val 0 c bump ! c val 1 NSv2 W orkshop kfal l@e e.lbl.gov Slide 11
C++/OTcl Split Ob jects � Split ob jects: implemen t metho ds in either language � new and delete set c [new Counter] $c val -> 0 $c bump $c val -> 1 delete $c � De�ne instance v ariables in either C++ or OTcl: Counter::Counter() f bind("cnt ", &value ); vs. $self set cnt 10 value = 10; ... g bind() Tcl T r ac eV ar simply uses NSv2 W orkshop kfal l@e e.lbl.gov Slide 12
Example: a simple sim ulation � A small but complete sim ulation script: { set up 4-no de top ology and one bulk-data transfer TCP { arrange to trace the queue on the r1-k1 link { place trace output in the �le simp.out.tr � # Create a simple four node topology: # s1 # \ # 8Mb,5ms \ 0.8Mb,50ms # r1 --------- k1 # 8Mb,5ms / # / # s2 set stoptime 10.0 set ns [new Simulator] set node_(s1) [$ns node] set node_(s2) [$ns node] set node_(r1) [$ns node] set node_(k1) [$ns node] $ns duplex-link $node_(s1) $node_(r1) 8Mb 5ms DropTail $ns duplex-link $node_(s2) $node_(r1) 8Mb 5ms DropTail $ns duplex-link $node_(r1) $node_(k1) 800Kb 50ms DropTail $ns queue-limit $node_(r1) $node_(k1) 6 $ns queue-limit $node_(k1) $node_(r1) 6 set tcp1 [$ns create-connection TCP $node_(s1) TCPSink $node_(k1) 0] $tcp1 set window_ 50 $tcp1 set packetSize_ 1500 # Set up FTP source set ftp1 [$tcp1 attach-source FTP] set tf [open simp.out.tr w] $ns trace-queue $node_(r1) $node_(k1) $tf $ns at 0.0 "$ftp1 start" $ns at $stoptime "close $tf; puts \"simulation complete\"; $ns halt" $ns run NSv2 W orkshop kfal l@e e.lbl.gov Slide 13
Example: a simple sim ulation (con t) � The trace �le pro duced lo oks lik e this: + 0.0065 2 3 tcp 1500 ------ 0 0.0 3.0 0 0 - 0.0065 2 3 tcp 1500 ------ 0 0.0 3.0 0 0 + 0.23344 2 3 tcp 1500 ------ 0 0.0 3.0 1 2 - 0.23344 2 3 tcp 1500 ------ 0 0.0 3.0 1 2 + 0.23494 2 3 tcp 1500 ------ 0 0.0 3.0 2 3 - 0.24844 2 3 tcp 1500 ------ 0 0.0 3.0 2 3 + 0.46038 2 3 tcp 1500 ------ 0 0.0 3.0 3 6 - 0.46038 2 3 tcp 1500 ------ 0 0.0 3.0 3 6 + 0.46188 2 3 tcp 1500 ------ 0 0.0 3.0 4 7 + 0.47538 2 3 tcp 1500 ------ 0 0.0 3.0 5 8 ... + 0.98926 2 3 tcp 1500 ------ 0 0.0 3.0 25 40 + 0.99076 2 3 tcp 1500 ------ 0 0.0 3.0 26 41 d 0.99076 2 3 tcp 1500 ------ 0 0.0 3.0 26 41 - 1.00426 2 3 tcp 1500 ------ 0 0.0 3.0 21 36 + 1.00426 2 3 tcp 1500 ------ 0 0.0 3.0 27 42 + 1.00576 2 3 tcp 1500 ------ 0 0.0 3.0 28 43 d 1.00576 2 3 tcp 1500 ------ 0 0.0 3.0 28 43 - 1.01926 2 3 tcp 1500 ------ 0 0.0 3.0 22 37 + 1.01926 2 3 tcp 1500 ------ 0 0.0 3.0 29 44 + 1.02076 2 3 tcp 1500 ------ 0 0.0 3.0 30 45 d 1.02076 2 3 tcp 1500 ------ 0 0.0 3.0 30 45 - 1.03426 2 3 tcp 1500 ------ 0 0.0 3.0 23 38 - 1.04926 2 3 tcp 1500 ------ 0 0.0 3.0 24 39 - 1.06426 2 3 tcp 1500 ------ 0 0.0 3.0 25 40 ... NSv2 W orkshop kfal l@e e.lbl.gov Slide 14
The Sim ulator � Sim ulator API is a set of metho ds b elonging to a simulator ob ject: � Create a sim ulator with: set ns [new Simulator] � What this do es: initialize the pac k et format (calls packetformat ) { create { create a sc heduler (defaults to a simple link ed-list sc heduler) � Sc heduler: handles time, timers and ev en ts (pac k ets), { deferred executions (\A Ts") - link ed-list sc heduler { Scheduler/List - heap-based sc heduler { Scheduler/Heap - calendar-queue sc heduler { Scheduler/Calendar see Reev es, "Complexit y Analyses of Ev en t Set Algorithms", { The Computer Journal , 27(1), 1984 NSv2 W orkshop kfal l@e e.lbl.gov Slide 15
Recommend
More recommend