LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Ubuntu
User Name
Password
Ubuntu This forum is for the discussion of Ubuntu Linux.

Notices


Reply
  Search this Thread
Old 04-10-2015, 12:47 AM   #1
ladyelaine
LQ Newbie
 
Registered: Apr 2015
Posts: 10

Rep: Reputation: Disabled
umts_wlan.tcl on ns2.35


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.

Last edited by ladyelaine; 04-10-2015 at 12:48 AM.
 
Old 04-10-2015, 04:31 AM   #2
knudfl
LQ 5k Club
 
Registered: Jan 2008
Location: Copenhagen DK
Distribution: PCLinuxOS2023 Fedora38 + 50+ other Linux OS, for test only.
Posts: 17,511

Rep: Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641
Please show your solution.
 
Old 04-10-2015, 06:37 AM   #3
ladyelaine
LQ Newbie
 
Registered: Apr 2015
Posts: 10

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by knudfl View Post
Please show your solution.
sorry,I don't know why it's maked as solved, it's very weird.Maybe I click some wrong button.
I'm now trying to work it out. If I make it, I will share it with u.
 
  


Reply

Tags
ns2



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
tcl ns2 (not running) ansarsatti Linux - Newbie 4 01-25-2015 12:07 PM
olsr.tcl with ns2.35 Suhaila Linux - Software 6 03-10-2014 11:16 AM
NS2 tcl scripting kumar_s Linux - Wireless Networking 1 01-13-2014 12:05 AM
UMTS_WLAN NS2 simulation RSM_smile Linux - Newbie 0 09-17-2012 06:11 PM
script tcl NS2 MounaRM Linux - Networking 0 01-10-2011 08:49 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Ubuntu

All times are GMT -5. The time now is 06:10 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration