- Home Page of ProjectGuideline.com ›
- Forums ›
- Get Help to do your B.E., and M.E., M.Tech., & M.S., Project in Ns2 ›
- Difficulties in wireless simulation
Hi
I am simulating a handover of a mobile node (MH) between a home network (HA) and a foreign network (FA), in an infrastructure mode. HA is connected to a gateway (HA-GW) and FA is connected to FA-GW
Also the endpoints (MH and CN) use SCTP at the transport layer with 2 interfaces for each endpoint. One interface with HN and the other with FN
However, I have a persistent routing problem and I can’t resolve it.
I tried to compare my script with those in NS tutorial and many other example scripts but I didn’t find the problem.
I send in attachment the script .
Can you please examin it and tell me where is the problem?
I will be thankful for you if you can help me bacause it is extremely urgent
Najla
global opt
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) 700.0
set opt(y) 700.0
set opt(ifqlen) 50
set opt(tr) all.tr
set opt(nn) 10
set opt(adhocRouting) DSDV
set opt(cp) “”
set opt(sc) “”
set opt(stop) 2
Mac/802_11 set dataRate_ 11Mb
#Phy/WirelessPhy set CSThresh_ 10.00e-12
#Phy/WirelessPhy set RXThresh_ 10.00e-11
#Phy/WirelessPhy set Pt_ 0.1
#Phy/WirelessPhy set Pt_ 7.214e-3
Trace set show_sctphdr_ 1
set ns [new Simulator]
# set up for hierarchical routing
$ns node-config -addressType hierarchical
AddrParams set domain_num_ 3
lappend cluster_num 1 1 1
AddrParams set cluster_num_ $cluster_num
lappend eilastlevel 5 4 1
AddrParams set nodes_num_ $eilastlevel
set nf [open sctp7.nam w]
$ns namtrace-all-wireless $nf $opt(x) $opt(y)
set allchan [open sctp7.tr w]
$ns trace-all $allchan
proc finish {} {
global ns
puts “finish”
exec nam sctp7.nam &
$ns flush-trace
exit 0
}
# set up topography object
set topo [new Topography]
$topo load_flatgrid $opt(x) $opt(y)
# Create God
create-god $opt(nn)
#create-god [expr $opt(nn) + 2]
# Create channel
set chan_1_ [new $opt(chan)]
$ns node-config -mobileIP ON
-adhocRouting $opt(adhocRouting)
-llType $opt(ll)
-macType $opt(mac)
-ifqType $opt(ifq)
-ifqLen $opt(ifqlen)
-antType $opt(ant)
-phyType $opt(netif)
-propInstance [new $opt(prop)]
-channel [new $opt(chan)]
-topoInstance $topo
-wiredRouting ON
-agentTrace ON
-routerTrace OFF
-macTrace ON
set HA_GW [$ns node 0.0.0]
#$HA_GW random-motion 0
set FA_GW [$ns node 0.0.1]
#$FA_GW random-motion 0
set CN_core [$ns node 0.0.2]
#$CN_core random-motion 0
set CN_if0 [$ns node 0.0.3]
#$CN_if0 random-motion 0
set CN_if1 [$ns node 0.0.4]
#$CN_if1 random-motion 0
# Create HA and FA
set HA [$ns node 1.0.0]
$HA random-motion 0
set FA [$ns node 2.0.0]
$FA random-motion 0
$ns node-config -wiredRouting OFF
set MH_core [$ns node 1.0.1]
$MH_core random-motion 0
set MH_if0 [$ns node 1.0.2]
$MH_if0 random-motion 0
set MH_if1 [$ns node 1.0.3]
$MH_if1 random-motion 0
set HAaddress [AddrParams addr2id [$HA node-addr]]
[$MH_core set regagent_] set home_agent_ $HAaddress
[$MH_if0 set regagent_] set home_agent_ $HAaddress
[$MH_if1 set regagent_] set home_agent_ $HAaddress
$MH_core color Red
$MH_if0 color Red
$MH_if1 color Red
$HA color Cyan
$FA color Green
$HA label “HA”
$FA label “FA”
$HA_GW color Cyan
$FA_GW color Green
$HA_GW label “HA”
$FA_GW label “FA”
$CN_core color Blue
$CN_if0 color Blue
$CN_if1 color Blue
# Position (fixed) for base-station nodes (HA & FA).
$HA set X_ 300.0
$HA set Y_ 550.0
$HA set Z_ 0.0
$FA set X_ 300.0
$FA set Y_ 150.0
$FA set Z_ 0.0
# Position (fixed) for Gateways (HA_GW & FA_GW).
$HA_GW set X_ 450.0
$HA_GW set Y_ 500.0
$HA_GW set Z_ 0.0
$FA_GW set X_ 450.0
$FA_GW set Y_ 300.0
$FA_GW set Z_ 0.0
# Position for nods (MH & CN).
$MH_core set X_ 250.0
$MH_core set Y_ 550.0
$MH_core set Z_ 0.0
$MH_if0 set X_ 250.0
$MH_if0 set Y_ 600.0
$MH_if0 set Z_ 0.0
$MH_if1 set X_ 250.0
$MH_if1 set Y_ 500.0
$MH_if1 set Z_ 0.0
$CN_core set Z_ 0.0
$CN_core set Y_ 400.0
$CN_core set X_ 600.0
$CN_if0 set Z_ 0.0
$CN_if0 set Y_ 450.0
$CN_if0 set X_ 600.0
$CN_if1 set Z_ 0.0
$CN_if1 set Y_ 350.0
$CN_if1 set X_ 600.0
set mac_(2) [$MH_if0 getMac 0]
$mac_(2) set RTSThreshold_ 3000
set mac_(1) [$MH_if1 getMac 0]
$mac_(1) set RTSThreshold_ 3000
## Define HA as an AP ##
set mac_(0) [$HA getMac 0]
$mac_(0) set RTSThreshold_ 3000
set AP_ADDR1 [$mac_(0) id]
$mac_(0) ap $AP_ADDR1
## Define FA as an AP ##
set mac_(3) [$FA getMac 0]
$mac_(3) set RTSThreshold_ 3000
set AP_ADDR2 [$mac_(3) id]
$mac_(3) ap $AP_ADDR2
$mac_(2) ScanType ACTIVE
$mac_(1) ScanType ACTIVE
$ns multihome-add-interface $MH_core $MH_if0
$ns multihome-add-interface $MH_core $MH_if1
$ns multihome-add-interface $CN_core $CN_if0
$ns multihome-add-interface $CN_core $CN_if1
$ns duplex-link $HA $HA_GW 5Mb 2ms DropTail
$ns duplex-link $FA $FA_GW 5Mb 2ms DropTail
$ns duplex-link $CN_if0 $HA_GW 5Mb 2ms DropTail
$ns duplex-link $CN_if1 $FA_GW 5Mb 2ms DropTail
set sctp0 [new Agent/SCTP]
$ns multihome-attach-agent $MH_core $sctp0
$sctp0 set trace_all_ 1 ;# print all on a single trace event
$sctp0 set usNumStreams 2 ;# nb streams =2
$sctp0 trace rto_
$sctp0 trace errorCount_
$sctp0 attach $allchan
set sctp1 [new Agent/SCTP]
$sctp1 set usNumStreams 2 ;# nb streams =2
$ns multihome-attach-agent $CN_core $sctp1
$ns connect $sctp0 $sctp1
set voice [new Application/Traffic/CBR] ;# CBR traffic generator
$voice set packetSize_ 1023
$voice set rate_ 64Kb
$voice set random_ 0 ;#without noise
$voice attach-agent $sctp0
$voice set fid_ 2
$voice set usStreamId 1
set ftp0 [new Application/FTP]
$ftp0 attach-agent $sctp0
$ftp0 set fid_ 1
$ftp0 set usStreamId 2
# paramétrage des couleurs d’affichage
$ns color 1 Red
$ns color 2 Yellow
$sctp0 set-primary-destination $CN_if0 ;# set primary before association starts
$sctp0 force-source $MH_if0 ;# set primary source before association starts
$ns at 0.01 “$HA setdest 300.0 550.0 1.0 ; $FA setdest 300.0 250.0 1.0 ; $HA_GW setdest 450.0 500.0 1.0 ; $FA_GW setdest 450.0 300.0 1.0 ; $MH_core setdest 250.0 550.0 1.0 ; $MH_if0 setdest 250.0 620.0 1.0 ; $MH_if1 setdest 250.0 480.0 1.0 ; $CN_core setdest 600.0 400.0 1.0 ; $CN_if0 setdest 600.0 450.0 1.0 ; $CN_if1 setdest 600.0 350.0 1.0 “
$ns at 0.5 “$ftp0 start ; $voice start”
$ns at 6.0 “$MH_core setdest 250.0 150.0 500.0 ; $MH_if0 setdest 250.0 180.0 500.0 ; $MH_if1 setdest 250.0 120.0 500.0”
$ns at 7.5 “$sctp0 set-primary-destination $CN_if1” ;# change primary
$ns at 7.5 “$sctp0 print cwnd_” ;# print all dests’ cwnds at time 7.5
$ns at 9.0 “$voice stop”
$ns at 9.5 “$ftp0 stop”
$ns at 10.0 “finish”
puts “running “
$ns run
What kind of result you are getting? And what kind of result you are expecting? – Just explain briefly.
What version of ns you are using?
I am using ns2.33
I expect to simulate the handover of the mobile node and mainly to observe how the mobility is managed with SCTP.
I already tried the script in the case of a wired network and it works.
However, when I use 802.11 at the mac layer, there is no packet transmission between the mobile node and the HA.
It seems like the route between the MN and HA can’t be defined.
I have a message “Node(7) is not defined in the array”!!
@CharlesPandian wrote:
What kind of result you are getting? And what kind of result you are expecting? – Just explain briefly.
What version of ns you are using?