📄 1_bts+2mn_avec_pareto+cbr_validee.tcl
字号:
# Test for 802.11 nodes.# @author rouil# @date 10/25/2005# Test file for wimax# Scenario: Communication between MN and Sink Node with MN attached to BS.# - Using grep ^r out.res | grep MAC | grep -c cbr you can see the number of# mac packets received at the destination (100 packets). # - Using grep ^s out.res | grep MAC | grep -c cbr you can see the number of # mac packets sent. By default the scheduler uses 64QAM_3_4 for # modulation. Using lower modulation can result in packet fragmentation # so the number of packets sent can increase (ex. 402 using QPSK_1_2)# - Using grep "1 0 cbr" out.res | grep -c ^r shows the number of packets # received at the destination.# pour notre cas on remplace out.res par output_dir.tr# Topology scenario:### |-----| # | MN0 | ; 1.0.1 # |-----| ### (^)# |# |--------------|# | Base Station | ; 1.0.0# |--------------|# |# |# |-----------|# | Sink node | ; 0.0.0# |-----------|##check input parametersif {$argc != 0} { puts "" puts "Wrong Number of Arguments! No arguments in this topology" puts "" exit (1)}# set global variablesset nb_mn 2 ;# max number of mobile nodeset packet_size 1500 ;# packet size in bytes at CBR applications #set output_dir set gap_size 1 ;#compute gap size between packetsputs "gap size=$gap_size"set traffic_start 20set traffic_stop 40set simulation_stop 50#define debug valuesMac/802_16 set debug_ 1Mac/802_16 set rtg_ 20Mac/802_16 set ttg_ 20Mac/802_16 set frame_duration_ 0.004Mac/802_16 set client_timeout_ 110 ;#to avoid BS disconnecting the SS since the traffic starts a 100sPhy/WirelessPhy/OFDM set g_ 0.25#define coverage area for base station: 20m coverage Phy/WirelessPhy set Pt_ 0.025#Phy/WirelessPhy set freq_ 2412e+6#Phy/WirelessPhy set RXThresh_ 2.90781e-09Phy/WirelessPhy set RXThresh_ 2.025e-12 ;#500m radiusPhy/WirelessPhy set CSThresh_ [expr 0.9*[Phy/WirelessPhy set RXThresh_]]# Parameter for wireless nodesset opt(chan) Channel/WirelessChannel ;# channel typeset opt(prop) Propagation/TwoRayGround ;# radio-propagation modelset opt(netif) Phy/WirelessPhy/OFDM ;# network interface typeset opt(mac) Mac/802_16/BS ;# MAC typeset opt(ifq) Queue/DropTail/PriQueue ;# interface queue typeset opt(ll) LL ;# link layer typeset opt(ant) Antenna/OmniAntenna ;# antenna modelset opt(ifqlen) 50 ;# max packet in ifqset opt(adhocRouting) DSDV ;# routing protocol#DSDVset opt(x) 1100 ;# X dimension of the topographyset opt(y) 1100 ;# Y dimension of the topographyMac/802_11 set basicRate_ 11MbMac/802_11 set dataRate_ 11MbMac/802_11 set bandwidth_ 11Mb#create the simulatorset ns [new Simulator]$ns use-newtrace#open file for traceset nf [open output_dir.tr w]$ns trace-all $nfset namtrace [open output_dir.nam w]$ns namtrace-all-wireless $namtrace $opt(x) $opt(y)#$ns namtrace-all $nf#defines function for flushing and closing filesproc finish {} { global ns nf $ns flush-trace close $nf #close $output_dir #close $nb_mn exec nam output_dir.nam & exit 0}#create the topographyset topo [new Topography]$topo load_flatgrid $opt(x) $opt(y)#puts "Topology created" #puts "Output file configured"# set up for hierarchical routing (needed for routing over a basestation)#puts "start hierarchical addressing"$ns node-config -addressType hierarchicalAddrParams set domain_num_ 2 ;# domain numberlappend cluster_num 1 1 ;# cluster number for each domain AddrParams set cluster_num_ $cluster_numlappend eilastlevel 1 [expr ($nb_mn+1)] ;# number of nodes for each cluster (1 for sink and one for mobile nodes + base stationAddrParams set nodes_num_ $eilastlevelputs "Configuration of hierarchical addressing done"# Create Godcreate-god [expr ($nb_mn + 2)] ;# nb_mn + 2 (base station and sink node)#puts "God node created"#creates the sink node in first addressing space.set sinkNode [$ns node 0.0.0]#set sinkNode1 [$ns node 0.0.0]#provide some co-ord (fixed) to base station node$sinkNode set X_ 100.0$sinkNode set Y_ 50.0$sinkNode set Z_ 0.0#$sinkNode1 set X_ 90.0#$sinkNode1 set Y_ 50.0#$sinkNode1 set Z_ 0.0#puts "sink node created"#creates the Access Point (Base station)$ns node-config -adhocRouting $opt(adhocRouting) \ -llType $opt(ll) \ -macType Mac/802_16/BS \ -ifqType $opt(ifq) \ -ifqLen $opt(ifqlen) \ -antType $opt(ant) \ -propType $opt(prop) \ -phyType $opt(netif) \ -channel [new $opt(chan)] \ -topoInstance $topo \ -wiredRouting ON \ -agentTrace ON \ -routerTrace ON \ -macTrace ON \ -movementTrace OFF#puts "Configuration of base station"set bstation [$ns node 1.0.0] $bstation random-motion 0#puts "Base-Station node created"#provide some co-ord (fixed) to base station node$bstation set X_ 550.0$bstation set Y_ 550.0$bstation set Z_ 0.0[$bstation set mac_(0)] set-channel 0# creation of the mobile nodes$ns node-config -macType Mac/802_16/SS \ -wiredRouting OFF \ -macTrace ON ;# Mobile nodes cannot do routing.#$ns at 30.0 "set $nb_mn 2" #for {set i 0} {$i < $nb_mn} {incr i} { # $ns at 7.0 "set nb_mn 2" #$ns at 7.0 " $wl_node_(1) start" set wl_node_(1) [$ns node 1.0.3] ;# create the node with given @. $wl_node_(1) random-motion 0 ;# disable random motion $wl_node_(1) base-station [AddrParams addr2id [$bstation node-addr]] ;#attach mn to basestation #compute position of the node $wl_node_(1) set X_ [expr 500.0 ] $wl_node_(1) set Y_ [expr 700.0 ] $wl_node_(1) set Z_ 0.0 #$ns at 7.0 "$wl_node_(1) setdest 1060.0 550.0 1. $ns at 0 "$wl_node_(1) setdest 1060.0 550.0 1.0" puts "wireless node 1 created ..." ;# debug info [$wl_node_(1) set mac_(0)] set-channel 0 [$wl_node_(1) set mac_(0)] set-diuc 7 ;# Change the node profile here (7=64QAM_3_4) #create source traffic #Create a UDP agent and attach it to node n0 set udp_(1) [new Agent/UDP] $udp_(1) set packetSize_ 1500 $ns attach-agent $wl_node_(1) $udp_(1) # Create a CBR traffic source and attach it to udp0 set cbr_(1) [new Application/Traffic/CBR] $cbr_(1) set packetSize_ $packet_size $cbr_(1) set interval_ $gap_size $cbr_(1) attach-agent $udp_(1) #create an sink into the sink nodset sink1 [new Agent/LossMonitor]$ns attach-agent $wl_node_(1) $sink1 # Create the Null agent to sink traffic set null_(0) [new Agent/Null] $ns attach-agent $sinkNode $null_(0) # Attach the 2 agents $ns connect $udp_(1) $null_(0)#nouveau set wl_node_(0) [$ns node 1.0.2] ;# create the node with given @. $wl_node_(0) random-motion 1 ;# disable random motion $wl_node_(0) base-station [AddrParams addr2id [$bstation node-addr]] ;#attach mn to basestation #compute position of the node $wl_node_(0) set X_ [expr 340.0 ] $wl_node_(0) set Y_ [expr 550.0 ] $wl_node_(0) set Z_ 0.0 # $ns at 25.0 "$wl_node_(0) "start" $ns at 25.0 "$wl_node_(0) setdest 1060.0 550.0 1.0" puts "wireless node 0 created ..." ;# debug info [$wl_node_(0) set mac_(0)] set-channel 0 [$wl_node_(0) set mac_(0)] set-diuc 7 ;# Change the node profile here (7=64QAM_3_4) #create source traffic #Create a UDP agent and attach it to node n0 set udp_(0) [new Agent/UDP] $udp_(0) set packetSize_ 1500 $ns attach-agent $wl_node_(0) $udp_(0) # Create a CBR traffic source and attach it to udp0 set cbr_(0) [new Application/Traffic/Pareto] $cbr_(0) set packetSize_ $packet_size $cbr_(0) set interval_ $gap_size $cbr_(0) attach-agent $udp_(0) #create an sink into the sink node
set sink0 [new Agent/LossMonitor]$ns attach-agent $wl_node_(0) $sink0 # Create the Null agent to sink traffic set null_(0) [new Agent/Null] $ns attach-agent $sinkNode $null_(0) # Attach the 2 agents $ns connect $udp_(0) $null_(0) #}# create the link between sink node and base station$ns duplex-link $sinkNode $bstation 100Mb 1ms DropTail#$ns duplex-link $wl_node_(1) $bstation 100Mb 1ms DropTail#$ns duplex-link $sinkNode1 $bstation 100Mb 1ms DropTail# Traffic scenario: if all the nodes start talking at the same# time, we may see packet loss due to bandwidth request collisionset diff 0.0for {set i 0} {$i < $nb_mn} {incr i} { $ns at [expr $traffic_start+$i*$diff] "$cbr_($i) start" $ns at [expr $traffic_stop+$i*$diff] "$cbr_($i) stop"}#$ns at 4 "$nd_(1) dump-table"#$ns at 5 "$nd_(1) send-rs"#$ns at 6 "$nd_(1) dump-table"#$ns at 8 "$nd_(1) dump-table"$ns at $simulation_stop "finish"#$ns at 5.0 "finish"#$ns at $simulation_stop "$ns halt"# Run the simulationputs "Running simulation for $nb_mn mobile nodes..."$ns runputs "Simulation done."
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -