Friday 9 November 2012

Xgraph for plotting in NS-2



After running your NS-2 program you will have a trace file as output.

Let us assume the name of the output file is "trace1.tr"

The trace file might look like below

+ 1             0 2 cbr 210 ------- 0 0.0 3.1 0 0
- 1              0 2 cbr 210 ------- 0 0.0 3.1 0 0
r  1.00212  0 2 cbr 210 ------- 0 0.0 3.1 0 0
+ 1.00212  0 2 cbr 210 ------- 0 0.0 3.1 0 0
+ 1.055      0 3 cbr 210 ------- 0 0.0 3.1 0 0

I am not explaining the meaning of the trace file. Instead I am giving instructions to use xgraph to draw a graph involving data extracted from the trace file.

To use xgraph we need 2 columns of data. The Unix command called "cut" is used for this purpose.

Open terminal and type the following commands

###############################

    cut  -d  " "  -f  2  trace1.tr  >  file1

    cut  -d  " "  -f  6  trace1.tr  >  file2

    paste      file1     file2    >   output

    xgraph   output

###############################

This will extract columns 2 and 6 and then draw a graph using the xgraph utility.

 
 for "cut" keyword -d specifies the delimiter between columns.
 Here the delimiter is white space ("  ").
 -f specifies the column number of the data to be extracted. 



7 comments:

  1. thank you.. very useful

    ReplyDelete
    Replies
    1. how can i write this command in terminal

      Delete
  2. plz tell me, commands for executing xgraph in ns2

    ReplyDelete
  3. @aks type command on terminal


    xgraph ur_file_name (which is having co-ordinate x y)

    ReplyDelete
  4. hi,
    I have some result in delay.tr , I want to display in Xgraph .
    How i can do that ?

    ReplyDelete
  5. how to define xgraph intcl program?pls rply

    ReplyDelete