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

How to Implement Physical layer technologies in ns3

To implement the physical layer technologies in ns3 that needs to follow the several steps initially setup the network topology, configure the physical layer parameters and use the proper modules and emulate the preferred physical layer characteristics. The given below is the step by step procedure on how to implement the physical layer technologies in ns3:

Step-by-Step Implementation:

Step 1: Set Up the Simulation Environment

  • Make sure ns3 is installed in the computer.

Step 2: Choose the Physical Layer Technology

  • Physical layer technologies are supported in ns3 tool and their technologies are Wi-Fi, LTE, and WiMAX. Here, we concentrate that Wi-Fi is an instance.

Step 3: Create the Network Topology

  • Generate a basic network topology using ns3. Here given below is a sample script to setup a basic Wi-Fi network with two nodes.

Step 4: Write the Script

  • Here, we provide the complete sample of how to generate and configure the Wi-Fi network in ns3 with physical layer scenarios:

#include “ns3/core-module.h”

#include “ns3/network-module.h”

#include “ns3/internet-module.h”

#include “ns3/wifi-module.h”

#include “ns3/mobility-module.h”

#include “ns3/applications-module.h”

using namespace ns3;

NS_LOG_COMPONENT_DEFINE (“WifiExample”);

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

{

bool verbose = true;

uint32_t nWifi = 2;

CommandLine cmd;

cmd.AddValue (“nWifi”, “Number of wifi STA devices”, nWifi);

cmd.AddValue (“verbose”, “Tell echo applications to log if true”, verbose);

cmd.Parse (argc, argv);

if (verbose)

{

LogComponentEnable (“UdpEchoClientApplication”, LOG_LEVEL_INFO);

LogComponentEnable (“UdpEchoServerApplication”, LOG_LEVEL_INFO);

}

NodeContainer wifiStaNodes;

wifiStaNodes.Create (nWifi);

NodeContainer wifiApNode = wifiStaNodes.Get (0);

YansWifiChannelHelper channel = YansWifiChannelHelper::Default ();

YansWifiPhyHelper phy = YansWifiPhyHelper::Default ();

phy.SetChannel (channel.Create ());

WifiHelper wifi;

wifi.SetRemoteStationManager (“ns3::AarfWifiManager”);

WifiMacHelper mac;

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

mac.SetType (“ns3::StaWifiMac”,

“Ssid”, SsidValue (ssid),

“ActiveProbing”, BooleanValue (false));

NetDeviceContainer staDevices;

staDevices = wifi.Install (phy, mac, wifiStaNodes);

mac.SetType (“ns3::ApWifiMac”,

“Ssid”, SsidValue (ssid));

NetDeviceContainer apDevices;

apDevices = wifi.Install (phy, mac, wifiApNode);

MobilityHelper mobility;

mobility.SetPositionAllocator (“ns3::GridPositionAllocator”,

“MinX”, DoubleValue (0.0),

“MinY”, DoubleValue (0.0),

“DeltaX”, DoubleValue (5.0),

“DeltaY”, DoubleValue (10.0),

“GridWidth”, UintegerValue (3),

“LayoutType”, StringValue (“RowFirst”));

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

mobility.Install (wifiStaNodes);

InternetStackHelper stack;

stack.Install (wifiStaNodes);

Ipv4AddressHelper address;

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

Ipv4InterfaceContainer wifiInterfaces;

wifiInterfaces = address.Assign (staDevices);

address.Assign (apDevices);

UdpEchoServerHelper echoServer (9);

ApplicationContainer serverApps = echoServer.Install (wifiApNode);

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 (wifiStaNodes.Get (1));

clientApps.Start (Seconds (2.0));

clientApps.Stop (Seconds (10.0));

Simulator::Run ();

Simulator::Destroy ();

return 0;

}

Explanation:

  1. Create Nodes:
    • Create two Wi-Fi nodes (one Access Point (AP) and one Station (STA)).
  1. Configure the Physical Layer:
    • Use YansWifiPhyHelper to set up the physical layer parameters.
    • Use YansWifiChannelHelper to configure the wireless channel.
  1. Set Up the Wi-Fi Helper:
    • Configure the Wi-Fi helper with the desired MAC and PHY settings.
    • Use WifiHelper to install the Wi-Fi devices on the nodes.
  1. Install Internet Stack:
    • Install the Internet stack on the nodes.
  1. Assign IP Addresses:
    • Assign IP addresses to the Wi-Fi interfaces.
  1. Create and Configure Applications:
    • Create a UDP Echo server on the AP node.
    • Create a UDP Echo client on the STA node.
  1. Run the Simulation:
    • Run the simulation and destroy it after completion.

Step 5: Compile and Run the Script

  1. Save the script as wifi-example.cc in the scratch directory of your ns-3 installation.
  2. Compile the script using the following commands:

./waf configure

./waf build

./waf –run wifi-example

Step 6: Analyse the Results

After running the simulation, we need to validate the features of the Wi-Fi physical layer. Further we can adjust the script to gather the additional metrics or to configure the various physical layer parameters.

Overall, we had learned how to Implement and run the Physical layer technologies in ns3 using the physical layer characteristics. We will elaborate the additional details on how to implement the Physical layer technologies in other frameworks.

Implementation of Physical layer technologies in ns3 as per your concept are done by us, if you are struggling to do even after reading the above ideas. You can approach us for best programming result.