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

How to Implement Blockage mitigation in ns3

To implement blockage mitigation in ns3, we need to follow several steps. In mmWave networks blockage plays a significant role which impact the performance of the network like, modeling the environment, detecting blockages, and implementing strategies to mitigate their effects. The following steps will guide on how to implement Blockage mitigation in ns3 environment:

Step 1: Set Up the Simulation Environment

Make sure ns3 is installed on the system along with the mmWave module

Step 2: Create the Network Topology

We need to create a basic network topology using ns3 with multiple nodes to simulate a mmWave communication scenario.

Step 3: Write the Script

An example given on how to create and configure a network topology in ns3 with blockage mitigation:

  1. Create a New File:
    • Save the following script as blockage-mitigation.cc in the scratch directory of ns3 installation.

#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/applications-module.h”

#include “ns3/mmwave-helper.h”

#include “ns3/mmwave-module.h”

#include “ns3/flow-monitor-helper.h”

#include “ns3/propagation-module.h”

using namespace ns3;

NS_LOG_COMPONENT_DEFINE (“BlockageMitigationExample”);

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

{

CommandLine cmd;

cmd.Parse (argc, argv);

// Create nodes

NodeContainer ueNodes;

ueNodes.Create (1);

NodeContainer enbNodes;

enbNodes.Create (1);

NodeContainer blockerNodes;

blockerNodes.Create (1);

// Set up mmWave channel with blockage model

Ptr<BuildingsPropagationLossModel>lossModel = CreateObject<BuildingsPropagationLossModel> ();

Ptr<BuildingsObstaclePropagationLossModel>blockageModel = CreateObject<BuildingsObstaclePropagationLossModel> ();

lossModel->SetNext (blockageModel);

Ptr<ChannelConditionModel>conditionModel = CreateObject<BuildingsChannelConditionModel> ();

Ptr<ThreeGppChannel> channel = CreateObject<ThreeGppChannel> ();

channel->SetPropagationLossModel (lossModel);

channel->SetChannelConditionModel (conditionModel);

mmWaveHelper mmwaveHelper;

mmwaveHelper.SetChannel (channel);

NetDeviceContainer enbDevices = mmwaveHelper.InstallEnbDevice (enbNodes);

NetDeviceContainer ueDevices = mmwaveHelper.InstallUeDevice (ueNodes);

// Install the Internet stack on the nodes

InternetStackHelper stack;

stack.Install (ueNodes);

stack.Install (enbNodes);

// Assign IP addresses to the devices

Ipv4AddressHelper address;

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

Ipv4InterfaceContainer ueInterfaces = address.Assign (ueDevices);

Ipv4InterfaceContainer enbInterfaces = address.Assign (enbDevices);

// Set up mobility model

MobilityHelper mobility;

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

mobility.Install (ueNodes);

mobility.Install (enbNodes);

mobility.Install (blockerNodes);

 

ueNodes.Get (0)->GetObject<MobilityModel> ()->SetPosition (Vector (0.0, 0.0, 0.0));

enbNodes.Get (0)->GetObject<MobilityModel> ()->SetPosition (Vector (100.0, 0.0, 10.0));

blockerNodes.Get (0)->GetObject<MobilityModel> ()->SetPosition (Vector (50.0, 0.0, 5.0));

// Set up applications

uint16_t port = 12345;

UdpServerHelper server (port);

ApplicationContainer serverApp = server.Install (ueNodes.Get (0));

serverApp.Start (Seconds (1.0));

serverApp.Stop (Seconds (10.0));

UdpClientHelper client (ueInterfaces.GetAddress (0), port);

client.SetAttribute (“MaxPackets”, UintegerValue (100));

client.SetAttribute (“Interval”, TimeValue (MilliSeconds (100)));

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

ApplicationContainer clientApp = client.Install (enbNodes.Get (0));

clientApp.Start (Seconds (2.0));

clientApp.Stop (Seconds (10.0));

// Simulate blockage mitigation

Simulator::Schedule (Seconds (3.0), [&]() {

NS_LOG_UNCOND (“Blocker is causing signal degradation”);

// Move blocker to simulate blockage

blockerNodes.Get (0)->GetObject<MobilityModel> ()->SetPosition (Vector (50.0, 0.0, 5.0));

});

 

Simulator::Schedule (Seconds (6.0), [&]() {

NS_LOG_UNCOND (“Blocker is removed”);

// Remove blocker to simulate mitigation

blockerNodes.Get (0)->GetObject<MobilityModel> ()->SetPosition (Vector (150.0, 0.0, 5.0));

});

// Enable Flow Monitor

FlowMonitorHelper flowmon;

Ptr<FlowMonitor> monitor = flowmon.InstallAll ();

// Run simulation

Simulator::Stop (Seconds (10.0));

Simulator::Run ();

// Print statistics

monitor->CheckForLostPackets ();

Ptr<Ipv4FlowClassifier>classifier=DynamicCast<Ipv4FlowClassifier> (flowmon.GetClassifier ());

std::map<FlowId, FlowMonitor::FlowStats> stats = monitor->GetFlowStats ();

for (std::map<FlowId, FlowMonitor::FlowStats>::const_iterator i = stats.begin (); i != stats.end (); ++i)

{

Ipv4FlowClassifier::FiveTuple t = classifier->FindFlow (i->first);

std::cout << “Flow ID: ” << i->first << ” Src Addr ” << t.sourceAddress << ” Dst Addr ” << t.destinationAddress << std::endl;

std::cout << “Tx Packets = ” << i->second.txPackets << std::endl;

std::cout << “Rx Packets = ” << i->second.rxPackets << std::endl;

std::cout << “Throughput: ” << i->second.rxBytes * 8.0 / (i->second.timeLastRxPacket.GetSeconds () – i->second.timeFirstTxPacket.GetSeconds ()) / 1024 / 1024 << ” Mbps” << std::endl;

std::cout << “Delay: ” << i->second.delaySum.GetSeconds() / i->second.rxPackets << ” s” << std::endl;

std::cout << “Packet Loss Ratio: ” << (i->second.txPackets – i->second.rxPackets) / static_cast<double>(i->second.txPackets) << std::endl;

}

Simulator::Destroy ();

return 0;

}

