I want study the handover between the umts and wlan.
But when I simulate this tcl script.
Code:
proc getopt {argc argv} {
global opt;
for {set i 0} {$i<$argc} {incr i} {
set opt($i) [lindex $argv $i]
}
}
getopt $argc $argv;
set rate $opt(0);
if {$rate<=1} {
set rate 2000000;
}
global ns;
set ns [new Simulator];
set tracefd [open udw.tr w];
$ns trace-all $tracefd;
$ns use-newtrace;
proc finish {} {
global ns
global tracefd
$ns flush-trace
close $tracefd
puts "Simulation ended."
exit 0
}
#---------- Global configuration: start....>> ----------#
# set topography.
set topo [new Topography];
$topo load_flatgrid 1000 1000;
# ggsn0
# (0.0.0)
# / \
# / \
# sgsn0 \
# (1.0.0) \
# / \
# rnc0 \
# (2.0.0) \
# / \
# bs0 ap0
# (2.0.1) (4.0.0)
# / \ \
# umts_0 umts_1 wlan_0
# (2.0.2) (2.0.3) (4.0.1)
$ns node-config -addressType hierarchical;
AddrParams set domain_num_ 6;
AddrParams set cluster_num_ {1 1 1 1 1 1};
AddrParams set nodes_num_ {1 1 4 1 2 1};
# Set GGSN (Gateway GPRS Support Node)
# umts & wlan network share ggsn0 as the gateway to the internet.
set ggsn0 [$ns node 0.0.0];
# Set UDP-CBR connection
set udp_0 [new Agent/UDP];
$udp_0 set fid_ 0;# flow_id=0
$ns attach-agent $ggsn0 $udp_0;
set cbr_0 [new Application/Traffic/CBR];
$cbr_0 set packet_size_ 1000
$cbr_0 set rate_ $rate;
$cbr_0 set random_ false;# disable noise feature.
$cbr_0 attach-agent $udp_0;
# Just confirm if wlan network could work.
set udp_1 [new Agent/UDP];
$udp_1 set fid_ 1;# flow_id=1
$ns attach-agent $ggsn0 $udp_1;
set cbr_1 [new Application/Traffic/CBR];
$cbr_1 set packet_size_ 1000;
$cbr_1 set rate_ $rate;
$cbr_1 set random_ false;
$cbr_1 attach-agent $udp_1;
#---------- Global configuration: end.<< ----------#
#---------- Setup UMTS network: start....>> ----------#
ChannelSwitcher set noSwitching_ true; #?
Mac/Hsdpa set max_mac_hs_buffer_level_ 1000;# High Speed Downlink Packet Access
# Set RNC (Radio Network Controller)
$ns node-config -UmtsNodeType rnc;
set rnc0 [$ns create-Umtsnode 2.0.0];# ID=0, address=
# Set BS (Base Station)
$ns node-config -UmtsNodeType bs \
-downlinkBW 32kbs \
-downlinkTTI 10ms \
-uplinkBW 32kbs \
-uplinkTTI 10ms \
-hs_downlinkTTI 2ms \
-hs_downlinkBW 64kbs;
set bs0 [$ns create-Umtsnode 2.0.1];# ID=1, address=
# Interface between RNC and BS
$ns setup-Iub $bs0 $rnc0 622Mbit 622Mbit 15ms 15ms DummyDropTail 2000;
# Set UE (User Equipment)
$ns node-config -UmtsNodeType ue \
-baseStation $bs0 \
-radioNetworkController $rnc0;
set umts_0 [$ns create-Umtsnode 2.0.2];
set umts_1 [$ns create-Umtsnode 2.0.3];
# Set SGSN (Serving GPRS Support Node)
set sgsn0 [$ns node 1.0.0];# ID=3, address=
$ns duplex-link $sgsn0 $ggsn0 100Mb 0.5ms DropTail;
# Connections between fixed network nodes
$ns duplex-link $rnc0 $sgsn0 100Mb 0.5ms DropTail;
$rnc0 add-gateway $sgsn0;
# Set null to receive packet from ggsn.
set null0 [new Agent/Null];
$ns attach-agent $umts_0 $null0;
$ns connect $udp_0 $null0;
# Set DCH (Downlink Channel)
$ns node-config -llType UMTS/RLC/UM \
-downlinkBW 64kbs \
-uplinkBW 64kbs \
-downlinkTTI 20ms \
-uplinkTTI 20ms \
-hs_downlinkTTI 2ms \
-hs_downlinkBW 64kbs;
set dch0 [$ns create-dch $umts_0 $null0];
# Tracing for all DCH traffic in downtarget
# $rnc trace-inlink-tcp $tracefd 0
# $bs trace-outlink $tracefd 2
# umts_0 Tracing
# $umts_0 trace-inlink $tracefd 2
# $umts_0 trace-inlink-tcp $tracefd 2
#---------- Setup UMTS network: end.<< ----------#
#---------- Setup WLAN network: start....>> ----------#
# create god object.
create-god 9;
# physical settings.
# /opt/ns-allinone-2.35/ns-2.35/indep-utils/propagation/threshold -m TwoRayGround -fr 2.4e+9 -Pt 0.1 100
Phy/WirelessPhy set freq_ 2.4e+9;
Phy/WirelessPhy set RXThresh_ 9.89465e-10;# 100m.
Phy/WirelessPhy set CSThresh_ 1.296e-10;
Phy/WirelessPhy set Pt_ 0.1;# 100mW
# As UMTS support a datarate up to 1920kbps, WLAN must be much faster.
# MAC layer specification: IEEE 802.11g (54Mbps);
Mac/802_11 set CWMin 31
Mac/802_11 set CWMax 1023
Mac/802_11 set SlotTime_ 0.000009
Mac/802_11 set SIFS_ 0.000010
Mac/802_11 set PreambleLength_ 96
Mac/802_11 set PLCPHeaderLength_ 40
Mac/802_11 set PLCPDataRate_ 6.0e6
Mac/802_11 set dataRate_ 54.0e6
Mac/802_11 set basicRate_ 1.0e6
Mac/802_11 set RTSThreshold_ 256
Mac/802_11 set ShortRetryLimit_ 7
Mac/802_11 set LongRetryLimit_ 4
# Node config
$ns node-config -adhocRouting DSDV; # while adhoc network is AODV
$ns node-config -llType LL;
$ns node-config -macType Mac/802_11;
$ns node-config -ifqType Queue/DropTail/PriQueue;
$ns node-config -ifqLen 50; # network adaptor queue length
$ns node-config -antType Antenna/OmniAntenna;
$ns node-config -propType Propagation/TwoRayGround;
$ns node-config -phyType Phy/WirelessPhy;
$ns node-config -channelType Channel/WirelessChannel;
$ns node-config -topoInstance $topo;
$ns node-config -agentTrace ON;
$ns node-config -routerTrace OFF;
$ns node-config -macTrace OFF;
# Set GateWay for WLAN network
$ns node-config -wiredRouting ON;
set gw0 [$ns node 3.0.0];
$ns duplex-link $gw0 $ggsn0 100Mb 0.5ms DropTail;
# Set WLAN access point
set ap0 [$ns node 4.0.0];
# $AP set X_ 100.00;
# $AP set Y_ 100.00;
# $AP set Z_ 0.00;
# $ns initial_node_pos $AP 5;
$ns duplex-link $gw0 $ap0 100Mb 0.5ms DropTail;
# Set wlan user device
$ns node-config -wiredRouting OFF;
set wlan_0 [$ns node 4.0.1];
$wlan_0 base-station [AddrParams addr2id [$ap0 node-addr]];
# $wlan_0 set X_ 120.00;
# $wlan_0 set Y_ 100.00;
# $wlan_0 set Z_ 0.00;
# $ns initial_node_pos $wlan_0 5;
# Set null to receive packet from ggsn
set null1 [new Agent/Null];
$ns attach-agent $wlan_0 $null1;
$ns connect $udp_1 $null1;
#---------- Setup WLAN network: end.<< ----------#
#---------- Setup User Equipment: start....>> ----------#
#$ns node-config -multiIf ON;#to create MultiFaceNode
#set ue_0 [$ns node 5.0.0];
#$ns node-config -multiIf OFF;
#$ue_0 add-interface-node $wlan_0;
#$ue_0 add-interface-node $umts_0;
#---------- Setup User Equipment: end.<< ----------#
$ns at 1 "$cbr_0 start";
$ns at 50 "$cbr_0 stop";
$ns at 1 "$cbr_1 start";
$ns at 50 "$cbr_1 stop";
$ns at 60 "finish";
puts " Simulation is running ... please wait ..."
$ns run
it has some error like
Quote:
lady@ubuntu:~/lady/umts_wlan$ ns umts_wlan.tcl
can't read "opt(0)": no such element in array
while executing
"set rate $opt(0)"
(file "umts_wlan.tcl" line 9)
|
I really have no idea about it, can anybody help?Thanks.