ns2 code for vertical handover What is vertical handover??? Vertical handoff refers also to a network node changing the type of connectivity it also uses to access a supporting infrastructure, also usually to support node mobility.
Three main phases of vertical handover:
- System discovery.
- Vertical handoff also in decision.
- Also VHO (Vertical Hand Off) execution.
Sample Ns2 code for Vertical Handover Projects
#check input parameters if {$argc >= 3 || $argc <1} { puts "" puts "Wrong Number of Arguments! " puts "command is ns scenario1.tcl case \[seed\]" exit 1 } global ns # Define global simulation parameters Agent/MIHUser/IFMNGMT/MIPV6/Handover/Handover1 set case_ [lindex $argv 0] # seed the default RNG global defaultRNG if {$argc == 2} { set seed [lindex $argv 1] if { $seed == "random"} { $defaultRNG seed 0 } else { $defaultRNG seed [lindex $argv 1] } } #define coverage area for base station: 50m coverage Phy/WirelessPhy set Pt_ 0.0134 Phy/WirelessPhy set freq_ 2412e+6 Phy/WirelessPhy set RXThresh_ 5.25089e-10 #define frequency of RA at base station Agent/ND set maxRtrAdvInterval_ 6 Agent/ND set minRtrAdvInterval_ 2 #define MAC 802_11 parameters Mac/802_11 set bss_timeout_ 5 Mac/802_11 set pr_limit_ 1.2 ;#for link going down #wireless routing algorithm update frequency (in seconds) Agent/DSDV set perup_ 8 #define DEBUG parameters set quiet 0 Agent/ND set debug_ 1 Agent/MIH set debug_ 1 Agent/MIHUser/IFMNGMT/MIPV6/Handover/Handover1 set debug_ 1 Mac/802_11 set debug_ 0 #Rate at which the nodes start moving set moveStart 10 set moveStop 130 #Speed of the mobile nodes (m/sec) set moveSpeed 1 #origin of the MN set X_src 40.0 set Y_src 100.0 set X_dst 160.0 set Y_dst 100.0 #defines function for flushing and closing files proc finish {} { global ns f quiet namtrace $ns flush-trace close $f close $namtrace exec nam out.nam & exec awk { { if ( $1 == "r" && $5 == "cbr") { if($4 == 0 ) { u += 1 print "u",$12, $2, u*8*500/$2 } if ($4 == 6 ) { w += 1 print "w",$12, $2, w*8*500/$2 } } } } out.res > throughput.tr set S_count 0 set R_count 0 set i 0 exec awk { { if ($1 == "+" && $5 == "cbr" && $4 == "4") { i++; S_count++; Sent_Time[i] = $2; } if ($1 == "r" && $5 == "cbr" && $3 == "4") { c++; R_count++; Recv_Time[c] = $2; delay[i]= Recv_Time[c] - Sent_Time[i] total_delay = total_delay + delay[i] avg_delay = (total_delay/R_count) if (R_count > 1) { jitter[i] = delay[i] - delay[i-1] sum_jitter += jitter[i] avg_jitter= sum_jitter/ (R_count - 1) print c, $2, delay[i] #print c, $2, jitter[i] } } } } out.res > delay.tr if {$quiet == 0} { puts " Simulation ended." } exit 0 } # set global variables set output_dir . #create the simulator set ns [new Simulator] $ns use-newtrace #open file for trace set f [open out.res w] $ns trace-all $f set namtrace [open out.nam w] $ns namtrace-all-wireless $namtrace 200 200 set topo [new Topography] $topo load_flatgrid 200 200 puts "Topology Created" # set up for hierarchical routing (needed for routing over a basestation) $ns node-config -addressType hierarchical AddrParams set domain_num_ 5 ;# domain number AddrParams set cluster_num_ {1 1 1 1 1} ;# cluster number for each domain # 1st cluster: UMTS: 2 network entities + nb of mobile nodes # 2nd cluster: CN # 3rd cluster: core network # 4th cluster: WLAN: 1BS + nb of mobile nodes # 5th cluster: super nodes lappend tmp 3 ;# UMTS MNs+RNC+BS lappend tmp 1 ;# router 0 lappend tmp 1 ;# router 1 lappend tmp 2 ;# 802.11 MNs+BS lappend tmp 1 ;# MULTIFACE nodes AddrParams set nodes_num_ $tmpTweet