[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[ns] mobile node movement in Mobile IP
Hi ns users
I am running a small Mobile IP program where I want to send UDP packets
from a wired node to a mobile node while the mobile node moves from one
foreign agent to another.
The two major problems I have are that first of all, the packets only
make it to the HA but not to the FA1/FA2 or the MN (which can be seen in
the two tracefiles). Also, I can't get the MN to move (I am using
setdest as can be seen in the code below) which can be seen
from the output I get when I print the coordinates of the MN. I would be
very glad if anyone could help me out with these two problems.
Thanks
Babak Ayani
Here is the code of my program:
#options
set opt(chan) Channel/WirelessChannel
set opt(prop) Propagation/TwoRayGround
set opt(netif) Phy/WirelessPhy
set opt(mac) Mac/802_11
set opt(ifq) Queue/DropTail/PriQueue
set opt(ll) LL
set opt(ant) Antenna/OmniAntenna
set opt(x) 670 ;# X & Y dimension of the topography
set opt(y) 670 ;# hard wired for now...
set opt(rp) dsr ;# rotuing protocls: dsdv/dsr
set opt(ifqlen) 50 ;# max packet in ifq
set opt(seed) 0.0
set opt(stop) 20.0 ;# simulation time
set opt(cc) "off"
set opt(tr) wireless-mip-out.tr ;# trace file
set opt(cp) ""
set opt(sc) ""
set opt(cbr-start) 5.0
# =================================================================
set num_wired_nodes 2
set num_bs_nodes 3
set num_wireless_nodes 1
set opt(nn) 4 ;# total number of wireless nodes
#==================================================================
# Other class settings
set AgentTrace ON
set RouterTrace OFF
set MacTrace OFF
LL set mindelay_ 50us
LL set delay_ 25us
Agent/Null set sport_ 0
Agent/Null set dport_ 0
Agent/CBR set sport_ 0
Agent/CBR set dport_ 0
Queue/DropTail/PriQueue set Prefer_Routing_Protocols 1
# ==================================================================
source ../../ns-2.1b7a/tcl/lib/ns-wireless-mip.tcl
# intial setup - set addressing to hierarchical
set ns [new Simulator]
$ns set-address-format hierarchical
# set mobileIP flag
Simulator set mobile_ip_ 1
set namtrace [open wireless-mip.nam w]
$ns namtrace-all $namtrace
set trace [open wireless-mip.tr w]
$ns trace-all $trace
AddrParams set domain_num_ 4
lappend cluster_num 2 1 1 1 ;#number of
clusters in each domain
AddrParams set cluster_num_ $cluster_num
lappend eilastlevel 1 1 1 2 1 ;#number of
nodes in each cluster
AddrParams set nodes_num_ $eilastlevel ;#of each
domain
## setup the wired nodes
set temp {0.0.0 0.1.0}
for {set i 0} {$i < $num_wired_nodes} {incr i} {
set W($i) [$ns node [lindex $temp $i]]
}
## create common objects reqd for wireless sim.
set chan [new $opt(chan)]
set prop [new $opt(prop)]
set topo [new Topography]
set tracefd [open $opt(tr) w]
# setup topography and propagation model
$topo load_flatgrid $opt(x) $opt(y)
$prop topography $topo
# Create God
create-god $opt(nn)
## setup ForeignAgent and HomeAgent nodes
set HA [create-base-station-node 1.0.0]
set FA1 [create-base-station-node 2.0.0]
set FA2 [create-base-station-node 3.0.0]
#provide some co-ord (fixed) to these base-station nodes.
$HA set X_ 1.000000000000
$HA set Y_ 2.000000000000
$HA set Z_ 0.000000000000
$FA1 set X_ 650.000000000000
$FA1 set Y_ 650.000000000000
$FA1 set Z_ 0.000000000000
$FA2 set X_ 600.000000000000
$FA2 set Y_ 600.000000000000
$FA2 set Z_ 0.000000000000
# create a mobilenode that would be moving between FA1 and FA2. Note
#address of MH indicates its in the same domain as FA1.
set MH [$opt(rp)-create-mobile-node 0 2.0.2]
set FA1address [AddrParams addr2id [$FA1 node-addr]]
[$MH set regagent_] set foreign_agent_1 $FA1address
# movement of the MH
$MH set Z_ 0.000000000000
$MH set Y_ 649.000000000000
$MH set X_ 649.000000000000
# starts to move towards FA2
$ns at 10.000000000000 "$MH setdest 610.0000000000 610.0000000000
20.000000000000" ;#this is the part that is not working
$ns at 13.000000000000 "puts x=[$MH set X_]" ;#the output is 649
which means that the MN hasen't moved
$ns at 13.000000000000 "puts y=[$MH set Y_]"
$ns at 13.000000000000 "puts z=[$MH set Z_]"
#create links between wired and BaseStation nodes
$ns duplex-link $W(0) $W(1) 5Mb 2ms DropTail
$ns duplex-link $W(1) $HA 5Mb 2ms DropTail
$ns duplex-link $HA $FA1 5Mb 2ms DropTail
$ns duplex-link $HA $FA2 5Mb 2ms DropTail
#If I have these two lines instead of the two above the packets arive at
the FA1
#but that is not how it sould be in Mobile IP. Why does not the above
work??
#$ns duplex-link $W(1) $FA1 5Mb 2ms DropTail
#$ns duplex-link $W(1) $FA2 5Mb 2ms DropTail
# setup UDP connections between a wired node and the MobileHost
set udp_(0) [new Agent/UDP]
$ns_ attach-agent $W(0) $udp_(0)
set null_(0) [new Agent/Null]
$ns_ attach-agent $MH $null_(0)
set cbr_(0) [new Application/Traffic/CBR]
$cbr_(0) set packetSize_ 200
$cbr_(0) set interval_ 2.0
$cbr_(0) set random_ 1
$cbr_(0) set maxpkts_ 1000
$cbr_(0) attach-agent $udp_(0)
$ns_ connect $udp_(0) $null_(0)
$ns_ at $opt(cbr-start) "$cbr_(0) start"
# Tell all the nodes when the simulation ends
for {set i 0} {$i < $num_wireless_nodes } {incr i} {
$ns_ at $opt(stop).0000010 "$node_($i) reset";
}
$ns_ at $opt(stop).0000010 "$HA reset";
$ns_ at $opt(stop).0000010 "$FA1 reset";
$ns_ at $opt(stop).0000010 "$FA2 reset";
$ns_ at $opt(stop).21 "finish"
$ns_ at $opt(stop).20 "puts \"NS EXITING...\" ; "
proc finish {} {
global ns_ trace namtrace
$ns_ flush-trace
close $namtrace
close $trace
puts "Finishing ns.."
exit 0
}
puts "Starting Simulation..."
$ns_ run