Ns3 Projects for B.E/B.Tech M.E/M.Tech PhD Scholars.  Phone-Number:9790238391   E-mail: ns3simulation@gmail.com

How To Implement Vertical Handover in NS3

To implement the vertical handover in ns-3 offers the modules for numerous network types, which can be integrated to simulate such environment.

Here are the step by step procedures to implement the vertical handover in ns-3:

Step-by-Step Guide to Implement Vertical Handover in ns-3

  1. Install ns-3:
    • Ensure ns-3 is installed as per the instructions provided in the previous responses.
  2. Create a Simulation Script:
    • Create a new script file, e.g., vertical-handover.cc.
  3. Include Necessary Headers:

#include “ns3/core-module.h”

#include “ns3/network-module.h”

#include “ns3/internet-module.h”

#include “ns3/point-to-point-module.h”

#include “ns3/mobility-module.h”

#include “ns3/wifi-module.h”

#include “ns3/lte-module.h”

#include “ns3/applications-module.h”

  1. Define the Main Function:

using namespace ns3;

int main (int argc, char *argv[])

{

  LogComponentEnable (“UdpEchoClientApplication”, LOG_LEVEL_INFO);

  LogComponentEnable (“UdpEchoServerApplication”, LOG_LEVEL_INFO);

  1. Set Up the Network Topology:
  • Create nodes for Wi-Fi, LTE, and the mobile user:

NodeContainer wifiNodes;

wifiNodes.Create (1);

NodeContainer lteNodes;

lteNodes.Create (1);

NodeContainer ueNodes;

ueNodes.Create (1);

  1. Configure Wi-Fi:

WifiHelper wifi;

wifi.SetStandard (WIFI_PHY_STANDARD_80211ac);

YansWifiChannelHelper wifiChannel = YansWifiChannelHelper::Default ();

YansWifiPhyHelper wifiPhy = YansWifiPhyHelper::Default ();

wifiPhy.SetChannel (wifiChannel.Create ());

WifiMacHelper wifiMac;

Ssid ssid = Ssid (“ns-3-ssid”);

wifiMac.SetType (“ns3::StaWifiMac”, “Ssid”, SsidValue (ssid), “ActiveProbing”, BooleanValue (false));

 

NetDeviceContainer wifiDevices;

wifiDevices = wifi.Install (wifiPhy, wifiMac, ueNodes);

wifiMac.SetType (“ns3::ApWifiMac”, “Ssid”, SsidValue (ssid));

NetDeviceContainer apDevices;

apDevices = wifi.Install (wifiPhy, wifiMac, wifiNodes);

  1. Configure LTE:

Ptr<LteHelper> lteHelper = CreateObject<LteHelper> ();

Ptr<PointToPointEpcHelper> epcHelper = CreateObject<PointToPointEpcHelper> ();

lteHelper->SetEpcHelper (epcHelper);

Ptr<Node> pgw = epcHelper->GetPgwNode ();

NodeContainer enbNodes;

enbNodes.Create (1);

NetDeviceContainer enbLteDevices = lteHelper->InstallEnbDevice (enbNodes);

NetDeviceContainer ueLteDevices = lteHelper->InstallUeDevice (ueNodes);

InternetStackHelper internet;

internet.Install (ueNodes);

Ipv4InterfaceContainer ueIpIface;

ueIpIface = epcHelper->AssignUeIpv4Address (NetDeviceContainer (ueLteDevices));

lteHelper->Attach (ueLteDevices, enbLteDevices.Get (0));

  1. Configure IP stack and mobility:

InternetStackHelper stack;

stack.Install (wifiNodes);

stack.Install (lteNodes);

MobilityHelper mobility;

mobility.SetMobilityModel (“ns3::ConstantPositionMobilityModel”);

mobility.Install (wifiNodes);

mobility.Install (lteNodes);

mobility.Install (ueNodes);

Ipv4AddressHelper address;

address.SetBase (“10.1.1.0”, “255.255.255.0”);

Ipv4InterfaceContainer wifiInterfaces;

wifiInterfaces = address.Assign (apDevices);

  1. Install Applications:
  • Set up a UDP echo server on the Wi-Fi AP and the LTE eNodeB:

UdpEchoServerHelper echoServer (9);

ApplicationContainer serverApps = echoServer.Install (wifiNodes.Get (0));

serverApps.Start (Seconds (1.0));

serverApps.Stop (Seconds (10.0));

serverApps = echoServer.Install (lteNodes.Get (0));

serverApps.Start (Seconds (1.0));

serverApps.Stop (Seconds (10.0));

  1. Set up a UDP echo client on the UE:

UdpEchoClientHelper echoClient (wifiInterfaces.GetAddress (0), 9);

echoClient.SetAttribute (“MaxPackets”, UintegerValue (1));

echoClient.SetAttribute (“Interval”, TimeValue (Seconds (1.0)));

echoClient.SetAttribute (“PacketSize”, UintegerValue (1024));

ApplicationContainer clientApps = echoClient.Install (ueNodes.Get (0));

clientApps.Start (Seconds (2.0));

clientApps.Stop (Seconds (10.0));

  1. Implement Vertical Handover Logic:
  • The handover can be managed by monitoring signal strength or other parameters and switching interfaces accordingly. Here is a basic implementation using a handover event:

Simulator::Schedule (Seconds (5.0), &LteHelper::HandoverRequest, lteHelper, ueLteDevices.Get (0), enbLteDevices.Get (0), enbLteDevices.Get (1));

Simulator::Run ();

Simulator::Destroy ();

return 0;

Example Complete Script (vertical-handover.cc):

Here is the sample script to complete the vertical handover simulation process in ns-3 environment.

#include “ns3/core-module.h”

#include “ns3/network-module.h”

#include “ns3/internet-module.h”

#include “ns3/point-to-point-module.h”

#include “ns3/mobility-module.h”

#include “ns3/wifi-module.h”

#include “ns3/lte-module.h”

#include “ns3/applications-module.h”

using namespace ns3;

int main (int argc, char *argv[])

{

  LogComponentEnable (“UdpEchoClientApplication”, LOG_LEVEL_INFO);

  LogComponentEnable (“UdpEchoServerApplication”, LOG_LEVEL_INFO);

  NodeContainer wifiNodes;

  wifiNodes.Create (1);

  NodeContainer lteNodes;

  lteNodes.Create (1);

  NodeContainer ueNodes;

  ueNodes.Create (1);

  // Configure Wi-Fi

  WifiHelper wifi;

  wifi.SetStandard (WIFI_PHY_STANDARD_80211ac);

  YansWifiChannelHelper wifiChannel = YansWifiChannelHelper::Default ();

  YansWifiPhyHelper wifiPhy = YansWifiPhyHelper::Default ();

  wifiPhy.SetChannel (wifiChannel.Create ());

 

  WifiMacHelper wifiMac;

  Ssid ssid = Ssid (“ns-3-ssid”);

  wifiMac.SetType (“ns3::StaWifiMac”, “Ssid”, SsidValue (ssid), “ActiveProbing”, BooleanValue (false));

  NetDeviceContainer wifiDevices;

  wifiDevices = wifi.Install (wifiPhy, wifiMac, ueNodes);

  wifiMac.SetType (“ns3::ApWifiMac”, “Ssid”, SsidValue (ssid));

  NetDeviceContainer apDevices;

  apDevices = wifi.Install (wifiPhy, wifiMac, wifiNodes);

  // Configure LTE

  Ptr<LteHelper> lteHelper = CreateObject<LteHelper> ();

  Ptr<PointToPointEpcHelper> epcHelper = CreateObject<PointToPointEpcHelper> ();

  lteHelper->SetEpcHelper (epcHelper);

  Ptr<Node> pgw = epcHelper->GetPgwNode ();

  NodeContainer enbNodes;

  enbNodes.Create (1);

  NetDeviceContainer enbLteDevices = lteHelper->InstallEnbDevice (enbNodes);

  NetDeviceContainer ueLteDevices = lteHelper->InstallUeDevice (ueNodes);

  InternetStackHelper internet;

  internet.Install (ueNodes);

 

  Ipv4InterfaceContainer ueIpIface;

  ueIpIface = epcHelper->AssignUeIpv4Address (NetDeviceContainer (ueLteDevices));

  lteHelper->Attach (ueLteDevices, enbLteDevices.Get (0));

  // Configure IP stack and mobility

  InternetStackHelper stack;

  stack.Install (wifiNodes);

  stack.Install (lteNodes);

  MobilityHelper mobility;

  mobility.SetMobilityModel (“ns3::ConstantPositionMobilityModel”);

  mobility.Install (wifiNodes);

  mobility.Install (lteNodes);

  mobility.Install (ueNodes);

  Ipv4AddressHelper address;

  address.SetBase (“10.1.1.0”, “255.255.255.0”);

  Ipv4InterfaceContainer wifiInterfaces;

  wifiInterfaces = address.Assign (apDevices);

  // Install Applications

  UdpEchoServerHelper echoServer (9);

  ApplicationContainer serverApps = echoServer.Install (wifiNodes.Get (0));

  serverApps.Start (Seconds (1.0));

  serverApps.Stop (Seconds (10.0));

  serverApps = echoServer.Install (lteNodes.Get (0));

  serverApps.Start (Seconds (1.0));

  serverApps.Stop (Seconds (10.0));

  UdpEchoClientHelper echoClient (wifiInterfaces.GetAddress (0), 9);

  echoClient.SetAttribute (“MaxPackets”, UintegerValue (1));

  echoClient.SetAttribute (“Interval”, TimeValue (Seconds (1.0)));

  echoClient.SetAttribute (“PacketSize”, UintegerValue (1024));

  ApplicationContainer clientApps = echoClient.Install (ueNodes.Get (0));

  clientApps.Start (Seconds (2.0));

  clientApps.Stop (Seconds (10.0));

  // Implement Vertical Handover

  Simulator::Schedule (Seconds (5.0), &LteHelper::HandoverRequest, lteHelper, ueLteDevices.Get (0), enbLteDevices.Get (0), enbLteDevices.Get (1));

  Simulator::Run ();

  Simulator::Destroy ();

  return 0;

}

Explanation:

The given below are the process for vertical handover explanations,

  1. Network Configuration:
    • Nodes are created for Wi-Fi, LTE, and the mobile user (UE).
    • Wi-Fi and LTE networks are configured with necessary devices and IP addresses.
    • Mobility is set for all nodes using the Constant Position Mobility Model.
  1. Applications:
    • UDP echo server applications are installed on the Wi-Fi AP and LTE eNodeB.
    • A UDP echo client application is installed on the UE.
  2. Vertical Handover:
    • A handover event is scheduled at 5 seconds using the Simulator::Schedule function, which triggers the handover from the initial LTE eNodeB to another.

Here we have discussed about the vertical handover implementation process in ns-3 environment and also we provide and support all kinds of handover works.