To Import Wifi-Phy.H Packages in Ns3 we have listed the needed steps to be carried out. So if you are looking for best guidance then contact us we will give you best guidance. The WifiPhy class is responsible for sending and receiving Wi-Fi signals. It deals with modulation, coding, and processing of signals. This class has methods to control physical layer settings like frequency, power, and signal strength. It also simulates how the physical environment affects the signal, including noise and interference, which is important for accurately modeling Wi-Fi network performance. The WifiPhy class works with the MAC layer to ensure realistic data transfer and network actions. Knowing about wifi-phy.h is essential for developers and researchers who are simulating Wi-Fi physical layer features in NS-3.
Installation guidance of Wifi-phy.h.
PRE-REQUISITES:
- Fresh installation of Ubuntu 22.04 LTS:
Screenshot:

2.NS-3.35 Installation:
Screenshot:

HEADER FILE VERIFICATION:
- Locate to the ns3/scratch folder:
Screenshot:

2.Create the Wifi-phy_eg.cc file in the scratch folder:
Next we need to create the Wifi-phy_eg.cc file by using text editor in the ns3/scratch folder.
Screenshot:

Next we need to paste the below code to the Wifi-phy_eg.cc file and save the file in the ns3/scratch folder.
Code:
#include “ns3/core-module.h”
#include “ns3/network-module.h”
#include “ns3/mobility-module.h”
#include “ns3/wifi-module.h”
#include “ns3/internet-module.h”
#include “ns3/applications-module.h”
#include “ns3/wifi-phy.h”
using namespace ns3;
NS_LOG_COMPONENT_DEFINE(“WifiSimpleExample”);
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;
wifiApNode.Create(1);
YansWifiChannelHelper channel = YansWifiChannelHelper::Default();
YansWifiPhyHelper phy ;
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::RandomWalk2dMobilityModel”,
“Bounds”, RectangleValue(Rectangle(-50, 50, -50, 50)));
mobility.Install(wifiStaNodes);
mobility.SetMobilityModel(“ns3::ConstantPositionMobilityModel”);
mobility.Install(wifiApNode);
InternetStackHelper stack;
stack.Install(wifiApNode);
stack.Install(wifiStaNodes);
Ipv4AddressHelper address;
address.SetBase(“10.1.3.0”, “255.255.255.0”);
Ipv4InterfaceContainer staInterfaces;
staInterfaces = address.Assign(staDevices);
Ipv4InterfaceContainer apInterfaces;
apInterfaces = address.Assign(apDevices);
UdpEchoServerHelper echoServer(9);
ApplicationContainer serverApps = echoServer.Install(wifiApNode.Get(0));
serverApps.Start(Seconds(1.0));
serverApps.Stop(Seconds(10.0));
UdpEchoClientHelper echoClient(apInterfaces.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(nWifi – 1));
clientApps.Start(Seconds(2.0));
clientApps.Stop(Seconds(10.0));
Ipv4GlobalRoutingHelper::PopulateRoutingTables();
Simulator::Stop(Seconds(10.0));
for (NetDeviceContainer::Iterator it = staDevices.Begin(); it != staDevices.End(); ++it) {
Ptr<NetDevice> device = *it;
Ptr<WifiNetDevice> wifiDevice = DynamicCast<WifiNetDevice>(device);
if (wifiDevice) {
Ptr<WifiPhy> wifiPhy = wifiDevice->GetPhy();
NS_LOG_INFO(“Station WifiPhy Standard: ” << wifiPhy->GetPhyStandard());}}
for (NetDeviceContainer::Iterator it = apDevices.Begin(); it != apDevices.End(); ++it) {
Ptr<NetDevice> device = *it;
Ptr<WifiNetDevice> wifiDevice = DynamicCast<WifiNetDevice>(device);
if (wifiDevice) {
Ptr<WifiPhy> wifiPhy = wifiDevice->GetPhy();
NS_LOG_INFO(“AP WifiPhy Standard: ” << wifiPhy->GetPhyStandard());}}
Simulator::Run();
Simulator::Destroy();
return 0;}
Screenshot:

3.Open the Terminal:
Next, we need to launch the terminal by right clicking the mouse in the ns3 location.
Screenshot:

Screenshot:

4.NS-3.35 Configuration && Building Process:
Next, we need to configure and build the ns3 folder to make the copied files to the scratch need to store in configuration.
Command: “./waf configure && ./waf build”
Screenshot:

Screenshot:

5.Importing Wifi-phy.h:
Here we imported the Wifi-phy.h header file in this example program.
Screenshot:

Here we highlighted the code line that highlighted which is the part of the Wifi-phy.h that we will show class file that used in this code via Wifi folder which represents wifi-module.
Screenshot:

Screenshot:

Here we will show the header file by opening Wifi-phy.h file to show the class imported from the Wifi-phy.h in the example code.
Screenshot:

6.Executing the Example Wifi-phy Program:
Then we need to run the Example Wifi-phy program to view output of the program.
Command: “./waf –run Wifi-phy_eg –vis”
Screenshot:

Here we shown the output of the example Wifi-phy program by using Wifi-phy.h.
Screenshot:

Screenshot:

Screenshot:
