xgraph utility in Network Simulator 2

Xgraph is an X-Windows application that includes:

  • interactive plotting and graphing
  • animation and deritives
  • portability and bug fixes

So to plot the characteristics of NS2 parameters like throughput, end to end delay, packets information, etc can be plotted using xgraph
The successful installation of NS2 will install xgraph also along with it.
To run xgraph from a shell prompt: # xgraph filename.xg

inside TCL scripts, xgraph can be written like this
exec xgraph filename.xg -geometry 500×500
if there are more xgraph files then,
exec xgraph filename1.xg -geometry 500×500 &
exec xgraph filename2.xg -geometry 500×500 &
The ambersand is mandatory to popup all the graph windows, if & (ambersand) is not there, then only the last xgraph window will be popped up.

Sample xgraph file and its contents
/*** The xgraph file shows the information about the overhead with size of the network,
 Overhead is compared with four routing protocols like AODV, DSR, DSDV and NEAODV (my own algorithm)
the values are taken from various trace files.
To execute the following xgraph file, copy the following contents and save it as “example.xg” possibly (other formats also supported) and 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
Output window will be looking like this


Published by


I am a professor cum blogger loves to blog on recent technologies, trends, articles on Personal productivity, How to's, blogging, lecture notes, video lectures,etc on topics related to Open source technologies, Embedded Systems, Linux, etc.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s