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

How To Import PTR.H Packages in NS3

To import PTR.H packages in NS3, follow the instructions below. Contact us if you need help with the installation. The Ptr template class is a smart pointer that helps manage the life of objects created dynamically. It automatically counts references, making sure that objects are deleted when they are not needed anymore. In NS-3, ns3::Ptr makes memory management easier by taking care of ownership and avoiding memory leaks. This header file is essential for NS-3 developers because it allows for safe and efficient management of objects in simulations. Knowing ptr.h is important for effectively using and handling objects in NS-3.

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/src/core/example folder:

Screenshot:

2.Copy the main-ptr.cc file to scratch folder:

Next we need to copy the main-ptr.cc file from core/example folder.to the ns3/scratch folder.

Screenshot:

Next we need to paste the main-ptr.cc file to the ns3/scratch folder.

Screenshot:

Copy the main-ptr.cc file to 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 Ptr.h:

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

Screenshot:

Importing ptr.h

Here we highlighted the code line that GetPointer class which is the part of the Ptr.h that we will show class file that used in this code via core folder.

Screenshot:

Importing ptr.h

Screenshot:

Importing ptr.h

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

Screenshot:

Importing ptr.h

6.Executing the Example Ptr Program:

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

Command:      “./waf –run main-ptr”

Screenshot:

Executing the Example Ptr Program

Here we shown the output of the example ptr module program by using ptr.h.

Screenshot:

Executing the Example Ptr Program