Network Simulator ns2 ECE 6610 Wireless Networks Ramanuja
- Slides: 94
Network Simulator ns-2 ECE 6610: Wireless Networks Ramanuja Vedantham GNAN Research Group January 30, 2006
Agenda n n Introduction Interface n n n Simulator n n n Tcl and OTcl Tcl. CL Wired network Wireless network Program assignment 2
Introduction n NS-2: network simulator version 2 n n n Discrete event simulator Packet level simulation Features n n n Open source Scheduling, routing and congestion control Wired networks: P 2 P links, LAN Wireless networks: terrestrial (ad-hoc, cellular; GPRS, UMTS, WLAN, Bluetooth), satellite Emulation and trace 3
NS-2: Evolution n REAL network simulator (Cornell), 1989 n n NS (NS-1), 1995 n n Adopt the Tcl / C++ architecture NS-2, 1996 n n Study the dynamic behavior of flow and congestion control schemes in packet-switched data networks (written in C) Object-oriented Tcl (Otcl) Wireless extensions n n n UC Berkeley Daedalus project CMU Monarch project Sun Microsystems 4
NS-2: Paradigm n Object-oriented programming n Protocol layering n n Large scale simulation n n Modularity and extensibility Maintenance and reusability Split-language programming n n Scripting language (Tcl) System programming language (C) 5
NS-2: Split Languages n Tcl scripts (Tcl/OTcl) n n n C codes (C/C++) n n n Interpreted (interactive) Setup and configuration Compiled (efficient) Algorithms and protocols Tcl. CL (OTcl/C++) n n Link Tcl/OTcl scripts and C/C++ codes Provide a layer of C++ glue over OTcl 6
NS-2: Split Objects OTcl/C++ split objects Pure C++ objects Pure OTcl objects OTcl Tcl. CL linkage C++ NS-2 7
NS-2: A Tcl Script Example #!/home/hsieh/ns-allinone-2. 27/bin/ns set ns [new Simulator] set nf [open out. tr w]; $ns trace-all $nf for {set i 0} {$i<2} {incr i} { ; # create the nodes set n($i) [$ns node]} $ns duplex-link $n(0) $n(1) 1 Mb 10 ms Drop. Tail # Create a UDP agent set udp(src) [new Agent/UDP] $udp(src) set packet. Size_ 500 $ns attach-agent $n(0) $udp(src) proc finish {} { global ns nf $ns flush-trace; close $nf } /home>ns abc. tcl /home>abc. tcl $ns at 5. 0 "finish" $ns run 8
NS-2: A C++ Code Example static class Udp. Agent. Class : public Tcl. Class { public: Udp. Agent. Class() : Tcl. Class("Agent/UDP") {} Tcl. Object* create(int, const char*const*) { return (new Udp. Agent()); } } class_udp_agent; Udp. Agent: : Udp. Agent() : Agent(PT_UDP), seqno_(-1) { bind("packet. Size_", &size_); } void Udp. Agent: : sendmsg(int nbytes, App. Data* data, const char* flags) { Packet *p; p = allocpkt(); hdr_cmn: : access(p)->size() = size_; hdr_rtp: : access(p)->seqno() = ++seqno_; p->setdata(data); target_->recv(p); } 9
NS-2: Directory Structure (ftp: //ftp. isi. edu/nsnam/ns-allinone-2. 27. tar. gz) ns-allinone Tcl 8 TK 8 OTcl Tcl. CL. . . tcl ex examples test validation tests ns-2 lib nam-1 . . . C++ code mcast . . . OTcl code 10
NS 2 Installation Guidelines n Downloading n n n Installing NS 2 n n n NS 2 is available from http: //www. isi. edu/nsnam/ns/ns-build. html Download the ns-allinone package, ns-allinone-2. 28. tar. gz Go to directory of downloaded ns-allinone. tar. gz Unpack the file using: tar -xzvf ns-allinone-2. 28. tar. gz Go to the ns-allinone directory: cd ns-allinone-2. 28 Install it with the command . /install How to run ns 2 n Type . /ns [filename]. tcl 11
NS 2 Useful Links n Network Simulator NS-2 n n n NS-2 Homepage (http: //www. isi. edu/nsnam/ns/) NS-2 Manual (http: //www. isi. edu/nsnam/ns/nsdocumentation. html) Getting started with NS-2 n n Marc Greis's tutorial (http: //www. isi. edu/nsnam/ns/tutorial/index. html) NS by example (http: //nile. wpi. edu/NS/) NS 2 for beginners (http: //www-sop. inria. fr/maestro/personnel/Eitan. Altman/COURS-NS/n 3. pdf) OTcl (ftp: //ftp. tns. lcs. mit. edu/pub/otcl/doc/tutorial. html) 12
Network Simulator ns-2 Part I: Tcl, OTcl and Tcl. CL
NS-2: A Tcl Extension Network Components OTcl Event Scheduler Tcl. CL C/C++ ns-2 14
Tcl: Overview n n Tcl: Tool command language Tcl is extensible and embeddable n n Tcl is a scripting language n n n NS-2 is also a Tcl interpreter (tclsh or ns) Ideal for network configuration A Tcl script consists of commands To write Tcl scripts, you need to learn n n Tcl command Tcl syntax (how commands are parsed) 15
Tcl: Command n A command consists of words cmd. Name arg 1 arg 2 … n cmd. Name: core command or procedure n n n set, puts, expr, open, if, for, … All words are considered as strings White space (space/tab) separates arguments Newline or semicolon (; ) terminates a command Command evaluation: parsing and execution n n The interpreter does “substitution” and “grouping” (parsing) before running a command Every command returns a result string after execution 16
Tcl: Command command string Tcl Parser cmd name arg 1 arg 2 words Command Procedure result 17
Tcl: Command Example puts hello puts “hello” open test. tcl w set a 3 set b 4; set c 5 set a expr 1+2 expr 1 + 2 What is the use of the double quote? expr “ 1” “+2” 18
Tcl: Substitution n Variable substitution $ n n n Command substitution [] n n n [Tcl script] will be replaced by its result Nesting and multiple commands Backslash substitution n n n $var. Name will be replaced by its value Variables are created automatically when assigned to (no declaration is necessary) n, t, 67, x 67, … and $, [, \, ”, { newline, space A single pass of substitution 19
Tcl: Substitution Example set a 3 puts $a puts $z set b [expr 2+3] set c [puts hi] set e [set d [expr $b/2]] set f [expr 3][set e] set g [expr 3; set e] expr 31 + 3 expr 031 + 3 (octal) expr 0 x 31 + 3 (hex) expr x 31 + 3 (ascii) 20
Tcl: Grouping (Quoting) n Group words into a single word n n Grouping before substitution n Space, newline and semicolon are not interpreted (lose their functions when quoted) Allow substitution: double quotes “” Prevent substitution: braces {} Fine points n n Single quote ‘ Use of [][], {}{}, and “” “” 21
Tcl: Grouping Example set msg This Is A Wrong Example set msg This Is A Correct Example set msg “This Is A Correct Example” set msg {This Is A Correct Example} set msg ‘This Is A Wrong Example’ puts "hello; puts hi" puts "hello John" set a “hello”“there” if {$a==2}{puts “bingo”} set a 3 puts “$a+2 ist [expr $a+2]” puts {$a+2 ist [expr $a+2]} for {set i 0} {$i<5} {incr i} {puts $i} 22
Tcl: Variable name n n Simple variable n n var. Name can consist of any character By default Tcl assumes var. Name contains only letters, digits and the underscore Use of ${var. Name} for delimiting the name The variable is always stored as a string Associative array () n Variables with a string-valued index (mapping) n n n Array name and element name Multi-dimensional array command 23
Tcl: Variable Example (1) set c 122; set 122 c set d value; set e d set e set $e set [set e] set “link bandwidth" 3 expr ${link bandwidth} * 5 expr $”link bandwidth” * 5 set rate [expr 5*2] set bandwidth $rate. Mb set bandwidth ${rate}Mb set bandwidth $rate. 5 Mb 24
Tcl: Variable Example (2) set x 3 set "x" "3" expr $x * "10" set arr(0) 7 set arr(1) hello set arr(two) 3 set arr(the name) {the value} array names arr; array size arr set mat(1, 1) 10 set mat(1, 2) 5 set x 1; set y 2 puts $mat($x, $y) 25
Tcl: Procedure n Define a procedure proc prc. Name arg body n Procedure name and variable name are in different name spaces Procedure nesting Global scope for procedure name Default argument value (quoting with {}) Variable length argument list args n Return value of a procedure n n 26
Tcl: Procedure Example proc add {a b} {expr $a + $b} proc add "a b" "expr $a + $b" proc inc {var {dv 1}} { set a [expr $var+$dv] return $a } proc greet {} {puts “hello there”} proc add args { set s 0 foreach i $args {incr s $i} return $s } 27
Tcl: Scope n Local scope inside the procedure n n global var. Name 1 var. Name 2 … n n Use array for a collection of global variables upvar ? level? var. Name local. Name n n n Variables defined outside the procedure (global variable) are invisible to the procedure Level: 1 (relative level), #0 (absolute/global level) Call by reference Static variable n Use global variable 28
Tcl: Scope Example proc topology {link} { global node for {set i 0} {$i<$link} {incr i} { set node($i) [new Node] } } proc topology-2 {var link} { upvar $var nn for {set i 0} {$i<$link} {incr i} { set nn($i) [new Node] } } topology 3 topology-2 node 3 29
Tcl: Miscellaneous n Comment (#) n n n Expression (expr) n n expr a? b: c vs. expr {a? b: c} Non-numeric operands: strings for comparisons Evaluation (eval) Command line arguments n n Comment is also a command It is placed where a command is expected argc, argv 0 Script files n source 30
Tcl: Miscellaneous Examples set x 2 if {$x==2} { # not a comment ; # a comment puts "x is 2”} set bw [expr $x==1 ? 3 : 5] set bw [expr {[info exists z] ? $z : 0}] set bw [expr $x ? 3 Mb : 5 Mb] set x “puts hello” eval $x 31
Tcl: Core Commands n Control flow n n File access n n glob-style and regular expression List manipulation n open, close, flush, puts, gets String manipulation n n if, switch, while, foreach llength, lindex, linsert, lreplace lappend string and array commands 32
NS-2: A Tcl Script (Recap) #!/home/hsieh/ns-allinone-2. 27/bin/ns set ns [new Simulator] set nf [open out. tr w]; $ns trace-all $nf for {set i 0} {$i<2} {incr i} { ; # create the nodes set n($i) [$ns node]} $ns duplex-link $n(0) $n(1) 1 Mb 10 ms Drop. Tail # Create a UDP agent set udp(src) [new Agent/UDP] $udp(src) set packet. Size_ 500 $ns attach-agent $n(0) $udp(src) proc finish {} { global ns nf $ns flush-trace; close $nf } $ns at 5. 0 "finish" $ns run 33
OTcl: Overview n OTcl: Object Tcl n Object-oriented n n Dynamic n n Class can be defined incrementally Methods and classes can be modified at any time Instance can behave differently from the class itself Object command approach n n n Class and inheritance Each object is registered as a command to the parser Each subcommand is an “argument” to the object OTcl intepreter: otclsh or ns 34
OTcl: Class n Class command n n n Class variable n n Class cls. Name to create a class cls. Name instproc to define a class method cls. Name set var. Name var. Value cls. Name instvar to link to a class variable All instance variables and methods of the class are public Inheritance n cls. Name superclass to set parent class 35
OTcl: Class n Comparison with C++ n Class definition n n Constructor and destructor n next Method invocation n n init and destroy Method shadowing and combination n n instproc and instvar (set) self Static variable Instance lifecycle n new and delete 36
OTcl: An Example Class Safety instproc init {} { $self next $self set count 0 } Safety instproc put {thing} { $self instvar count incr count $self next $thing } Safety instproc get {} { $self instvar count if {$count==0} {return {empty!}} incr count -1 $self next } Class Stack instproc init {} { $self next $self set pile {} } Stack instproc put {thing} { $self instvar pile set pile [concat [list $thing] $pile] return $thing } Stack instproc get {} { $self instvar pile set top [lindex $pile 0] set pile [lrange $pile 1 end] return $top } Class Safe. Stack –superclass {Safety Stack} Safe. Stack s 37
OTcl: Inheritance Object next Safety next Stack superclass next Safe. Stack class s 38
Tcl. CL: Overview n n n Tcl. CL: Tcl with Classes NS-2 is written in C++ with OTcl interpreter as a front end Class hierarchy n n Compiled hierarchy and interpreted hierarchy One-to-one correspondence of objects from users’ perspective Simulator objects are implemented in the compiled hierarchy, but instantiated through the interpreter Tcl. Object is the root of the hierarchy 39
Tcl. CL: NS-2 Objects Tcl. CL linkage Pure C++ objects Pure OTcl objects OTcl/C++ split objects OTcl C++ NS-2 40
Tcl. CL: OTcl/C++ Linkage Root of NS-2 object hierarchy Tcl. Object bind(): link variable values between C++ and OTcl command(): link OTcl methods to C++ implementations Tcl. Class Tcl Create and initialize Tcl. Object’s C++ methods to access the OTcl interpreter Tcl. Command Standalone global commands Embedded. Tcl NS-2 script initialization 41
Tcl. CL: Class Tcl. Object n Base class in NS-2 for split objects n n Usage n n Mirrored in both C++ (Tcl. Object) and OTcl (Split. Object) Instantiation, bind and command Example set tcp [new Agent/TCP] $tcp set window_ 30 $tcp advanceby 5000 42
Class Tcl. Object: Hierarchy Split. Object OTcl class hierarchy C++ class hierarchy Tcl. Object Connector Agent/TCP Tcp. Agent _o 123 Agent/TCP OTcl object *tcp Agent/TCP C++ object 43
Tcl. CL: Class Tcl. Class C++ Tcl. Object Ns. Object Agent Tcp. Agent staticmirroring class Tcp. Class : OTcl public Tcl. Class { public: Split. Object Tcp. Class() : Tcl. Class(“Agent/TCP”) {} Tcl. Object* create(int, const char*const*) { return (new Tcp. Agent()); } } class_tcp; Agent create-shadow{} create_shadow() Tcp. Class: : create() Agent/TCP new Agent/TCP 44
Class Tcl. Object: Binding n Bi-directional variable bindings n n Link C++ member variables (compiled) to OTcl instance variables (interpreted) Initialization through the closest OTcl class variable Agent/TCP set window_ 50 n Do all initialization of bound variables in ~ns/tcl/lib/ns-default. tcl n Otherwise a warning will be issued when the shadow compiled object is created 45
Class Tcl. Object: Binding n C++ Tcp. Agent: : Tcp. Agent() { bind(“window_”, &wnd_); … … } n n bind(), bind_time(), bind_bool(), bind_bw() OTcl Agent/TCP set window_ 50 set tcp [new Agent/TCP] $tcp set window_ 100 46
Class Tcl. Object: Command n Invoke C++ compiled functions through OTcl interpreted methods n n Hook point n n n A way of implementing OTcl methods in C++ Tcl method unknown{} OTcl method cmd{} Send all arguments after cmd{} call to Tcl. Object: : command() n Use Tcl: : resultf() in C++ to pass back results 47
Class Tcl. Object: Command $tcp send no such Split. Object: : unknown{} procedure OTcl space $tcp cmd send C++ space Tcp. Agent: : command() Yes process and return match “send”? No Invoke parent: return Agent: : command() 48
Class Tcl. Object: Command n OTcl set tcp [new Agent/TCP] $tcp advance 100 n C++ int Tcp. Agent: : command(int argc, const char*const* argv) { if (argc == 3) { if (strcmp(argv[1], “advance”) == 0) { int newseq = atoi(argv[2]); …… return TCL_OK; } } return (Agent: : command(argc, argv); } 49
Tcl. CL: Class Tcl n Class Tcl encapsulates the instance of the OTcl interpreter n n It provides methods in C++ to access and communicate with the interpreter Usage n n Obtain a reference to the OTcl instance Invoke OTcl procedure Obtain or pass back OTcl evaluation results Return success/failure code to OTcl 50
Class Tcl: Example n C++ (app. cc) Tcl& tcl = Tcl: : instance(); if (argc == 2) { if (strcmp(argv[1], "agent") == 0) { tcl. resultf("%s", agent_->name()); return TCL_OK; } else if (strcmp(argv[1], “start”) == 0) { tcl. evalf("[%s info class] info instprocs", name_); sprintf(result, " %s ", tcl. result()); … } tcl. error(“unknown command”); } 51
Tcl. CL: Summary n Class Tcl. Object n n n Class Tcl. Class n n Unified interpreted (OTcl) and compiled (C++) class hierarchies Seamless access (procedure call and variable access) between OTcl and C++ Mechanism that makes Tcl. Object work Class Tcl n Primitives to access OTcl interpreter 52
Network Simulator ns-2 Part II: Wired Network
Class Hierarchy Tcl. Object recv() Scheduler Ns. Object Node Connector Queue target_ Classifier Delay Agent Trace Drop. Tail RED TCP Reno Enq Deq Drop SACK Vegas Process Application FTP Addr. Classifier Port. Classifier 54
Simulation Elements n n n n n Create the event scheduler (simulator) [Setup tracing] Create network topology [Setup routing] [Insert error modules/network dynamics] Create connection (transport) Create traffic (application) Start the scheduler Post-process data 55
Event Scheduler n Create event scheduler n n Schedule events (OTcl) n n n OTcl: $ns at <time> <TCL_command> C++: Scheduler: : schedule(h, e, delay) Obtain simulation time n n n set ns [new Simulator] OTcl: $ns now C++: Scheduler: : clock() Start scheduler n n $ns run The last line of your OTcl script 56
Trace n Trace packets on all links n $ns trace-all [open nstr. out w] <event> + r n n < pkt> > <seq > pkt> <size> -- <fid> < src> <dst> <seq> cbr 210 ------- 0 0. 0 3. 1 0 <uid > <uid> 0 0 0 $ns namtrace-all [open namtr. out w] Turn on tracing on specific links n n n <t> <from> <to> 1 0 2 1. 00234 0 2 $ns trace-queue $n 0 $n 1 $ns namtrace-queue $n 0 $n 1 Output trace to /dev/null if not desired 57
Network Topology n Nodes n n set n 0 [$ns node] set n 1 [$ns node] Links and queues $ns duplex-link $n 0 $n 1 <bandwidth> <delay> <queue> n bandwidth: bind_bw(), delay: bind_time() queue: Drop. Tail, RED, CBQ, FQ, … n Link delay = f (bandwidth, delay) n = packet transmission time + propagation delay 58
Network Topology: Node n 0 n 1 Port Classifier dmux_ Addr Classifier Node entry classifier_ dmux_ entry_ Node entry_ classifier_ Unicast Node multiclassifier_ Multicast Classifier Multicast Node 59
Network Topology: Link n 0 n 1 duplex link head_ enq. T_ tracing queue_ drophead_ deq. T_ drp. T_ link_ ttl_ n 1 entry_ simplex link 60
Routing n Unicast routing n n n Default static routing n n n $ns rtproto <type> <nodes> type: Static (default), Session, DV, LS, Manual nodes: default entire topology Dijkstra’s all-pairs shortest path first algorithm Route calculation is done before simulation starts Link cost n n $ns cost $n 0 $n 1 <cost> default link cost = 1 61
Routing n 0 n 1 Port Classifier Addr Classifier Node entry_ 0 1 dmux_ classifier_ head_ enq. T_ queue_ drophead_ deq. T_ link_ ttl_ n 1 entry_ drp. T_ 62
Routing n 0 n 1 Port Classifier Addr Classifier entry_ 0 1 dmux_ Link n 0 -n 1 classifier_ entry_ 1 0 dmux_ classifier_ Link n 1 -n 0 63
Transport: TCP n n n set $ns $ns Use tcp [new Agent/TCP] tcpsink [new Agent/TCPSink] attach-agent $n 0 $tcp attach-agent $n 1 $tcpsink connect $tcpsink create-connection{} Customization n n $agent set fid <fid> $agent set packet. Size_ <size> 64
Transport n 0 n 1 Port Classifier Addr Classifier entry_ 0 1 0 Port Classifier dst_= 1. 0 Agent/TCP agents_ dmux_ Link n 0 -n 1 classifier_ entry_ Addr Classifier 0 1 0 dmux_ dst_= 0. 0 Agent/TCPSink agents_ classifier_ Link n 1 -n 0 65
Application n FTP n n n CBR n n n set ftp [new Application/FTP] $ftp attach-agent $tcp attach-app FTP set cbr [new Application/Traffic/CBR] $cbr set packet. Size_ 1000 $cbr set rate_ 16000 Start traffic generation n $ns at <time> “$app start” 66
Application n 0 n 1 Application/FTP Port Classifier entry_ Addr Classifier 0 0 1 dmux_ Port Classifier dst_=1. 0 Agent/TCP agents_ Link n 0 -n 1 classifier_ entry_ Addr Classifier 0 1 0 dmux_ dst_=0. 0 Agent/TCPSink agents_ classifier_ Link n 1 -n 0 67
Packet n Packets are events n n Packets contain header section and data n n Header section is a cascade of all in-use headers Each packet contains a common header n n Can be scheduled to “arrive” packet size (used to compute transmission time) packet type timestamp, uid, … All in-use headers are included when simulation starts n Change packet size to reflect header cascading 68
Packet Header cmn header data ip header tcp header rtp header Example: Get the pointer to the common header: p->access(hdr_cmn: : offset_) trace header ts_ ptype_ uid_ size_ iface_ . . . or, HDR_CMN(p) 69
Packet Flow n 0 n 1 Port Classifier Addr Classifier entry_ 0 1 0 Application/FTP Port Classifier dst_=1. 0 Addr Classifier Agent/TCP Link n 0 -n 1 entry_ 0 dst_=0. 0 Agent/TCPSink 1 0 Link n 1 -n 0 70
Recap n n n n Ns. Object: generic receive method recv() for packet reception Connector: one neighbor target_ Node: collection of classifiers and agents Link: encapsulation of queue and delay Classifier: packet demultiplexer (routing) Agent: protocol endpoint or implementation of routing protocol Application: traffic generation 71
Network Simulator ns-2 Part III: Wireless Network
Wireless Network n Wireless network n n n Nodes can move No explicit “links” used to connect nodes Wireless network extension n n Mobile node Wireless channel and propagation model Packet headers Topology and movement Routing and forwarding 73
Class Hierarchy Tcl. Object Ns. Object Node Channel Propagation Connector Mobile. Node Wireless. Channel Two. Ray. Ground Bi. Connector uptarget_ downtarget_ Phy MAC Wireless. Phy 802. 11 Delay LL 74
Mobile Node: Portrait Node port classifier Classifier: Forwarding protocol agent Node Entry 255 addr classifier defaulttarget_ LL routing agent ARP IFQ MAC PHY Mobile. Node Propagation and antenna models Agent: Protocol entity LL LL: Link layer object IFQ: Interface queue MAC: MAC object PHY: Network interface CHANNEL 75
Mobile Node: Components n Link layer and ARP n n n Interface queue n n n Same as for LAN, but with a separate ARP module ARP holds only one packet to the same destination Use callback to allow MAC retransmission Use priority queue to give priority to routing protocol packets MAC layer n n n IEEE 802. 11 RTS/CTS/DATA/ACK for all unicast packets Physical and virtual carrier sense 76
Mobile Node: Components n Network interface (PHY) n n Radio propagation model n n n Parameters based on DSSS (Wave. LAN 914 MHz) Interface with antenna and propagation models for packet reception decision Update energy upon transmission and reception Friss-space attenuation (1/r 2) at near distance Two-ray ground reflection (1/r 4) at far distance Antenna n Omni-directional antenna with unity gain 77
Wireless Channel n Duplicate packets to all mobile nodes attached to the channel except the sender n n n Propagation delay is included Use of multiple channels is possible It is the receiver’s responsibility (PHY) to decide if it will accept the packet n Decision is based on received signal power n n n Each packet will have the transmission power stamped Currently interference from other transmissions is not included in reception decision Collision is handled at individual receiver 78
Wireless Packet Header cmn header data Example: Get the pointer to the MAC header: p->access(hdr_mac: : offset_); or, HDR_MAC(p) IP header. . . ts_ ptype_ uid_ ARP size_ LL iface_ MAC 802_11. . . wireless headers 79
Node Movement n Location n n Coordinates (x, y, z) Movement n n Waypoint movement model Random destination Random speed [0, max. Speed] Random pause time or random moving time 80
Network Topology 81
Example: Ad Hoc Network n Scenario n n n 3 mobile nodes Move within a 670 m*670 m flat topology DSR ad hoc routing protocol Random waypoint mobility model UDP and CBR traffic 82
An Example – Step 1 # Create simulator set ns [new Simulator] # Create a topology in a 670 m x 670 m area set topo [new Topography] $topo load_flatgrid 670 # ns trace and nam trace $ns trace-all [open ns. tr w] $ns namtrace-all-wireless [open ns. nam w] 670 83
An Example – Step 2 # Create God set god [create-god 3] n God: General Operations Director n n Keep the number of nodes in the network Called by 802. 11 MAC to keep a sequence number cache of all nodes Store an array of the smallest number of hops required to reach one node to another Used for setdest operation $ns at 100. 00 “$god set-dist 2 3 1” 84
An Example – Step 3 # Define how to create a mobile node $ns node-config -adhoc. Routing DSR -ll. Type LL -mac. Type Mac/802_11 -ifq. Len 50 -ifq. Type Queue/Drop. Tail/Pri. Queue -phy. Type Phy/Wireless. Phy -ant. Type Antenna/Omni. Antenna -prop. Type Propagation/Two. Ray. Ground -channel [new Channel/Wireless. Channel] -topo. Instance $topo -agent. Trace ON -router. Trace OFF -mac. Trace OFF -movement. Trace OFF 85
Energy Parameters $ns node-config –energy. Model -initial. Energy -tx. Power -rx. Power n Node is energy-aware n n Energy. Model 100. 0 0. 6 0. 2 Node status: on / off / sleep Pt_ and Pt_consume_ 86
An Example – Step 4 # Create mobile nodes for {set i 0} {$i<3} {incr i} { set node($i) [$ns node] # disable random motion for static network $node($i) random-motion 0 } # Define movement model (if applicable) source movement-scenario-files # Define traffic model (if applicable) source traffic-scenario-files 87
Scenario: Movement n Mobile movement generator ~ns/indep-utils/cmu-scen-gen/setdest -n <num. Nodes> -p <pause. Time> -s <max. Speed> -t <sim. Time> -x <max. X> -y <max. Y> n n Random movement $node random-motion 1 $node start n Change POSITION_UPDATE_INTERVAL and MAX_SPEED internally 88
A Movement File $node_(0) set X_ 83. 4 $node_(0) set Y_ 239. 4 $node_(0) set Z_ 0. 0 $node_(1) set X_ 257. 1 $node_(1) set Y_ 345. 4 $node_(1) set Z_ 0. 0 $node_(2) set X_ 591. 3 $node_(2) set Y_ 199. 4 $node_(2) set Z_ 0. 0 $ns_ at 33. 0 "$node_(0) setdest 89. 7 283. 5 19. 2“ $ns_ at 51. 0 "$node_(1) setdest 221. 8 80. 9 14. 9" $ns_ at 50. 0 "$node_(2) setdest 369. 5 170. 5 3. 4" 89
Scenario: Traffic n Traffic pattern generator CBR (UDP) or FTP (TCP) traffic n ~ns/indep-utils/cmu-scen-gen/cbrgen. tcl ns cbrgen. tcl [-type cbr|tcp] [-nn nodes] [-seed] [-mc connections] [-rate] n n Specify in the OTcl script n Same as the wired network scenario 90
A Traffic Scenario set udp_(0) [new $ns_ attach-agent set null_(0) [new $ns_ attach-agent Agent/UDP] $node_(0) $udp_(0) Agent/Null] $node_(2) $null_(0) set cbr_(0) [new Application/Traffic/CBR] $cbr_(0) set packet. Size_ 1000 $cbr_(0) set interval_ 4. 0 $cbr_(0) set random_ 1 $cbr_(0) set maxpkts_ 10000 $cbr_(0) attach-agent $udp_(0) $ns_ connect $udp_(0) $null_(0) $ns_ at 20. 0 "$cbr_(0) start" 91
An Example – Step 5 # Define node initial position in nam for {set i 0} {$i < 3} {incr i} { $ns initial_node_position $node($i) 20 } # Tell ns/nam the simulation stop time $ns at 100. 0 “$ns nam-end-wireless 100. 0” $ns at 100. 0 “$ns halt” # Start your simulation $ns run 92
Summary n n NS-2 is an open source, discrete event, and packet level network simulator NS-2 is written in C++ with OTcl interpreter as a front end Tcl. CL provides linkage for class hierarchy, object instantiation, variable binding and command dispatching NS-2 provides abundant implementations of protocols used in wired and wireless networks 93
References n n n The ns Manual, January 2002 IEC ns workshop slides, June 2000 First ns workshop slides, September 1997 Wetherall and Lindblad, “Extending Tcl for Dynamic Object-Oriented Programming, ” Proceedings of the Tcl/Tk Workshop, 1995 Welch, “Practical Programming in Tcl and Tk”, Prentice-Hall, 1995 Ousterhout, “Tcl and the Tk Toolkit, ” Addison. Wesley, 1994 94
- Ns2 simulator tutorial
- Ns2 simulator tutorial
- Ns2 simulator tutorial
- Ramanuja acharya body
- Ranga ramanuja
- Setdest in ns2
- Awkweb
- Awk ns2
- Ns2 tutorial
- What are wireless devices and the wireless revolution
- Wireless networking meaning
- Local wireless networks
- Game theory in wireless and communication networks
- Wireless wide area networks
- Single node architecture in wireless sensor networks
- Wireless sensor networks for habitat monitoring
- Wired and wireless media
- Wireless networks
- Understanding wired and wireless networks
- Habitat monitoring sensor
- Gast 802 11 wireless networks "torrent"
- Difference between virtual circuit and datagram network
- Basestore iptv
- Quantum network simulator
- Network simulator 2
- Network slicing onap
- Network slicing simulator
- Ns3 network simulator
- Online mikrotik simulator
- Network simulator 2 download
- Java network simulator
- Wlan network
- Soho network definition
- Wireless security in cryptography and network security
- Receiver sensitivity
- Wireless sensor network protocols
- Dilbert wireless network
- Planning a wireless network
- Arrow mesh wifi
- A type of wireless local area network technology
- Wireless sensor network ppt
- Wireless wide area network
- Skymanage
- Wireless network components
- What does a wireless lan (wlan) act as to a wired network?
- Border security using wins
- Wireless integrated network sensors
- Elements of a wireless network
- Palo alto networks certified network security engineer
- Principles of network applications in computer networks
- Network motifs: simple building blocks of complex networks
- The network layer is concerned with
- Internet structure network of networks
- Internet structure network of networks
- Network layer design issues
- Network performance measurement in computer networks
- Network performance measurement
- Router node
- Network topology in computer network
- Features of peer to peer network and client server network
- Network systems design using network processors
- Network centric computing
- Packet vs circuit switching
- Water bottle rocket simulator
- Virtual baseball simulator
- Ca2 ultralight
- Turing tumble simulator
- Turing test simulator
- Thermocouple simulator circuit
- Toy program example
- Teseq esd gun
- Synopsys verilog simulator
- Ddo simulator
- Mz___-945ps -site:youtube.com
- Projectile motion simulator
- Family simulator sex
- Lc3 multiply
- Mips pipeline simulator
- Interactive ultrasound simulator
- Ladder diagram simulator
- Quirk quantum simulator
- Na_admin
- C1341 prius
- Hardware simulator
- Dominion simulator
- Nc code simulation
- Checking account and debit card simulation answers
- Sampling distribution simulator
- Mips assembly simulator
- Code tornado simulator
- Arduino uno wikipedia
- Continental drift simulator
- Producer's risk
- Frc robot simulator
- C compiler