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

HOW TO IMPORT INTERNET STACK HELPER.H PACKAGES IN .NS3

To import INTERNET-STACK-HELPER.H packages in NS3 we will explain about the Internet-stack-helper.h is a header file in the NS-3 network simulator that defines the ns3. IF you want to get hazel free services then reach out for our developers. The InternetStackHelper class helps set up and configure the Internet stack on network nodes. It offers methods to add and configure essential Internet protocols like IPv4, IPv6, TCP, UDP, and more. This class makes it easier to establish network stacks by managing protocol setup, parameter settings, and connections with network devices. Knowing about internet-stack-helper.h is important for researchers and developers dealing with Internet protocols and network simulations in NS-3.

Installation stesp of Internet-stack-helper.h.

PRE-REQUISITES:

  1. Fresh installation of Ubuntu 22.04 LTS:

Screenshot:

Fresh installation of Ubuntu 22_04 LTS

2.NS-3.35 Installation:

Screenshot:

NS-3.35 Installation

HEADER FILE VERIFICATION:

  1. Locate to the ns3/scratch folder:

Screenshot:

Locate to the ns3-scratch folder

2.Create the Internet-stack-helper_eg.cc file in the scratch folder:

Next we need to create the Internet-stack-helper_eg.cc file by using text editor in the ns3/scratch folder.

Screenshot:

Create the Internet-stack-helper_eg.cc file in the scratch folder

Next we need to paste the below code to the Internet-stack-helper_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/internet-module.h”

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

#include “ns3/applications-module.h”

#include “ns3/internet-stack-helper.h”

using namespace ns3;

NS_LOG_COMPONENT_DEFINE (“InternetStackExample”);

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

{

  CommandLine cmd;

  cmd.Parse (argc, argv);

  NodeContainer nodes;

  nodes.Create (2);

  InternetStackHelper internet;

  internet.Install (nodes);

  PointToPointHelper pointToPoint;

  pointToPoint.SetDeviceAttribute (“DataRate”, StringValue (“5Mbps”));

  pointToPoint.SetChannelAttribute (“Delay”, StringValue (“2ms”));

  NetDeviceContainer devices;

  devices = pointToPoint.Install (nodes);

  Ipv4AddressHelper address;

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

  Ipv4InterfaceContainer interfaces;

  interfaces = address.Assign (devices);

  uint16_t port = 9; 

  Address serverAddress (InetSocketAddress (Ipv4Address::GetAny (), port));

  PacketSinkHelper packetSinkHelper (“ns3::TcpSocketFactory”, serverAddress);

  ApplicationContainer serverApps = packetSinkHelper.Install (nodes.Get (1));

  serverApps.Start (Seconds (1.0));

  serverApps.Stop (Seconds (10.0));

  Address clientAddress (InetSocketAddress (interfaces.GetAddress (1), port));

  OnOffHelper onOffHelper (“ns3::TcpSocketFactory”, clientAddress);

  onOffHelper.SetAttribute (“OnTime”, StringValue (“ns3::ConstantRandomVariable[Constant=1]”));

  onOffHelper.SetAttribute (“OffTime”, StringValue (“ns3::ConstantRandomVariable[Constant=0]”));

  onOffHelper.SetAttribute (“DataRate”, DataRateValue (DataRate (“50Kbps”)));

  onOffHelper.SetAttribute (“PacketSize”, UintegerValue (2000));

  ApplicationContainer clientApps = onOffHelper.Install (nodes.Get (0));

  clientApps.Start (Seconds (2.0));

  clientApps.Stop (Seconds (10.0));

  pointToPoint.EnablePcapAll (“internet-stack-example”);

  Simulator::Run ();

  Simulator::Destroy ();

  return 0;

}

Screenshot:

Create the Internet-stack-helper_eg.cc file in the scratch folder

3.Open the Terminal:

Next, we need to launch the terminal by right clicking the mouse in the ns3 location.

Screenshot:

Open the Terminal

Screenshot:

Open the Terminal

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:

NS-3.35 Configuration && Building Process

Screenshot:

NS-3.35 Configuration && Building Process

5.Importing Internet-stack-helper.h:

Here we imported the Internet-stack-helper.h header file in this example program.

Screenshot:

Importing Internet-stack-helper.h

Here we highlighted the code line that highlighted which is the part of the Internet-stack-helper.h that we will show class file that used in this code via Internet folder which represents Internet-module.

Screenshot:

Importing Internet-stack-helper.h

Screenshot:

Importing Internet-stack-helper.h

Here we will show the header file by opening Internet-stack-helper.h file to show the class imported from the Internet-stack-helper.h in the example code.

Screenshot:

Importing Internet-stack-helper.h

6.Executing the Example Internet-stack-helper Program:

Then we need to run the Example Internet-stack-helper program to view output of the program.

Command:      “./waf –run Internet-stack-helper_eg –vis”

Screenshot:

Executing the Example Internet-stack-helper Program

Here we shown the output of the example Internet-stack-helper program by using Internet-stack-helper.h.

Screenshot:

Executing the Example Internet-stack-helper Program
Screenshot:

Screenshot:

Executing the Example Internet-stack-helper Program