X-graph in NS2

Xgraph Generation

Xgraph is easy and very Useful.

Xgraph
  •  Xgraph draws a graph on a Display device.
  • Display upto 64 Independent data sets using  different colors
  • The input data can be read from either data file or from standard input if no files are specified
  • It annotates the graph with a title, axis labels grid lines or tick marks, grid labels, and  legend.
Windows Interface
  • The interface used to specify the size and location of this window depends on the window manager currently in use.
  • Once the window has been opened, all of the data sets will be displayed graphically with a legend in the upper right corner of the screen.
  • Xgraph also presents three control buttons in the upper left corner of each window.
Xgraph command options       
  • -geometry WxH (Geometry)
  •  Specifies the initial size and location of the Xgraphwindow.
  •  -bar (BarGraph) Specifies that vertical bars should be drawn from the data points to a base point which can be specified with -brb.
  •  -brb <base> (BarBase) 
  •  This specifies the base for a bar graph. By default, the base is zero.
  • -brw <width> (BarWidth)
  •  This specifies the width of bars in a bar graph. The amount is specified in the user’s units. By default, a bar one pixel wide is drawn.
Xgraph Command 
  • xgraph DataFile.txt –geometry 400x400,  Here DataFile.txt can be Replaced with trace file generated from NS2.this command will show the graph using X and Y co-ordinates with Geometry of 400X400
  • xgraph DataFile.txt –geometry 400x400 –bar –brb 2 –brw 0.5 –tk –bb –nl –bg white –t “Example_Xgraph” –x “Xaxis” –y “Yaxis” . This command will generate Bar Graph.
  • Xgraph DataFile.txt DataFile2.txt –bg white –tk –bb –m -M –t “Marker” –geometry  800x400.This command used to compare the two Files and generated graph
Awk and Xgraph
  • Awk programming is used to generate the detailed analysis of NS2 trace file.
  • Metric's like Throughput,end-to-end Delay,Jitter,NRL,Packet Delivery ratio can be calculated using Awk scripts. Generate output's  by changing scenario files.
  • Keep these outputs in a Text file in the Form of X and Y co-ordinates .for example, you can keep No_of _mobile nodes on X-axis and PDF on Y-axis. 
Xgraph of  Trace files(Two) 
  • Xgraph can generated using Two files .This graph will show the comparison of two files with different data 
  • command :Xgraph DataFile.txt DataFile2.txt –bg white –tk –bb –m -M –t “Marker” –geometry  800x400
  • Like wise One can compare two Routing Protocols and evaluate the best among them. For example comparison of AODV performance with DSDV in MANET. 
Sample Xgraph Generation ---->Node size vs PDR 

  • Create a text file named  PDRvsNODE.txt and keep the data as like the below format .First column represent node size, (5 ,10,20,30,40,50) and 2 nd column specifies pdr that you got after running pdr.awk scipt for no of nodes set in your tcl file . Location of the text file need to specified clearly while you are running the command.

5  99.5
10 99.7
20 99.0
30 95.6
40 94.8
50 95.9



Once you created text file and kept this data ,Run the command 

Xgraph PDRvsNODE.txt   –bg white –tk –bb –m -M –t “Marker” –geometry  800x400

Xgraph for Throughput in NS2:

      Like the same way the xgraph can be plotted for throughput against node size in the network.


That's it!!! You arrived your destination successfully.

No comments:

Post a Comment