The Internet ns-2 101 Got to make the Infocom submission deadline!! Web Web TCP Polly Huang TCP www.cs.columbia.edu Internet Network Network USC/ISI Link/Physical Link/Physical huang@isi.edu 1 2 ns-2 Outlines • Network Simulator Version 2 (ns-2) • Essentials • Help to debug problems in a controlled • Getting Started environment • Fundamental tcl, otcl and ns • Case Studies – Web, TCP, Routing, Queuing 3 4 1
Object-Oriented C++ and otcl Separation + Reusability • C++ for data + Maintainability – per packet action • otcl for control – Careful Planning Ahead – periodic or triggered action + Compromize between composibility and speed – Learning & debugging 5 6 otcl and C++: The Duality tcl Interpreter With Extents Event ns-2 C++ Scheduler tclcl Component Network otcl otcl tcl8.0 • otcl to call C ++ : command(), tcl.result() • otcl: Object-oriented support • tclcl: C++ and otcl linkage • C++ to call otcl: tcl.eval() • Discrete event scheduler • Data network (the Internet) components 7 8 2
Outlines Installation • Essentials • Getting the pieces • Getting Started – tcl/tk8.0, otcl, tclcl, ns-2, (and nam-1) • http://www-mash.cs.berkeley.edu/ns/ns- • Fundamental tcl, otcl and ns build.html • Case Studies • ns-users@mash.cs.berkeley.edu – Web, TCP, Routing, Queuing – majordomo@mash.cs.berkeley.edu – subscribe ns-users yourname@address 9 10 Hello World - Interactive Mode Hello World - Passive Mode simple.tcl swallow 71% ns % set ns [new Simulator] set ns [new Simulator] _o3 $ns at 1 “puts \“Hello World!\”” % $ns at 1 “puts \“Hello World!\”” $ns at 1.5 “exit” 1 $ns run % $ns at 1.5 “exit” swallow 74% ns simple.tcl 2 Hello World! % $ns run swallow 75% Hello World! swallow 72% 11 12 3
Outlines Fundamentals • Essentials • tcl • Getting Started • otcl – ftp://ftp.tns.lcs.mit.edu/pub/otcl • Fundamental tcl, otcl and ns • ns-2 • Case Studies – http://www-mash.cs.berkeley.edu/ns/ns-man.html – Web, TCP, Routing, Queuing, Wireless – http://www-mash.cs.berkeley.edu/ns/nsDoc.ps.gz 13 14 Basic tcl Basic otcl proc test {} { Class mom set a 43 set a [ new mom] mom instproc greet {} { set b 27 $a set age_ 45 $ self instvar age_ set c [ expr $a + $b] set b [ new kid] puts “$age_ years old mom: set d [ expr [ expr $a - $b] * $c] How are you doing?” $b set age_ 15 for { set k 0} {$k < 10} { incr k} { } if {$k < 5} { $a greet puts “k < 5, pow= [ expr pow($d, $k)]” Class kid - superclass mom $b greet } else { kid instproc greet {} { puts “k >= 5, mod= [ expr $d % $k]” $ self instvar age_ } puts “$age_ years old kid: } What’s up, dude?” } } test 15 16 4
Basic ns-2 Creating Network • Nodes • Creating network – set ns [new Simulator] • Computing routes – set n0 [$ns node] • Creating connection – set n1 [$ns node] • Creating traffic • Links & Queuing • Inserting errors – $ns duplex-link $n0 $n1 <bandwidth> <delay> <queue_type> • Monitoring – <queue_type>: DropTail, RED, CBQ, WFQ, SFQ, DRR 17 18 Computing routes Creating Connection • Unicast • UDP – $ns rtproto <type> – set src [new Agent/UDP] – <type>: Static, Session, DV, cost, multi-path – set rcv [new Agent/Null] • Multicast – $ns connect $src $rcv • TCP – Simulator set EnableMcast_ 1 – Simulator set NumberInterfaces_ 1 – set tcp [new Agent/TCP] – $ns mrtproto <type> – set tcpsink [new Agent/TCPSink] – <type>: CtrMcast, DM, dynamicDM, pimDM – $ns connect $tcp $tcpsink 19 20 5
Creating Traffic Inserting Errors • Creating Error Module • FTP – set loss_module [new ErrorModel] – set ftp [new Application/FTP] – $loss_module set rate_ 0.01 – $ftp attach-agent $tcp – $loss_module unit pkt • Telnet – $loss_module ranvar [new – set telnet [new Application/Telnet] RandomVariable/Uniform] • Web – $loss_module drop-target [new Agent/Null] – set session [new httpSession $ns <numPages> • Inserting Error Module <clientNode>] – $ns lossmodel $loss_module $n0 $n1 21 22 Tracing Outlines • Trace packets on all links • Essentials – $ns trace-all [open test.out w] • Getting Started • Fundamental tcl, otcl and ns-2 <event> <time> <from> <to> <pkt> <size>--<flowid> <src> <dst> <seqno> <aseqno> • Case Studies + 1 0 2 cbr 210 ------- 0 0.0 3.1 0 0 - 1 0 2 cbr 210 ------- 0 0.0 3.1 0 0 r 1.00234 0 2 cbr 210 ------- 0 0.0 3.1 0 0 • Trace packets on all links in nam-1 format – $ns namtrace-all [open test.nam w] 23 24 6
Case Studies Visualization Tools • Routing - Multicast • nam-1 (Network AniMator Version 1) • TCP • xgraph • Web • Queuing - RED 25 26 Other ns-2 Freatures ns-2 102 Preview • Mathematical Support • Flow of code • Multi-access Media (some link layer – Packet forwarding mechanism walk through support) – Routing walk through – TCP walk through • Network Dynamics – Web code walk through • Simulation Scale • Creating your own agent (adding & – 460 nodes, 100,000 TCP connections changing) • Emulation Interface 27 28 7
Online Resources Credits • UCB • http://netweb.usc.edu/vint – Elan Amir, Hari Balakrishnan, Tom Henderson, Steven McCanne, Giao Nguyen, Venkat Padmanabhan, Teck-Lee Tung • http://www-mash.cs.berkeley.edu/ns/ • USC/ISI • Mailing lists: – Lars Eggert, Deborah Estrin, Padma Haldar, Mark Handley, John – ns-users@mash.cs.berkeley.edu Heidemann, Ahmed Helmy, Polly Huang, Satish Kumar, Reza Rejaie, Puneet Sharma, Kannan Varadhan, Vikram Visweswariah, – ns-announce@mash.cs.berkeley.edu Ya Xu, Haobo Yu • To subscribe: • LBNL – majordomo@mash.cs.berkeley.edu – Kevin Fall, Sally Floyd • Xerox Parc 29 30 – Sandeep Bajaj, Lee Breslau, Scott Shenker 8
Recommend
More recommend