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:
- Fresh installation of Ubuntu 22.04 LTS:
Screenshot:

2.NS-3.35 Installation:
Screenshot:

HEADER FILE VERIFICATION:
- 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:

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 Ptr.h:
Here we imported the ptr.h header file in this example program.
Screenshot:

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:

Screenshot:

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:

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:

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