Hello everybody,
I am trying to simulate a hand over. Following script shows two nodes (acting
as AP) and a node moving within their vicinity. After a certain amount of
simulation time, node 0 gets out of range of node 1 (AP) and stops sending
packets. This is the point it needs to get associated with node 2 (another AP).
I dont know how to do that can some one help?
In order to make it work, I have intentionally stopped the previous connection
and started a new one (between node 0 and new AP). How can I make hand over
take place on its own.
Please write back soon,
Faraz
======================================================================
# Define options
# ======================================================================
set val(chan) Channel/WirelessChannel ;# channel type
set val(prop) Propagation/TwoRayGround ;# radio-propagation model
set val(netif) Phy/WirelessPhy ;#
Phy/WirelessPhy set freq_ 2.472e9 ;# network interface type
Phy/WirelessPhy set CPThresh_ 10.0 ;# Collision Threshold
Phy/WirelessPhy set CSThresh_ 5.011872e-12 ;# Carrier Sense Threshold
Phy/WirelessPhy set RXThresh_ 5.82587e-09 ;# Receiver Threshold
Phy/WirelessPhy set bandwidth_ 11Mb ;# BW
set val(mac) Mac/802_11 ;# MAC type
Mac/802_11 set dataRate_ 11Mb ;# Data Rate
Mac/802_11 set basicRate_ 1Mb ;# Control Frame Rate
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(ifqlen) 50 ;# max packet in ifq
set val(nn) 3 ;# number of mobilenodes
set val(rp) AODV ;# routing protocol
set val(x) 200 ;# x-axis of grid
set val(y) 200 ;# y-asix of grid
set opt(energymodel) EnergyModel ;
set opt(radiomodel) RadioModel ;
set opt(initialenergy) 1000 ;# Initial energy in Joules
set num_ms_nodes 10;
set opt(nn) 3;
# ======================================================================
# Main Program
# ======================================================================
#
# Initialize Global Variables
#
#start the simulator
set ns [new Simulator]
#open the trace file
set tracefile1 [open a.tr w]
$ns trace-all $tracefile1
#Open the NAM trace file
set nf [open out.nam w]
#$ns namtrace-all $nf
$ns namtrace-all-wireless $nf $val(x) $val(y)
#Define a 'finish' procedure
proc finish {} {
global ns nf
$ns flush-trace
#Close the NAM trace file
close $nf
#Execute NAM on the trace file
exec /home/faraz/Desktop/ns-allinone-2.33/nam-1.13/nam out.nam
exit 0
}
#define the procedure finish
#proc finish {} {
#global ns tracefile1
#$ns flush-trace
#close $tracefile1
#exit 0
#}
# set up topography object
set topo [new Topography]
$topo load_flatgrid $val(x) $val(y)
# Create God General Operations Director
create-god [expr $opt(nn) + $num_ms_nodes]
# Create channel #1 and #2
set chan_1_ [new $val(chan)]
#
# Create the specified number of mobilenodes [$val(nn)] and "attach" them
# to the channel.
# Here two nodes are created : node(0) and node(1)
# configure node
$ns node-config -adhocRouting $val(rp) \
-llType $val(ll) \
-macType $val(mac) \
-ifqType $val(ifq) \
-ifqLen $val(ifqlen) \
-antType $val(ant) \
-propType $val(prop) \
-phyType $val(netif) \
-topoInstance $topo \
-agentTrace OFF \
-routerTrace ON \
-macTrace OFF \
-movementTrace OFF\
-channel $chan_1_
#-energyModel $opt(energymodel) \
-idlePower 1.0 \
-rxPower 1.0 \
-txPower 1.0 \
-sleepPower 0.001 \
-transitionPower 0.2 \
-transitionTime 0.005 \
-initialEnergy $opt(initialenergy)
for {set i 0} {$i < $val(nn) } {incr i} {
set node_($i) [$ns node]
$node_($i) random-motion 0 ;# disable random motion
}
$node_(0) set X_ 0.001
$node_(0) set Y_ 75.0
#$node_(0) set Z_ 0.0
$node_(1) set X_ 25.0
$node_(1) set Y_ 125.0
#$node_(1) set Z_ 0.0
$node_(2) set X_ 150.0
$node_(2) set Y_ 125.0
#$node_(2) set Z_ 0.0
set udp0 [new Agent/UDP]
$ns attach-agent $node_(0) $udp0
set cbr0 [new Application/Traffic/CBR]
$cbr0 set packetSize_ 1000
$cbr0 set interval_ 0.05
$cbr0 attach-agent $udp0
set null0 [new Agent/Null]
$ns attach-agent $node_(1) $null0
$ns connect $udp0 $null0
set null1 [new Agent/Null]
$ns attach-agent $node_(2) $null1
$ns at 0.1 "$node_(0) setdest 199.0 75.0 100.0"
$ns at 0.1 "$node_(1) setdest 25.0 125.0 0.0"
$ns at 0.1 "$node_(2) setdest 150.0 125.0 0.0"
$ns at 0.2 "$cbr0 start"
$ns at 1 "$cbr0 stop"
$ns at 1.1 "$ns connect $udp0 $null1"
$ns at 1.2 "$cbr0 attach-agent $udp0"
$ns at 1.3 "$cbr0 start"
$ns at 2.1 "$cbr0 stop"
$ns at 2.3 "finish"
puts "Starting Simulation..."
$ns run