Appendix I
The input script for ns-2 used in VOIP traffic analysis.
##############################################################
#Test_VOIP.tcl
#
#This script will take the number of nodes with VOIP traffic
# and the codec to be used as parameters.
#
#
###############################################################
#check input parameters
if {$argc != 2} {
puts
""
puts "Syntax: ns test-be.tcl nbMNs codec"
puts "G.711 64kbps: 80 bytes frame, 160 bytes payload, 50
pkts per sec. "
puts "G.729 8 kbps: 10 bytes frame, 20 bytes payload, 50
pkts per sec. "
puts "G.729.2 8 kbps: 10 bytes frame, 30 bytes payload, 33
pkts per sec. "
puts "G.723 6.3 kbps: 30 bytes frame, 30 bytes payload, 26
pkts per sec. "
puts "G.723.2 5.3 kbps: 30 bytes frame, 30 bytes payload, 22
pkts per sec. "
puts
""
exit
1
}
set nb_ss [lindex $argv 0]
set codec [lindex $argv 1]
# set global variables
set output_dir .
set traffic_start 15
set traffic_stop 165
set simulation_stop 200
set output_file voip_$nb_ss.$codec.tr
puts $output_file
#Set VoIP settings
Application/Traffic/VoIP set HeaderCompression_ 0;
76
Application/Traffic/VoIP set VAD_ 0;
#Application/Traffic/VoIP set CNG_ 1;
Mac/802_16 set fbandwidth_ 20e+6 ;# frequency bandwidth
(MHz)
set diuc 7 ;#modulation for MNs
#define debug values
Mac/802_16 set rtg_ 20
Mac/802_16 set ttg_ 20
Mac/802_16 set frame_duration_ 0.005
Mac/802_16 set ITU_PDP_ 2
Phy/WirelessPhy/OFDMA set g_ 0.25
#define coverage area for base station
# 200 mw for MS specified in standard, we use the same for all nodes
for the time being
Phy/WirelessPhy set Pt_ 0.2
Phy/WirelessPhy set RXThresh_ 1.90546e-16
Phy/WirelessPhy set CSThresh_ [expr 0.9*[Phy/WirelessPhy set
RXThresh_]]
Phy/WirelessPhy set OFDMA_ 1
# Parameter for wireless nodes
set opt(chan) Channel/WirelessChannel ;# channel type
set opt(prop) Propagation/OFDMA ;# radio-propagation model
set opt(netif) Phy/WirelessPhy/OFDMA ;# network
interface type NEW
set opt(mac) Mac/802_16 ;# MAC type
set opt(ifq) Queue/DropTail/PriQueue; # interface queue type
set opt(ll) LL ;# link layer
type
set opt(ant) Antenna/OmniAntenna ;# antenna model
set opt(ifqlen) 50 ;# max packet in ifq
set opt(adhocRouting) DSDV ;# routing
protocol
set opt(x)
670
;# X dimension of the
topography
set opt(y)
670
;# Y dimension of the
topography
#defines function for flushing and closing files
proc finish {} {
global ns nf tf output_dir nb_ss nm_bs output_file codec
$ns flush-trace
close $tf
exit
0
}
#create the simulator
77
set ns [new Simulator]
#create the topography
set topo [new Topography]
$topo load_flatgrid $opt(x) $opt(y)
#setup trace (.tr) file
set tf [open $output_file w]
$ns trace-all $tf
# set up for hierarchical routing (needed for routing over a
basestation)
$ns node-config -addressType hierarchical
AddrParams set domain_num_ 2 ;# domain number (number of BS
+ 1 (sink node (0.0.0))
puts "NumBS: 1"
set nb_bs 1
#creates the sink node in first addressing space.
set sinkNode [$ns node 0.0.0]
#provide some co-ord (fixed) to base station node
$sinkNode set X_ 50.0
$sinkNode set Y_ 50.0
$sinkNode set Z_ 0.0
#puts "sink node created"
lappend cluster_num 1
;# cluster number for each
domain
for {set ClusterCounter 1} {$ClusterCounter <= $nb_bs} {incr
ClusterCounter} {
lappend cluster_num 1
}
AddrParams set cluster_num_ $cluster_num
lappend eilastlevel 1 ;# number of nodes for each cluster
for {set NodeCounter 1} {$NodeCounter <= $nb_bs} {incr NodeCounter}
{
lappend eilastlevel [expr $nb_ss + 1];# number of nodes for
each cluster
}
AddrParams set nodes_num_ $eilastlevel
puts "Configuration of hierarchical addressing done"
# Create God
create-god [expr $nb_ss + 2]
#create common channel
set channel [new $opt(chan)]
#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 $channel \
-topoInstance $topo \
-wiredRouting ON \
78
-agentTrace OFF \
-routerTrace OFF \
-macTrace ON \
-movementTrace OFF
#setup channel model
set prop_inst [$ns set propInstance_]
$prop_inst ITU_PDP PED_A
puts "Configuration of base station"
set Pi 3.14159
set CenterX 500
set CenterY 500
#Calculate the separateion angle
set SS_SeparationAngle [expr 2*$Pi / $nb_ss]
set SS_RingRadius 150
set bstation [$ns node 1.0.0]
;# create the BS
$bstation random-motion 0 ;#turn off random motion
set BS_xloc 300
set BS_yloc 400
$bstation set X_ $BS_xloc
$bstation set Y_ $BS_yloc
$bstation set Z_ 0.0
[$bstation set mac_(0)] set-channel 0
puts "BS created"
# creation of the mobile node
$ns node-config -macType Mac/802_16/SS \
-wiredRouting OFF \
-macTrace ON
#add a UDP traffic agent
for {set i 0} {$i < $nb_ss} {incr i} {
set wl_node_($i) [$ns node 1.0.[expr $i + 1]] ;# create the
node.
$wl_node_($i) random-motion 0 ;# disable random motion
$wl_node_($i) base-station [AddrParams addr2id [$bstation
node-addr]] ;#attach SS to BS
$wl_node_($i) set X_ [expr $BS_xloc +
sin(($i)*$SS_SeparationAngle)*$SS_RingRadius]
$wl_node_($i) set Y_ [expr $BS_yloc +
cos(($i)*$SS_SeparationAngle)*$SS_RingRadius]
$wl_node_($i) set Z_ 0.0
$ns initial_node_pos $wl_node_($i) 20
[$wl_node_($i) set mac_(0)] set-channel 0 ;#same channel as BS
puts "wireless node created ..."
[$wl_node_($i) set mac_(0)] set-diuc $diuc
[$wl_node_($i) set mac_(0)] setflow UL 100000 BE 700 2 0 0.05
15 1 0 0 0 0 0 0 0 0 0 0 ;# setting up static flows
#create source for traffic
#Create a UDP agent for the SS
79
set udp($i) [new Agent/UDP]
$udp($i) set packetSize_ 1500
$ns attach-agent $wl_node_($i) $udp($i)
#creat sink for traffic
# Create the Null agent to sink traffic
set null($i) [new Agent/Null]
$ns attach-agent $sinkNode $null($i)
#creat voip traffic
set voip($i) [new Application/Traffic/VoIP]
$voip($i)
vad
$voip($i) use-vad-model "one-to-one"
$voip($i) use-codec $codec
#$voip cng ;#for silence suppression
$voip($i) attach-agent $udp($i)
$ns connect $udp($i) $null($i)
}
# create the link between sink node and base station
$ns duplex-link $sinkNode $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 collision
set diff 0.02
for {set i 0} {$i < $nb_ss} {incr i} {
$ns at [expr $traffic_start+$i*$diff] "$voip($i) start"
$ns at [expr $traffic_stop+$i*$diff] "$voip($i) stop"
}
#run simulation
$ns at $simulation_stop "finish"
puts "Running simulation"
$ns run
puts "Simulation done."
80
Do'stlaringiz bilan baham: |