Xgraph in Ns2
Let’s get to know about the significance of Xgraph in network simulator 2 with the assistance of our research experts.
Step: 1 Install Xgraph and Ns2
Firstly, we have to execute the commands that have been highlighted in the following to install Xgraph and other required packages of Ns2.
sudo apt-get install perl xgraph libxt-dev libx11-dev libxmu-dev
![Installation of Xgraph](https://www.ns2project.com/wp-content/uploads/2023/06/Install-xgraph.png)
To install Ns2.35, we have to download ns-allinone-2.35 package and change the package location to execute the commands that have been highlighted in the following.
cd /home/ns-allinone-2.35/
sudo ./install
![](https://www.ns2project.com/wp-content/uploads/2023/06/Install-ns2-2.png)
Ns2 Code to Execute Xgraph
Here, we have highlighted the sample Ns2 Tcl code to execute the Xgraph based on the author generated trace file.
exec xgraph PDR.tr -t “PDR Graph” -x “No.of.Nodes” -y “PDR” -bg pink &
exec xgraph Delay.tr -t “Delay Graph” -x “No.of.Nodes” -y “Delay” -bg pink &
Run Ns2 Code
To run the Ns2 simulation, we have to acquire the Xgraph based graph results in main file through the execution of below mentioned commands.
cd /home/research/trace_file_in_ns2
sudo ./ns main.tcl
![Running Ns2 Code](https://www.ns2project.com/wp-content/uploads/2023/06/run-ns2-code-1.png)
Finally, we have highlighted the graph result for delay which is based on the number of nodes.
![](https://www.ns2project.com/wp-content/uploads/2023/06/result-graph-for-delay-based-on-number-of-nodes-1024x603.png)
If you are looking for the best assistance based on the appropriate implementation of Xgraph in network simulator 2 then you guys can reach us.