ns-2 101 Polly Huang USC/ISI huang@isi.edu 1 The Internet Got - - PowerPoint PPT Presentation

ns 2 101
SMART_READER_LITE
LIVE PREVIEW

ns-2 101 Polly Huang USC/ISI huang@isi.edu 1 The Internet Got - - PowerPoint PPT Presentation

ns-2 101 Polly Huang USC/ISI huang@isi.edu 1 The Internet Got to make the Infocom submission deadline!! Web Web TCP TCP www.cs.columbia.edu Internet Network Network Link/Physical Link/Physical 2 ns-2 Network Simulator Version


slide-1
SLIDE 1

1

ns-2 101

Polly Huang USC/ISI huang@isi.edu

slide-2
SLIDE 2

2

The Internet

Web TCP Network Link/Physical Internet Web TCP Network Link/Physical

www.cs.columbia.edu Got to make the Infocom submission deadline!!

slide-3
SLIDE 3

3

ns-2

  • Network Simulator Version 2 (ns-2)
  • Help to debug problems in a controlled

environment

slide-4
SLIDE 4

4

Outlines

  • Essentials
  • Getting Started
  • Fundamental tcl, otcl and ns
  • Case Studies

– Web, TCP, Routing, Queuing

slide-5
SLIDE 5

5

Object-Oriented

+ Reusability + Maintainability – Careful Planning Ahead

slide-6
SLIDE 6

6

C++ and otcl Separation

  • C++ for data

– per packet action

  • otcl for control

– periodic or triggered action

+ Compromize between composibility and speed – Learning & debugging

slide-7
SLIDE 7

7

  • tcl and C++: The Duality
  • otcl to call C ++ : command(), tcl.result()
  • C++ to call otcl: tcl.eval()

C++

  • tcl
slide-8
SLIDE 8

8

tcl Interpreter With Extents

  • otcl: Object-oriented support
  • tclcl: C++ and otcl linkage
  • Discrete event scheduler
  • Data network (the Internet) components

tcl8.0

  • tcl

tclcl ns-2 Event Scheduler Network Component

slide-9
SLIDE 9

9

Outlines

  • Essentials
  • Getting Started
  • Fundamental tcl, otcl and ns
  • Case Studies

– Web, TCP, Routing, Queuing

slide-10
SLIDE 10

10

Installation

  • Getting the pieces

– tcl/tk8.0, otcl, tclcl, ns-2, (and nam-1)

  • http://www-mash.cs.berkeley.edu/ns/ns-

build.html

  • ns-users@mash.cs.berkeley.edu

– majordomo@mash.cs.berkeley.edu – subscribe ns-users yourname@address

slide-11
SLIDE 11

11

Hello World - Interactive Mode

swallow 71% ns % set ns [new Simulator] _o3 % $ns at 1 “puts \“Hello World!\”” 1 % $ns at 1.5 “exit” 2 % $ns run Hello World! swallow 72%

slide-12
SLIDE 12

12

Hello World - Passive Mode

simple.tcl

set ns [new Simulator] $ns at 1 “puts \“Hello World!\”” $ns at 1.5 “exit” $ns run

swallow 74% ns simple.tcl Hello World! swallow 75%

slide-13
SLIDE 13

13

Outlines

  • Essentials
  • Getting Started
  • Fundamental tcl, otcl and ns
  • Case Studies

– Web, TCP, Routing, Queuing, Wireless

slide-14
SLIDE 14

14

Fundamentals

  • tcl
  • otcl

– ftp://ftp.tns.lcs.mit.edu/pub/otcl

  • ns-2

– http://www-mash.cs.berkeley.edu/ns/ns-man.html – http://www-mash.cs.berkeley.edu/ns/nsDoc.ps.gz

slide-15
SLIDE 15

15

Basic tcl

proc test {} { set a 43 set b 27 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]” } } } test

slide-16
SLIDE 16

16

Basic otcl

Class mom mom instproc greet {} { $self instvar age_ puts “$age_ years old mom: How are you doing?” } Class kid -superclass mom kid instproc greet {} { $self instvar age_ puts “$age_ years old kid: What’s up, dude?” } set a [new mom] $a set age_ 45 set b [new kid] $b set age_ 15 $a greet $b greet

