Friday, 20 February 2015

Use Xgraph for Plotting Graphs in NS2

Xgraph is an X-Windows application that includes:

  • interactive plotting and graphing
  • animation and deritives
  • portability and bug fixes
To run xgraph you need to enter the following command in your terminal

$ xgraph [filename].xg

The following example shows the comparison between three protocols for temperature vs time. 

The three protocol that I have used is AODV, DSDV and LEACH.

Open a text editor and save the following values with a name, let’s say temperature.xg

Now run the command xgraph temperature.xg

TitleText: Temperature Vs Time
YUnitText: Temperature
XUnitText: Time
"LEACH"
0.101696 28.785601
0.111696 26.269455
0.121696 14.959191
0.131696 25.293587
0.141696 30.931101
0.151696 24.457528
0.161696 18.711203
0.177869 24.049889
0.187869 30.155190
0.197869 23.436181
0.207869 14.882664

"AODV"
0.105162 20.642021
0.115162 9.209109
0.125162 24.508792
0.135162 25.728884
0.147681 31.114854
0.157681 26.044112
0.177268 24.369410
0.187268 22.886387
0.197268 24.093065
0.207268 24.930244

"DSDV"
0.109013 23.600860
0.119013 21.985642
0.138179 25.826512
0.148179 25.370684
0.158179 28.402469
0.168179 24.851947
0.178179 30.817568
0.188179 34.148164
0.198179 27.616187
0.208179 29.777069

After you execute the command, your output window will be this


Share your experience with us, Any queries please comment below

1 comment: