Download presentation
1
Introduction to Network Simulator NS-2 Part II
King Fahd University of Petroleum and Minerals Computer Engineering Department Introduction to Network Simulator NS-2 Part II Wireless Mobile Ad hoc Networks COE 549 Anas Alroubaiey
2
Outlines Wireless TCL script How to build wireless scenarios
Mobility and traffic (setdest & cbrgen.tcl) DSR trace file Using AWK for calculating Routing overhead PDR( Packet Delivery Ratio)
3
Wireless TCL Script (1/3)
Mobile node parameters Channel type (Channel/WirelessChannel) Propagation model (Propagation/TwoRayGround) Interface type (Phy/WirelessPhy) MAC layer protocol (Mac/802_11) Routing protocol (DSR) Interface Queue type (CMUPriQueue - for DSR) Interface Queue Length (50) Antenna type (Antenna/OmniAntenna) LL type (LL) Read chapter 16 in ns-documentation Use wireless.tcl example in tcl\ex folder
4
Wireless TCL Script (2/3)
# unity gain, omni-directional antennas # set up the antennas to be centered in the node and 1.5 meters above it Antenna/OmniAntenna set X_ 0 Antenna/OmniAntenna set Y_ 0 Antenna/OmniAntenna set Z_ 1.5 Antenna/OmniAntenna set Gt_ 1.0 Antenna/OmniAntenna set Gr_ 1.0
5
Wireless TCL Script(3/3)
How to reduce the trace output file size set AgentTrace ON set RouterTrace ON set MacTrace ON Generating data traffic and mobility scenarios set val(cp) "../mobility/scene/cbr-3-test" set val(sc) "../mobility/scene/scen-3-test"
6
Wireless Scenario (Mobility)
Provide initial (X,Y, for now Z=0) co-ordinates for mobile nodes $node_(0) set X_ 5.0 $node_(0) set Y_ 2.0 $node_(0) set Z_ 0.0 $node_(1) set X_ 390.0 $node_(1) set Y_ 385.0 $node_(1) set Z_ 0.0 Now produce some simple node movements # Node_(1) starts to move towards node_(0) $ns_ at 50.0 "$node_(1) setdest " $ns_ at 10.0 "$node_(0) setdest " # Node_(1) then starts to move away from node_(0) $ns_ at "$node_(1) setdest "
7
Wireless scenario ( Traffic)
# Setup traffic flow between nodes # TCP connections between node_(0) and node_(1) set tcp [new Agent/TCP] $tcp set class_ 2 set sink [new Agent/TCPSink] $ns_ attach-agent $node_(0) $tcp $ns_ attach-agent $node_(1) $sink $ns_ connect $tcp $sink set ftp [new Application/FTP] $ftp attach-agent $tcp $ns_ at 10.0 "$ftp start"
8
Setdet A script has been provided which generates these movements automatically in a separate file To generate this, use the setdest script present in ns/indep-utils/cmu-scen-gen/ directory. Examples: setdest -v 1 -n 20 -p 2.0 -M t 200 -x 500 -y 500 > scen-20_v1.tcl setdest -v 2 -n 20 -s 1 -m 1 -M t 200 -P 1 -p 2.0 -x 500 -y 500 > scen- 20_v2.tcl
9
Cbrgen.tcl Generates traffic automatically in a separate file
script present in ns/indep-utils/cmu-scen-gen/ directory ns cbrgen.tcl [-type cbr|tcp] [-nn nodes] [-seed seed] [-mc connections][-rate rate] >output.tcl Example: ns cbrgen.tcl –type cbr –nn 50 –seed 1 –mc 10 –rate 4 > cbr
10
A Typical DSR trace format (1/3)
s _39_ RTR DSR 44 [13a a ] [39:255 8: ] 2 [0 0] [ >0] [ >10] s: means send : time stamp _39_: node id RTR: means router message 1306: uid of this packet DSR: DSR agent 44: size in the common header hdr_cmn() [13a a ] MAC detail: 13a: means the expected transmission time ( note that packet size is large, 44 bytes, 314second?) a: means the receiving node: 10 27: means the sending node is 39 800: IP header: 0x0800, (ETHERTYPE_ARP is 0x0806)
11
DSR Trace Format (2/3) [39:255 8: ] IP detail: src address: IP 39 means port 255 dst address: IP 8 means port 255 TTL: 255 Next-hop: 8 TTL (time to live ) you can use it to know the number of hops
12
DSR Trace Format (3/3) 2 [0 0] [ >0] [ >10] DSR detail: 2: num_addrs() [0 0] route-request option, this is not a route request, the second 0 is labeled for sequence number [ >0] route-reply option: [ " route-reply?" "Rreq seqno" "reply length" "dst of src route", "src of the src route"] [ >10], 1: shows this is a route error 1: number of route errors 8: tp notify node 8. 39->10: link is broken
13
Calculating Routing Overhead & PDR
sum of routing packets / sum of data packets PDR = Packet Delivery Ratio PDR = sum of packets sent/ sum of successfully received packets How to extract the number of Routing packets $cat out.tr |grep "^s.*MAC.*DSR" | wc –l Data packets $cat out.tr |grep "^s.*MAC.*cbr" | wc –l
14
Routing Overhead (AWK code)
BEGIN {dsrpktno = 0; dsrbyte = 0; cbrpktno = 0; cbrbyte = 0; } { $1~/s/ && /DSR/ && /MAC/ { dsrpktno ++ ; dsrbyte+=$8 ;} $1~/s/ && /cbr/ && /MAC/ { cbrpktno ++ ; cbrbyte+=$8; } } END { print ( dsrpktno/cbrpktno, dsrbyte /cbrbyte) }
15
PDR (AWK code) BEGIN {Scbr=0; Rcbr=0; } {
$1~/s/ && /cbr/ && /AGT/ { Scbr ++ ;} $1~/r/ && /cbr/ && /AGT/ { Rcbr++ ;} } END { print ( “PDR=“,Scbr/Rcbr) }
16
References
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.