Explanation:

  1. Create Nodes:
    • We need to create one UE node, one eNodeB node, and one blocker node.
  2. Set Up mmWave Channel with Blockage Model:
    • Use theBuildingsPropagationLossModel and BuildingsObstaclePropagationLossModel to simulate blockage effects.
    • Set up the channel condition model.
  3. Install the Internet Stack:
    • Install the Internet stack on both the UE and eNodeB nodes.
  4. Assign IP Addresses:
    • Assign IP addresses to the devices using Ipv4AddressHelper.
  5. Set Up Mobility Models:
    • Use the ConstantPositionMobilityModel to set fixed positions for the UE and eNodeB nodes.
    • To simulate blockage, position the blocker node.
  6. Set Up Applications:
    • To generate traffic, we need to set up a UDP server on the UE and a UDP client on the eNodeB.
  7. Simulate Blockage and Mitigation:
    • To simulate blockage and its mitigation, schedule events to move the blocker into and out of the signal path
  8. Enable Flow Monitor:
    • Install Flow Monitor to collect performance metrics.
  9. Run Simulation:
    • Run the simulation and print the collected statistics.

Step 4: Compile and Run the Script

  1. Save the script as blockage-mitigation.cc in the scratch directory of your ns3 installation.
  2. Compile the script using the following commands:

./waf configure

./waf build

./waf –run blockage-mitigation

Step 5: Analyze the Results

After running the simulation, you can analyze the results by looking at the logs and any generated output files to verify the behavior of the blockage mitigation.

On conclusion, we all get to know that for implementing blockage mitigation especially in mmWave, which also involves modelling, detecting, and providing strategies for mitigation to implement it in ns3.

We can assist you with the implementation of Blockage mitigation in ns3 for your projects through our website ns3simulation.com. Please provide us with your details and we will promptly guide you through the process.