1 / 18

NS2 - Wireless Network

NS2 - Wireless Network. Ming-Feng Yang. Outline. Basic wireless model Extensions wireless model Example - Ad hoc network. Basic wireless model. Creating wireless topology set topo [new Topography] $topo load_flatgrid $opt(x) $opt(y)

riva
Télécharger la présentation

NS2 - Wireless Network

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. NS2 - Wireless Network Ming-Feng Yang

  2. Outline • Basic wireless model • Extensions wireless model • Example - Ad hoc network

  3. Basic wireless model • Creating wireless topology set topo [new Topography] $topo load_flatgrid $opt(x) $opt(y) # where opt(x) and opt(y) are the boundaries used in simulation

  4. Basic wireless model Wired-cum-wireless MobileIP • Configure the node $ns_ node-config -adhocRouting DSDV or DSR or TORA or AODV \ -topoInstance $topo \ -addressTypeflat or hierarchical or expanded\ -wiredRouting ON \ -mobileIP ON \ -llType LL \ -macType Mac/802_11 \ -antType Antenna/OmniAntenna \ -propType Propagation/TwoRayGround \ -phyType Phy/WirelessPhy \ -channelType Channel/WirelessChannel \ -ifqType Queue/DropTail/PriQueue \ -ifqLen <integer> \ -agentTrace ON or OFF \ -routerTrace ON or OFF \ -macTrace ON or OFF \ -movementTrace ON or OFF

  5. Basic wireless model • Node movement $node set X_ <x1> $node set Y_ <y1> $node set Z_ <z1> # Start-position $ns at $time $node setdest <x2> <y2> <speed> # Future destinations

  6. Basic wireless model event s,r,d,f id for next hop node id node’s y-coordinate time next hop destination node’s x-coordinate node’s z-coordinate trace level source’s ethernet addr source’s addr.port duration node energy level reason for this event dest’s ethernet addr ethernet type packet type flow id ttl value dest’s addr.port packet size unique id • New traces format $ns use-newtrace s-t 0.029290548-Hs 1-Hd -1-Ni 1-Nx 390.00-Ny 385.00-Nz 0.00 -Ne -1.000000-Nl RTR-Nw ----Ma 0-Md 0-Ms 0-Mt 0-Is 1.255 -Id -1.255-It message-Il 32-If 0-Ii 0-Iv 32 -H: next hop info -N: node info -M: MAC level info -I: IP level info

  7. Basic wireless model Num-of-nodes Pause-time Max-speed Sim-time Topo-boundary source pattern-file set god_ [God instance] $ns_ at 50.000000000000 "$node_(2) setdest 369.463244915743170.5192031111523.371785899154” $ns_ at 51.000000000000 "$node_(1) setdest 221.82658549709380.85549500383914.909259208114” $ns_ at 33.000000000000 "$node_(0) setdest 89.663708107313283.49464442644219.153832288917” $god_ set-dist 1 2 2 $god_ set-dist 0 2 3 $god_ set-dist 0 1 1 $node_(2) set Z_ 0.000000000000 $node_(2) set Y_ 199.373306816804 $node_(2) set X_ 591.256560093833 $node_(1) set Z_ 0.000000000000 $node_(1) set Y_ 345.357731779204 $node_(1) set X_ 257.046298323157 $node_(0) set Z_ 0.000000000000 $node_(0) set Y_ 239.438009831261 $node_(0) set X_ 83.364418416244 : • Movement scenario generator cd ns-allinone-2.27/ns-2.27/indep-utils/cmu-scen-gen/setdest ./setdest -n 3 -p 2.0 -s 20.0 -t 300 -x 600 -y 600 > pattern-file

  8. Basic wireless model CBR-or-TCP Num-of-nodes Random-seed Max-connection CBR-rate source pattern-file # nodes: 10, max conn: 8, send rate: 0.25, seed: 1.0 # 1 connecting to 2 at time 2.5568388786897245 set udp_(0) [new Agent/UDP] $ns_ attach-agent $node_(1) $udp_(0) set null_(0) [new Agent/Null] $ns_ attach-agent $node_(2) $null_(0) set cbr_(0) [new Application/Traffic/CBR] $cbr_(0) set packetSize_ 512 $cbr_(0) set interval_ 0.25 $cbr_(0) set random_ 1 $cbr_(0) set maxpkts_ 10000 $cbr_(0) attach-agent $udp_(0) $ns_ connect $udp_(0) $null_(0) $ns_ at 2.5568388786897245 "$cbr_(0) start“ : • Traffic scenario generator ns cbrgen.tcl -type tcp -nn 25 -seed 0.0 -mc 8 > pattern-file ns cbrgen.tcl -type cbr -nn 10 -seed 1.0 -mc 8 -rate 4.0 > pattern-file

  9. Extensions wireless model cluster 0 domain 0 0,0,0 cluster 1 0,1,0 domain 1 cluster 0 1,0,0 1,0,2 1,0,1 1,0,3 • wired-cum-wireless W(0) $ns_ node-config -addressTypehierarchical AddrParams set domain_num_ 2 lappend cluster_num 21 AddrParams set cluster_num_ $cluster_num lappend eilastlevel 114 AddrParams set nodes_num_ $eilastlevel W(1) set temp {0.0.00.1.0} for {set i 0} {$i < $num_wired_nodes} {incr i} { set W($i) [$ns_ node [lindex $temp $i]] } BS(0) node_(1) node_(0) $ns_ node-config -wiredRouting ON set temp {1.0.01.0.11.0.21.0.3} set BS(0) [$ns_ node [lindex $temp 0]] $BS(0) random-motion 0 node_(2) $ns_ node-config -wiredRouting OFF for {set j 0} {$j < $opt(nn)} {incr j} { set node_($j) [ $ns_ node [lindex $temp [expr $j+1]] ] $node_($j) base-station [AddrParams addr2id [$BS(0) node-addr]] }

  10. Extensions wireless model • Mobile IP W(0) $ns_ node-config -mobileIP ON set HA [$ns_ node 1.0.0] set FA [$ns_ node 2.0.0] $HA random-motion 0 $FA random-motion 0 W(1) set MH [$ns_ node 1.0.1] set node_(0) $MH set HAaddress [AddrParams addr2id [$HA node-addr]] [$MH set regagent_] set home_agent_ $HAaddress HA FA MH

  11. Example - Ad hoc network Traffic: node(0) to node(1)

  12. Example - Ad hoc network Traffic: node(0) to node(1)

  13. Example - Ad hoc network Traffic: node(0) to node(1)

  14. Example - Ad hoc network set val(chan) Channel/WirelessChannel ;# channel type set val(prop) Propagation/TwoRayGround ;# radio-propagation model set val(netif) Phy/WirelessPhy ;# network interface type set val(mac) Mac/802_11 ;# MAC type set val(ifq) Queue/DropTail/PriQueue ;# interface queue type set val(ll) LL ;# link layer type set val(ant) Antenna/OmniAntenna ;# antenna model set val(ifqlen) 50 ;# max packet in ifq set val(nn) 3 ;# number of nodes set val(rp) DSDV ;# routing protocol set val(x) 500 ;# X dimension of topography set val(y) 400 ;# Y dimension of topography set val(stop) 150 ;# time of simulation end # Define options set ns [new Simulator] set tracefd [open out.tr w] set namtrace [open out.nam w] $ns trace-all $tracefd $ns namtrace-all-wireless $namtrace $val(x) $val(y)

  15. Example - Ad hoc network set topo [new Topography] $topo load_flatgrid $val(x) $val(y) # Create a topology object that keeps track of movements of nodes within the topological boundary create-god $val(nn) # God object is used to store global information about the state of the environment, network or nodes $ns node-config -adhocRouting $val(rp) \ -llType $val(ll) \ -macType $val(mac) \ -ifqType $val(ifq) \ -ifqLen $val(ifqlen) \ -antType $val(ant) \ -propType $val(prop) \ -phyType $val(netif) \ -channelType $val(chan) \ -topoInstance $topo \ -agentTrace ON \ -routerTrace ON \ -macTrace OFF \ -movementTrace ON # Configure the nodes

  16. Example - Ad hoc network for {set i 0} {$i < $val(nn) } { incr i } { set node_($i) [$ns node] $node_($i) random-motion 0 ;# disable random motion } # Create the specified number of nodes [$val(nn)] and "attach" them to the channel $node_(0) set X_ 5.0 $node_(0) set Y_ 5.0 $node_(0) set Z_ 0.0 $node_(1) set X_ 490.0 $node_(1) set Y_ 285.0 $node_(1) set Z_ 0.0 $node_(2) set X_ 150.0 $node_(2) set Y_ 240.0 $node_(2) set Z_ 0.0 # Provide initial location of nodes $ns at 10.0 "$node_(0) setdest 250.0 250.0 3.0" $ns at 30.0 "$node_(1) setdest 45.0 285.0 5.0" $ns at 100.0 "$node_(0) setdest 480.0 300.0 5.0" # Generation of movements

  17. Example - Ad hoc network set tcp [new Agent/TCP] 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" # Set up a TCP connection between node_(0) and node_(1) for {set i 0} {$i < $val(nn)} { incr i } { $ns initial_node_pos $node_($i) 40 } # Define node initial position in NAM, 40 defines the node size for NAM for {set i 0} {$i < $val(nn) } { incr i } { $ns at $val(stop) "$node_($i) reset"; } # Telling nodes when the simulation ends

  18. Example - Ad hoc network $ns at $val(stop) "$ns nam-end-wireless $val(stop)" $ns at $val(stop) "stop" proc stop {} { global ns tracefd namtrace $ns flush-trace close $tracefd close $namtrace exec nam out.nam & exit 0 } # ending nam and the simulation $ns run

More Related