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

HOW TO IMPORT SOCKET.H PACKAGES IN NS3

The Socket.h installation steps we use for implementing and debugging network protocols and applications in NS-3 are listed below, contact us for more project details.  The Socket class offers tools for creating, binding, and managing sockets, along with sending and receiving data through network connections. It works with different transport protocols like TCP and UDP and has features for managing asynchronous events and data transfer. This class connects with NS-3’s lower-level network system, allowing developers to simulate and study network communication in detail. Knowing socket.h is crucial for building and troubleshooting network protocols and applications in NS-3, as it is the foundation of socket communication in the simulator.

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 Socket_eg.cc file in the scratch folder:

Next we need to create the Socket_eg.cc file by using text editor in the ns3/scratch folder.

Screenshot:

Create the Socket_eg.cc file in the scratch folder

Next we need to paste the below code to the Socket_eg.cc file and save the file in the ns3/scratch folder.

Code:

Create the Socket_eg.cc file in the scratch folder

Screenshot:

Open the Terminal

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:

NS-3.35 Configuration && Building Process

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:

Importing Socket.h

3.Importing Socket.h:

Here we imported the Socket.h header file in this example program.

Screenshot:

Importing Socket.h

Here we highlighted the code line that GetIpTos() class which is the part of the Socket.h that we will show class file that used in this code via network folder.

Screenshot:

Importing Socket.h

Screenshot:

Importing Socket.h

Here we will show the header file by opening Socket.h file to show the class imported from the Socket.h in the example code.

Screenshot:

Executing the Example Socket Program

6.Executing the Example Socket Program:

Then we need to run the Example Socket program to view output of the program.

Command:      “./waf –run socket_eg”

Screenshot:

Executing the Example Socket Program