How to Install Xgraph in Ns2

               Generally, the research scholars are searching for the appropriate article that includes all the fundamental steps based on the answers for the question “how to install Xgraph in Ns2”. Thus, we have provided the required data about the installation steps of Xgraph in Ns2. Let’s start this article with the keynotes about Ns2 and Xgraph in the following.

What is Xgraph?

            Xgraph includes the wide ranging functions through the x-y data plotter along with the interactive buttons that are used for various processes such as selecting, printing, zooming and panning display options. It is capable to plot the data from several numbers of files in that same graph and it is used to regulate the size of unlimited data set sizes with the number of data files.

What is Ns2?

             Ns2 is considered as the well reputed and discrete event network simulator that is developed over various previous research activities and grants. It is about the active utilizations that are continued and will be maintained. OTcl is deployed in Ns2 as the scripting environment and various other Ns2 models are written using C++.

             Hereby, our research professionals have highlighted the installation step about Xgraph in Ns2 in the following.

Xgraph Install Steps

             The process of Xgraph installation includes some required steps to precede the installation process and our research professionals have enlisted the installation steps for your reference.

$] sudo apt update
$] sudo apt install build-essential autoconf automake libxmu-dev
$] sudo apt install gcc-4.8 g++-4.8

           While installing Ns2 in Ubuntu, Ns2 is using gcc-4.8 as C compiler and g++-4.8 as C++ compiler. In general, the software based on Ns2 and Xgraph are being contented with the version namely 4.8. Thus, the users have to make some alterations in the setting based on Mainly, we have to change the three locations such as.

  • xgraph-12.2/
  • ns-2.35/
  • nam-1.15/

The above mentioned three files have to be altered as per the following files.

  • @CC@ –> gcc-4.8
  • @CPP@ –> g++-4.8
  • ns-2.35/linkstate/ls.h. in the line nuber 137, change erase to this->erase, Set the PATH and LD_LIBRARY_PATH in /home/networks/.bashrc file

           Consequently, command is deployed in this process of terminal window and the command is highlighted below.


sudo apt-get install Xgraph

           For your quick reference, our technical experts have highlighted the developments and progressions of annotations in Xgraph in the following along with some references such as.

Annotations in Xgraph

          The users can place the textual annotations directly towards the graphs mainly it is deployed to recognize the curves based on this process. It is the simple place in that the annotation file. The keyword “ANNOtation” is used to start the annotation line, here in this keyword the caps are essential and smalls are optional. It is followed through both the X-Y coordinates in which the annotation text is appeared in the graph and all the process are followed through the annotation text up to the end of the line.

  • Form
  • annotation <X>  <Y>  <text>
  • Example
  • anno 2  78.0   Second Experiment Results

        Through this given highlights, the X-Y coordinate data are functioning in the same coordinate system as per the data.

         Now, let’s get to know about the replacements in the Xgraph particularly in the vertical axis labels based on Xgraph. In addition, the vertical axis is denoted as x axis.

Replacing Vertical Axis Labels in Xgraph

  • Command syntax
  • replace_y_axis <value> <string>
  • Example
  • replace_y_axis 2  VME_bus
  • Action
  • “VME_bus” is the word that is appeared in the vertical position which is corresponding towards the 101.2 towards the left of y axis in which the numbers are appeared

            Following that we have highlighted the replacements in the Xgraph based on horizontal axis. When the x axis is vertical obviously the y axis is horizontal.

Replacing Horizontal Axis Labels in Xgraph

  • Command syntax
  • replace_x_axis <value> <string>
  • Example
  • replace_x_axis 11  /device_11
  • Action
  • “/device_11” is the word that may appear in the horizontal position that is corresponding to 11 and that is under the x-axis in which the x-axis numbers are appearing