slide-17
SLIDE 17

17

Basic ns-2

  • Creating network
  • Computing routes
  • Creating connection
  • Creating traffic
  • Inserting errors
  • Monitoring
slide-18
SLIDE 18

18

Creating Network

  • Nodes

– set ns [new Simulator] – set n0 [$ns node] – set n1 [$ns node]

  • Links & Queuing

– $ns duplex-link $n0 $n1 <bandwidth> <delay> <queue_type> – <queue_type>: DropTail, RED, CBQ, WFQ, SFQ, DRR

slide-19
SLIDE 19

19

Computing routes

  • Unicast

– $ns rtproto <type> – <type>: Static, Session, DV, cost, multi-path

  • Multicast

– Simulator set EnableMcast_ 1 – Simulator set NumberInterfaces_ 1 – $ns mrtproto <type> – <type>: CtrMcast, DM, dynamicDM, pimDM

slide-20
SLIDE 20

20

Creating Connection

  • UDP

– set src [new Agent/UDP] – set rcv [new Agent/Null] – $ns connect $src $rcv

  • TCP

– set tcp [new Agent/TCP] – set tcpsink [new Agent/TCPSink] – $ns connect $tcp $tcpsink

slide-21
SLIDE 21

21

Creating Traffic

  • FTP

– set ftp [new Application/FTP] – $ftp attach-agent $tcp

  • Telnet

– set telnet [new Application/Telnet]

  • Web

– set session [new httpSession $ns <numPages> <clientNode>]

slide-22
SLIDE 22

22

Inserting Errors

  • Creating Error Module

– set loss_module [new ErrorModel] – $loss_module set rate_ 0.01 – $loss_module unit pkt – $loss_module ranvar [new RandomVariable/Uniform] – $loss_module drop-target [new Agent/Null]

  • Inserting Error Module

– $ns lossmodel $loss_module $n0 $n1

slide-23
SLIDE 23

23

Tracing

  • Trace packets on all links

– $ns trace-all [open test.out w]

<event> <time> <from> <to> <pkt> <size>--<flowid> <src> <dst> <seqno> <aseqno> + 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]

slide-24
SLIDE 24

24

Outlines

  • Essentials
  • Getting Started
  • Fundamental tcl, otcl and ns-2
  • Case Studies
slide-25
SLIDE 25

25

Case Studies

  • Routing - Multicast
  • TCP
  • Web
  • Queuing - RED
slide-26
SLIDE 26

26

Visualization Tools

  • nam-1 (Network AniMator Version 1)
  • xgraph
slide-27
SLIDE 27

27

Other ns-2 Freatures

  • Mathematical Support
  • Multi-access Media (some link layer

support)

  • Network Dynamics
  • Simulation Scale

– 460 nodes, 100,000 TCP connections

  • Emulation Interface
slide-28
SLIDE 28

28

ns-2 102 Preview

  • Flow of code

– Packet forwarding mechanism walk through – Routing walk through – TCP walk through – Web code walk through

  • Creating your own agent (adding &

changing)

slide-29
SLIDE 29

29

Online Resources

  • http://netweb.usc.edu/vint
  • http://www-mash.cs.berkeley.edu/ns/
  • Mailing lists:

– ns-users@mash.cs.berkeley.edu – ns-announce@mash.cs.berkeley.edu

  • To subscribe:

– majordomo@mash.cs.berkeley.edu

slide-30
SLIDE 30

30

Credits

  • UCB

– Elan Amir, Hari Balakrishnan, Tom Henderson, Steven McCanne, Giao Nguyen, Venkat Padmanabhan, Teck-Lee Tung

  • USC/ISI

– Lars Eggert, Deborah Estrin, Padma Haldar, Mark Handley, John Heidemann, Ahmed Helmy, Polly Huang, Satish Kumar, Reza Rejaie, Puneet Sharma, Kannan Varadhan, Vikram Visweswariah, Ya Xu, Haobo Yu

  • LBNL

– Kevin Fall, Sally Floyd

  • Xerox Parc

– Sandeep Bajaj, Lee Breslau, Scott Shenker