Introduction � 1989: REAL network simulator Ns Tutorial 2002 � 1995: DARPA VINT project at LBL, Xerox PARC, UCB, and USC/ISI � Present: DARPA SAMAN project and Padmaparna Haldar (haldar@isi.edu) NSF CONSER project Xuan Chen (xuanc@isi.edu) � Collaboration with other researchers Nov 21, 2002 including CIRI 1 2 Ns Goals SAMAN and CONSER Projects � Support networking research and education � SAMAN: build robust networks through understanding the detection and prediction of � Protocol design, traffic studies, etc failure conditions � Protocol comparison � ASIM, RAMP, and NEWS � Provide a collaborative environment � CONSER: extending ns and nam to support: � Freely distributed, open source � Share code, protocols, models, etc � Network research: � Allow easy comparison of similar protocols � New module integration: diffserv, direct diffusion � Existing module improvement, new trace, etc � Increase confidence in results � Network education: nam and nam editor, � More people look at models in more situations educational scripts repository, ns-edu mailing list, � Experts develop models ns tutorial, etc � Multiple levels of detail in one simulator 3 4 Ns Status Ns functionalities � Wired world � Periodical release (ns-2.1b9a, July 2002) � Routing DV, LS, PI M-SM � ~ 200K LOC in C+ + and Otcl, � Transportation: TCP and UDP � ~ 100 test suites and 100+ examples � Traffic sources:web, ftp, telnet, cbr, stochastic � 371 pages of ns manual � Queuing disciplines:drop-tail, RED, FQ, SFQ, DRR � Daily snapshot (with auto-validation) � QoS: IntServ and Diffserv � Stability validation � Emulation � http://www.isi.edu/nsnam/ns/ns-tests.html � Wireless � Platform support � Ad hoc routing and mobile IP � FreeBSD, Linux, Solaris, Windows and Mac � Directed diffusion, sensor-MAC � User base � Tracing, visualization, various utilities � > 1k institutes (50 countries), > 10k users 5 6 � About 300 posts to ns-users@isi.edu every month 1
“Ns” Components Ns Models � Traffic models and applications: � Ns, the simulator itself � Web, FTP, telnet, constant-bit rate, real audio � Nam, the network animator � Transport protocols: � Visualize ns (or other) output � unicast: TCP (Reno, Vegas, etc.), UDP � Nam editor: GUI interface to generate ns scripts � Multicast: SRM � Pre-processing: � Routing and queueing: � Wired routing, ad hoc rtg and directed diffusion � Traffic and topology generators � queueing protocols: RED, drop-tail, etc � Post-processing: � Physical media: � Simple trace analysis, often in Aw k, Perl, or Tcl � Wired (point -to-point, LANs), wireless (multiple propagation models), satellite 7 8 Installation Help and Resources � Getting the pieces � Ns and nam build questions � Tcl/TK 8.x (8.3.2 preferred): � http://www.isi.edu/nsnam/ns/ns-build.html http://resource.tcl.tk/resource/software/tcltk/ � Otcl and TclCL : � Ns mailing list: ns-users@isi.edu http://otcl-tclcl.sourceforge.net � Ns manual and tutorial (in distribution) ns-2 and nam-1: � http://www.isi.edu/nsnam/dist � TCL: http://dev.scriptics.com/scripting � Other utilities � Otcl tutorial (in distribution): � http:/ / www.isi.edu/nsnam/ns/ns-build.html ftp://ftp.tns.lcs.mit.edu/pub/otcl/doc/tutorial. � Tcl-debug, GT-I TM, xgraph, … html 9 10 Cautions Tutorial Schedule � First session (Nov 21, 2002) � We tried best to validate ns with regression tests � Introduction � Ns fundamentals � However: abstraction of the real world � Extending ns is necessary for a simulator � Lab � You must justify the usage of this � Second session (Nov 22, 2002) simulator based on your research goals � Diffserv model (including lab) � Wireless networks (including lab) 11 12 2
Ns-2, the Network Simulator � A discrete event simulator Part I: ns fundamentals � Simple model � Focused on modeling network protocols � Wired, wireless, satellite � TCP, UDP, multicast, unicast � Web, telnet, ftp � Ad hoc routing, sensor networks � Infrastructure: stats, tracing, error models, etc 13 14 Discrete Event Simulation Discrete Event Examples � Model world as events simple Consider two nodes t=1, A enqueues pkt on LAN queuing � Simulator has list of events on an Ethernet: t=1.01, LAN dequeues pkt model: � Process: take next one, run it, until done and triggers B � Each event happens in an instant of virtual (simulated) time , but takes an arbitrary amount of A B t=1.0: A sends pkt to NIC real time A’s NIC starts carrier sense detailed t=1.005: A’s NIC concludes cs, � Ns uses simple model: single thread of CSMA/CD starts tx control = > no locking or race conditions to model: t=1.006: B’s NIC begins reciving pkt worry about (very easy) t=1.01: B’s NIC concludes pkt B’s NIC passes pkt to app 15 16 Ns Architecture C+ + and OTcl Separation � “data” / control separation � Object-oriented (C+ + , OTcl) � C+ + for “data”: � Modular approach � per packet processing, core of ns � Fine-grained object composition � fast to run, detailed, complete control � OTcl for control: � Simulation scenario configurations + Reusability � Periodic or triggered action � Manipulating existing C+ + objects + Maintenance � fast to write and change – Performance (speed and memory) + running vs. writing speed – Careful planning of modularity – Learning and debugging (two languages) 17 18 3
Basic Tcl Otcl and C+ + : The Duality variables: procedures: C++ set x 10 proc pow {x n} { puts “x is $x” if {$n == 1} { return $x } set part [pow x [expr $n-1]] C+ + / OTcl functions and expressions: return [expr $x*$part] split objects set y [pow x 2] } set y [expr x*x] otcl control flow: Also lists, associative arrays, � OTcl (object variant of Tcl) and C+ + share etc. if {$x > 0} { return $x } else { class hierarchy return [expr -$x] } => can use a real programming language to while { $x > 0 } { � TclCL is glue library that makes it easy to build network topologies, puts $x share functions, variables, etc traffic models, etc. incr x –1 } 19 20 Basic otcl C+ + and OTcl Linkage Class Person # subclass: � Class Tcl: instance of OTcl interpreter # constructor: Class Kid - superclass Person Person instproc init {age} { Kid instproc greet {} { Tcl& tcl = Tcl::instance(); $ self instvar age_ $ self instvar age_ tcl.evalc(“puts stdout hello world”); set age_ $age puts “$age_ years old kid: tcl.result() and tcl.error What’s up, dude?” } # method: } � Class TclObject and TclClass Person instproc greet {} { � Variable bindings set a [ new Person 45] $ self instvar age_ set b [ new Kid 15] bind(“ rtt_”, &t_rtt_ ) puts “$age_ years old: How are you doing?” $a greet � Invoking command method in shadow class } $b greet $ tcp advanceby 10 => can easily make variations of existing things (TCP, TCP/Reno) 21 22 C+ + and Otcl linkage II Using ns � Some important objects: Problem � NsObject: has recv() method � Connector: has target() and drop() Result Simulation Modify � BiConnector: uptarget() & downtarget() analysis model ns Setup/run simulation with ns 23 24 4
Ns programming Creating Event Scheduler � Create event scheduler � Create the event scheduler � Turn on tracing set ns [new Simulator] � Schedule events � Create network $ns at < time> < event> � Setup routing � < event> : any legitimate ns/tcl commands � Insert errors $ns at 5.0 “finish” � Create transport connection � Start scheduler � Create traffic $ns run � Transmit application- level data 25 26 Discrete Event Scheduler Event Scheduler � Event: at-event and packet time_, uid_, next_, handler_ � List scheduler: default head_ -> � Heap and calendar queue scheduler head_ -> handler_ -> handle() � Real-time scheduler � Synchronize with real-time � Network emulation insert time_, uid_, next_, handler_ set ns_ [new Simulator] $ns_ use-scheduler Heap $ns_ at 300.5 “$self halt” 27 28 Hello World - Interactive Mode Tracing and Monitoring I � Packet tracing: Interactive mode: Batch mode: swallow 71% ns simple.tcl � On all links: $ns trace-all [open out.tr w ] % set ns [new Simulator] set ns [new Simulator] � On one specific link: $ns trace-queue $n0 $n1$ tr _o3 $ns at 1 “puts \“Hello % $ns at 1 “puts \“Hello <Event> <time> <from> <to> <pkt> <size> -- <fid> <src> < dst> <seq> < attr> World!\”” World!\”” + 1 0 2 cbr 210 ------- 0 0.0 3.1 0 0 $ns at 1.5 “exit” 1 - 1 0 2 cbr 210 ------- 0 0.0 3.1 0 0 $ns run % $ns at 1.5 “exit” r 1.00234 0 2 cbr 210 ------- 0 0.0 3.1 0 0 swallow 74% ns 2 � We have new trace format simple.tcl % $ns run Hello World! � Event tracing (support TCP right now) Hello World! swallow 75% swallow 72% � Record “event” in trace file: $ns eventtrace-all E 2.267203 0 4 TCP slow_start 0 210 1 29 30 5
Recommend
More recommend