API Command in Xgraph

           The command line interface based on Xgraph is denoted as the acceleration of building and running the Xgraph system. The users are capable to generate novel and innovative modules and systems, run the system from a system cache and compile systems from a system structure object through the utilization of Xgraph CLI. Several API command are used in Xgraph, here we have enlisted the list of commands that are functional in Xgraph CLI with the assistance of Xgraph.

  • xgraph generate module MyFirstModule
  • Create the novel module that is denoted as MyfirstModule
  • xgraph reset –cwd ./MultipleSystemsTemplate/Systems/Plexus/ –xGraph ../xGraph
  • It is deployed to reset the system in various working directory along with the external source
  • xgraph deploy –config ./ExampleSystems/HelloWorld/config.json
  • It is used to module the system structure file
  • xgraph compile
  • The system is compiled with the current directory
  • generate <module|system> g <m|s>
  • It is used to generate novel module and system through the template through the given name
  • execute x
  • The system is functioning through cache and compile and run the system when the cache does not exist
  • reset r
  • It is deployed to run a system structure file through resetting the cache of system
  • deploy d
  • It is used to run the system from cache
  • compile c
  • It creates cache from the system such as
  • Structure file (config.json)
  • help h
  • It is used to display the help screen

Sample Xgraph File and Its Contents

           The Xgraph is deployed to plot the characteristics based on Ns2 parameters such as packets information, end to end delay, throughput and etc. The successful installation of Ns2 is installing the Xgraph and the functions through the shell prompt: # xgraph filename.xg in the TCL scripts and the Xgraph is written based on the below mentioned process.

  • exec xgraph filename.xg -geometry 500×500
  • exec xgraph filename1.xg -geometry 500×500 &
  • exec xgraph filename2.xg -geometry 500×500 &

         The ambersand is considered as the requested popup in which all the graph windows and the absence of Xgraph window lead to popup the Xgraph.

Sample Xgraph File

         The files based on Xgraph depicts the data based on overhead size of the network and the overhead is compared with the four significant routing protocols such as

  • DSDV
  • DSR
  • AODV

           The above mentioned are considered as the own proposed algorithms and the values for these algorithms are collected from various trace files. The implementation of Xgraph file includes to copy the content and save the “example.xg” file and it is in the shell prompt.

# xgraph example.xg
TitleText: Overhead (Kbits/s) Vs Network Size
YUnitText: OverHead
XUnitText: Network Size (nodes)
200 100
400 350
600 800
800 1200
200 500
400 1600
600 2300
800 3700
200 100
400 320
600 400
800 600
200 500
400 3700
600 6400
800 11600

Generate Xgraph for Throughput in Ns2 Simulator

            The wireless network with the communication model is established through the utilization of TCL scripts. The TCL scripts based implementations are used to generate the trace file along with some simulation events that are recorded within it. The AXK script is used to calculate the throughput of process based on trace file and produce the result in file with the .xg extension. Throughput for Xgraph is plotted through the results that are acquired through the implementation of AWK script.

#Fixing the co-ordinate of simulation area
set val(x) 500
set val(y) 500
# set up topography object
set topo [new Topography]
$topo load_flatgrid $val(x) $val(y)
#Nam File Creation nam – network animator
set namfile [open sample33.nam w]
#Tracing all the events and cofiguration
$ns namtrace-all-wireless $namfile $val(x)
#Trace File creation
set tracefile [open w]
# ending nam and the simulation
$ns at $val(stop) "$ns nam-end-wireless
$ns at $val(stop) "stop"
#Stopping the scheduler
$ns at 10.01 "puts \"end simulation\" ; $ns halt"
#$ns at 10.01 "$ns halt"
exec awk -f Throughput.awk > Throughput.xg &
exit 0
exec xgraph -geometry 500X500 -P -bg
white -t THROUGHPUT -x time(s) -y throughput(Mbits/s) Throughput.xg & #Starting scheduler
$ns run

             Our research team updates their knowledge to produce the finest installation process in Xgraph. In fact, we have 20+ years of experience in this research field. In this period of time, we accomplished enormous research requirements in this field. Consequently, we have 5000+ happy customers all over the world. Therefore, we are able to provide 100% worth and plagiarism free research work for the research scholars. So, ping us to develop your research in an innovative way.