Classification of Communication Networks Wired Networks LAN MAN

  • Slides: 27
Download presentation

Classification of Communication Networks Wired Networks LAN, MAN, WAN, and Internet Wireless Networks Infrastructured

Classification of Communication Networks Wired Networks LAN, MAN, WAN, and Internet Wireless Networks Infrastructured networks (cellular networks) Infrastructureless networks (ad hoc wireless networks) 4

Infrastructure vs Ad-hoc Networks infrastructure network AP AP wired network AP: Access Point AP

Infrastructure vs Ad-hoc Networks infrastructure network AP AP wired network AP: Access Point AP ad-hoc network 5

Wired/Wireless Networks 6

Wired/Wireless Networks 6

Outline • NS 2 Overview • NS 2 Fundamentals

Outline • NS 2 Overview • NS 2 Fundamentals

What is NS 2 • • • Discrete event simulator Packet-level Link layer and

What is NS 2 • • • Discrete event simulator Packet-level Link layer and up Wired and wireless Platforms – Most UNIX and UNIX-like systems – Window 95/98/NT – (Emulation only for Free. BSD for now)

Resources • Tcl (Tool Command Language) – http: //dev. scriptics. com/scripting • OTcl (MIT

Resources • Tcl (Tool Command Language) – http: //dev. scriptics. com/scripting • OTcl (MIT Object Tcl) – gamma: ~otcl/doc/tutorial. html (in distribution) • ns manual – Included in distribution: gamma 2: ~ns/doc – http: //www. isi. edu/nsnam/ns/ns-documentation. html • ns tutorial – http: //perform. wpi. edu/NS/

Part I: Fundamentals

Part I: Fundamentals

ns Architecture • Object-oriented (C++, OTcl) • C++ for “data” – Per packet action

ns Architecture • Object-oriented (C++, OTcl) • C++ for “data” – Per packet action • OTcl for control – Periodic or triggered action

OTcl and C++: The Duality Pure OTcl objects Pure C++ objects C++/OTcl split objects

OTcl and C++: The Duality Pure OTcl objects Pure C++ objects C++/OTcl split objects C++ OTcl ns

Extending Tcl Interpreter – Link layer and up – Emulation support Network Components Tcl.

Extending Tcl Interpreter – Link layer and up – Emulation support Network Components Tcl. CL OTcl C/C++ ns-2 Event Scheduler • OTcl: object-oriented Tcl • Tcl. CL: C++ and OTcl linkage • Discrete event scheduler • Data network components

Hello World - Batch Mode simple. tcl set $ns $ns ns [new Simulator] at

Hello World - Batch Mode simple. tcl set $ns $ns ns [new Simulator] at 1 “puts “Hello World!”” at 1. 5 “exit” run swallow 74% ns simple. tcl Hello World! swallow 75%

Basic tcl # Command arg 1 arg 2 arg 3 … set a 43

Basic tcl # Command arg 1 arg 2 arg 3 … set a 43 set b 27 proc test { a b } { set c [expr $a + $b] set d [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 43 27

An Overview of Tcl and Tk

An Overview of Tcl and Tk

Scripting Language Philosophy ¥ Program size, complexity, reuse • Large, complex applications: – Performance

Scripting Language Philosophy ¥ Program size, complexity, reuse • Large, complex applications: – Performance important. – Need structure. – Goal: prevent bad things. One language can't meet all needs? 1 • Interactive commands, scripting: – Performance less important. – Minimum structure: less overhead, easy interchange. – Goal: enable good things.

Two-Language Approach ¥ Program size, complexity, reuse C Tcl • Use Tcl for scripting,

Two-Language Approach ¥ Program size, complexity, reuse C Tcl • Use Tcl for scripting, C or C++ for large things. • Goals for Tcl: – Minimal syntax: easy to learn and type. – Minimal structure: make things play together. – Simple interfaces to C: extensibility. 1

Language Overview • Two parts to learning Tcl: • 1. Syntax and substitution rules:

Language Overview • Two parts to learning Tcl: • 1. Syntax and substitution rules: – Substitutions simple, but may be confusing at first. • 2. Built-in commands: – Can learn individually as needed. – Control structures are commands, not language syntax.

Basics • Tcl script = – Sequence of commands. – Commands separated by newlines,

Basics • Tcl script = – Sequence of commands. – Commands separated by newlines, semi-colons. • Tcl command = – One or more words separated by white space. – First word is command name, others are arguments. – Returns string result. • Examples: – set a 22; set b 33 – set a 22 set b 33

Tcl: Tool Command Language • Simple syntax (similar to sh, C, Lisp): – set

Tcl: Tool Command Language • Simple syntax (similar to sh, C, Lisp): – set a 47 • Substitutions: – set b $a – set b [expr $a+10] • Quoting: – set b "a is $a" – set b {[expr $a+10]} • C: x = 4; y = x+10 y is 14 Tcl: set x 4; set y x+10 y is "x+10"

More On The Tcl Language Sample command Result set b 66 set a b

More On The Tcl Language Sample command Result set b 66 set a b b set a $b+$b+$b set a $b. 3 set a $b 4 66 66 66+66+66 66. 3 no such variable Sample command Result set b 8 8 set a [expr $b+2] set a "b-3 is [expr $b-3]" 10 b-3 is 5

More On The Tcl Language if "$x < 3" { puts "x below 3"

More On The Tcl Language if "$x < 3" { puts "x below 3" } --------------------------if {$turn == “ 0”} { computer_move } else { player_move }

More On The Tcl Language proc func x { if $x<=1 {return 1} expr

More On The Tcl Language proc func x { if $x<=1 {return 1} expr $x*[fac [expr $x-1]] } func 4 ---------------------------while {$i <= 10} { set I [expr $i+1] }

Elements of ns-2 • • Create the event scheduler [Turn on tracing] Create network

Elements 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

Creating Event Scheduler • Create event scheduler – set ns [new Simulator] • Schedule

Creating Event Scheduler • Create event scheduler – set ns [new Simulator] • Schedule events – $ns at <time> <event> – <event>: any legitimate ns/tcl commands – $ns at 1. 0 “$ftp start” • Start scheduler – $ns run

Tracing • Trace packets on all links • #Open the NAM trace file #Open

Tracing • Trace packets on all links • #Open the NAM trace file #Open the Trace file – set nf [open out. nam w] – $ns namtrace-all $nf set tf [open out. tr w] $ns trace-all $tf • Must appear immediately after creating scheduler • Turn on tracing on specific links – $ns trace-queue $n 0 $n 1 – $ns namtrace-queue $n 0 $n 1