[ns] wireless handoff
izzeldin shibeika
shibeika at gmail.com
Tue Jun 14 16:44:51 PDT 2005
i'm trying to simulate a simple handoff between 2 base stations but
i can see that there's a connection with the home agent but not with
the foreign one. is there any code i suppose to write it so the mobile
node can know.
below is my code. please help me as soon as possible.
#################################################################
# Izzeldin Shibeika - 06/01/05 - ifshibei at uncc.edu #
# sim0613-2BS.tcl #
# this code has 1 wired node, 2 Base Station and 1 mobile nodes.
#
# #
#################################################################
# =======================================================
# Define options
# =======================================================
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(adhocRouting) DSDV ;# routing protocol
set val(x) 670 ;# X dimension of the topography
set val(y) 670 ;# Y dimension of the topography
set val(ifqlen) 500 ;# max packet in ifq
set val(seed) 0.0 ;# seed for random number gen.
set val(stop) 50.0 ;# simulation time
set val(nn) 1 ;# number of mobilenodes
set val(n) 2 ;# number of base stations
set val(cbr1-start) 3.0 ;# start udp application
set val(cbr1-stop) 25.0 ;# stop udp application
# Main
#Create a simulator object
set ns [new Simulator]
#Define different colors for data flows (for NAM)
$ns color 1 Blue
$ns color 2 Red
#Open the NAM trace file
set nf [open nam0613-2BS.nam w]
$ns namtrace-all-wireless $nf $val(x) $val(y)
#Open the Trace file using the new format
$ns use-newtrace
set tf [open trace0613-2BS.tr w]
$ns trace-all $tf
#Define a 'finish' procedure
proc finish {} {
global ns nf tf
$ns flush-trace
#Close the NAM trace file
close $nf
#Close the Trace file
close $tf
exit 0
}
# Create topography object
set topo [new Topography]
# define topology
$topo load_flatgrid $val(x) $val(y)
# set up for hierarchical routing
# now we have 2 diff domains for wired and wireless
$ns node-config -addressType hierarchical
AddrParams set domain_num_ 3 ;# number of domains
lappend cluster_num 1 1 1 ;# number of clusters in each domain
AddrParams set cluster_num_ $cluster_num
lappend eilastlevel 1 2 1 ;# number of nodes in each cluster
AddrParams set nodes_num_ $eilastlevel ;# of each domain
# Create God
create-god $val(nn)+$val(n)
#create a wired node
set node [$ns node 0.0.0]
$node set X_ 350.0
$node set Y_ 350.0
$node set Z_ 0.0
# Initialize the SharedMedia interface with parameters to make
# it work like the 914MHz Lucent WaveLAN DSSS radio interface
Phy/WirelessPhy set CPThresh_ 10.0 ;# receive power threshold
Phy/WirelessPhy set CSThresh_ 1.559e-11 ;# -108.07154db carrier sense thresh
Phy/WirelessPhy set RXThresh_ 3.652e-10 ;# -94.374692db receive power thresh
Phy/WirelessPhy set Rb_ 2*1e6
Phy/WirelessPhy set Pt_ 0.2818 ;# For 250m transmission range.
Phy/WirelessPhy set freq_ 914e+6 ;# frequency
Phy/WirelessPhy set L_ 1.0 ;# system loss factor
Phy/WirelessPhy set Pt_consume_ 0.660 ;# 1.6 W drained power for tx
Phy/WirelessPhy set Pr_consume_ 0.395 ;# 1.2 W drained power for reception
Phy/WirelessPhy set P_idle_ 0.035; ;# 1.15 W drained power for idle
# define channels
# now we have just 1 channel
set chan_1 [new $val(chan)]
#global node setting for base station
$ns node-config -adhocRouting $val(adhocRouting) \
-llType $val(ll) \
-macType $val(mac) \
-ifqType $val(ifq) \
-ifqLen $val(ifqlen) \
-antType $val(ant) \
-propType $val(prop) \
-phyType $val(netif) \
-channel $chan_1 \
-topoInstance $topo \
-mobileIP ON \
-wiredRouting ON \
-agentTrace ON \
-routerTrace ON \
-macTrace ON
#create base-station nodes
for {set i 0} {$i < $val(n)} {incr i} {
set BS($i) [$ns node [expr $i+1].0.0]
$BS($i) random-motion 0 ;# disable random motion
#provide some co-ord (fixed) to base station node
$BS($i) set X_ [expr 250.0+$i*100]
$BS($i) set Y_ 250.0
$BS($i) set Z_ 0.0
}
#configure for mobilenodes
$ns node-config -wiredRouting OFF
#Create mobile nodes
set n(0) [$ns node 1.0.1] ;# create node with address
#set node_(0) $n(0)
set BSaddress [AddrParams addr2id [$BS(0) node-addr]]
[$n(0) set regagent_] set home_agent_ $BSaddress
$n(0) set X_ 50.0
$n(0) set Y_ 100.0
$n(0) set Z_ 0.0
# next-hop information
$ns compute-routes
#create links between wired and BS nodes
$ns duplex-link $node $BS(0) 5Mb 2ms DropTail
$ns duplex-link $node $BS(1) 5Mb 2ms DropTail
$ns duplex-link-op $node $BS(0) orient left-down
$ns duplex-link-op $node $BS(1) orient right-down
# traffic setup
# setup UDP connection between the wired node and the mobile node
set udp1 [new Agent/UDP]
$ns attach-agent $node $udp1
set null1 [new Agent/Null]
$ns attach-agent $n(0) $null1
$ns connect $udp1 $null1
$udp1 set class_ 1
set cbr1 [new Application/Traffic/CBR]
$cbr1 attach-agent $udp1
#$cbr1 set type_ CBR
#$cbr1 set packet_size_ 1000
#$cbr1 set rate_ 1mb
#$cbr1 set random_ false
$ns at $val(cbr1-start) "$cbr1 start"
# Define initial node position in nam
for {set i 0} {$i < $val(nn)} {incr i} {
$ns initial_node_pos $n($i) 20
}
# setup nodes movement
$ns at 7.0 "$n(0) setdest 650.0 100.0 100.0"
# stop traffic
$ns at $val(cbr1-stop) "$cbr1 stop"
# Tell all nodes when the simulation ends
for {set i } {$i < $val(nn) } {incr i} {
$ns at $val(stop).0 "$n($i) reset"
}
# stop simulation
$ns at $val(stop).0 "$BS(0) reset";
$ns at $val(stop).0001 "$BS(1) reset";
$ns at $val(stop).0006 "puts \"NS EXITING...\" ; $ns halt"
$ns at $val(stop).0008 "finish"
#Run the simulation
$ns run
Thank you,
--
Izzeldin Shibeika
Research Assistant
University of North Carolina at Charlotte
Electrical & Computer Engineering
Office: Smith 353
Phone: (704)492-0032
Email: ifshibei at uncc.edu
More information about the Ns-users
mailing list