To simulate Vertical Handover (VHO) projects in NS2 have includes designing the seamless transition of a mobile device from one type of network like Wi-Fi to another such as cellular network without interruption in service. NS2, with the help of its MObile Wireless Network (MWN) extension, supports mobile networking, and we can replicate vertical handover by set up multiple interfaces for mobile nodes and programming the handover behaviour according to network conditions.
Here is a step-by-step guide to simulate Vertical Handover projects in NS2:
Steps for Simulating Vertical Handover in NS2
- Install NS2 with MWN Support: make sure that we have NS2 installed. We required the NS-2.35 version or later with MObile Wireless Network (MWN) extensions, that support multiple network interfaces.
For Ubuntu, we can install NS2 as follows:
sudo apt-get install ns2
we can validate the installed version of NS2 with:
ns -version
- Create a Vertical Handover Scenario in Tcl Script: The handover simulation has includes to configure multiple network interfaces for the mobile nodes (Wi-Fi and cellular) and programming the logic for switching among them in terms of signal strength, mobility, or QoS parameters.
Here is a simplified Tcl script to replicate vertical handover from Wi-Fi to a cellular network:
# Create a new NS2 simulator object
set ns [new Simulator]
# Open trace and NAM files
set tracefile [open vho_out.tr w]
$ns trace-all $tracefile
set namfile [open vho_out.nam w]
$ns namtrace-all-wireless $namfile 500 500
# Define the physical channel for wireless (Wi-Fi)
set wifi_chan [new Channel/WirelessChannel]
# Create wired topology for cellular network
set cell_chan [new Channel]
# Create a mobile node with two interfaces (Wi-Fi and Cellular)
set node [new Node/MobileNode]
# Configure Wi-Fi interface (wireless)
set phy [new Phy/WirelessPhy]
$node set phy_ $phy
$node add-interface $phy
# Configure Cellular interface (wired)
set cell_if [new Phy/WiredPhy]
$node add-interface $cell_if
# Create two access points: Wi-Fi AP and Cellular Base Station (BS)
set wifi_ap [$ns node]
set cell_bs [$ns node]
# Create links for access points (wired links to the core network)
$ns duplex-link $wifi_ap $cell_bs 1Mb 10ms DropTail
# Define mobility for the node (simulating the node moving out of Wi-Fi range)
$node set X_ 100
$node set Y_ 100
$node set Z_ 0
# Define node mobility model (simple linear mobility to simulate handover)
set mobility [new Mobility/Linear]
$node attach-mobility $mobility
$mobility set speed_ 10
$mobility set direction_ 90
# Define traffic source: CBR over UDP
set cbr [new Application/Traffic/CBR]
$cbr set packetSize_ 512
$cbr set interval_ 0.01
# Attach traffic to Wi-Fi AP initially
set udp0 [new Agent/UDP]
$node attach-agent $udp0
$ns connect $udp0 [$ns agent UDP $wifi_ap]
# Schedule the CBR traffic start and handover event
$ns at 1.0 “$cbr start”
$ns at 2.5 “handover $node $cell_bs”
# Schedule simulation end
$ns at 5.0 “finish”
proc finish {} {
global ns tracefile namfile
$ns flush-trace
close $tracefile
close $namfile
exec nam vho_out.nam &
exit 0
}
# Handover procedure (moving node from Wi-Fi to Cellular)
proc handover {node new_bs} {
global ns
$node delete-agent $node(udp0) # Detach from Wi-Fi
$node attach-agent $new_bs(udp0) # Attach to Cellular Base Station
puts “Handover to Cellular at [$ns now]”
}
# Run the simulation
$ns run
Explanation of the Tcl Script:
- Simulator Object:
- The set ns [new Simulator] command generates a new simulator object, which is the controller for the simulation.
- Network Channels:
- Two network channels are defined: one for Wi-Fi (wireless) and the other for Cellular (wired).
- Mobile Node with Multiple Interfaces:
- The mobile node is set up with two network interfaces: one for Wi-Fi (WirelessPhy) and another for the cellular network (WiredPhy).
- Access Points and Base Station:
- The mobile node starts communicates through a Wi-Fi access point (wifi_ap) and then hands over to a cellular base station (cell_bs).
- Mobility:
- A mobility model is utilized to replicate the movement of the node out of the range of the Wi-Fi network.
- Traffic Source:
- A CBR (Constant Bit Rate) traffic source is attached to the mobile node that transmits data through UDP. The traffic is start over the Wi-Fi network and later transferred to the cellular network after handover.
- Handover Event:
- The handover procedure replicates the vertical handover by detaching the mobile node from the Wi-Fi network and assigning it to the cellular network.
- Simulation End:
- The finish procedure finishes the simulation at 5 seconds and raises NAM (Network Animator) for envision the network behaviour.
- Running the Simulation:
- Save the script as vho_simulation.tcl and execute it using the ns command:
ns vho_simulation.tcl
- After the simulation, we can view the outcomes in NAM:
nam vho_out.nam
- Analysing the Results:
- Utilize the trace file (vho_out.tr) to measure the handover process. We can extract parameters like packet delivery ratio, delay, and throughput before and after the handover event.
- We need to utilize AWK scripts or other evaluation tools to process the trace file and collect the parametric for vertical handover.
Extending the Model:
- Multiple Handover Conditions:
- We can program the handover to be caused in terms of signal strength, Quality of Service (QoS) parameters, or other conditions such as congestion or mobility speed.
- Different Network Types:
- We can simulate different kinds of wireless networks for the vertical handover, like WiMAX, 3G/4G, or 5G, by adjusting the network configuration and link properties.
- Performance Evaluation:
- Evaluate the parameters before and after the handover event, like handover latency, packet loss, throughput, and delay. These parameters can help to measure the effectiveness of the handover algorithm or protocol.
- Advanced Protocols:
- Execute certain vertical handover algorithms, like MIPv6 (Mobile IPv6), SIP-based handover, or other network layer handover schemes to relate their performance.
In this presented manual elaborately provide the complete procedures to help you to simulate the vertical handover over the network using the tool of ns2. More information regarding this process is provided in further script.
We kindly request that you share the details of your Vertical Handover Project with us. In return, we will provide tailored simulation support. Our expertise includes mobile nodes and programming relevant to your projects.