Manual interpretation of ns2 trace file

If you have generated a trace file from running a ns tcl script, you should be able to analyze it without the use of any tools. This could come handy in emergencies when you don’t have any tools (Tracegraph,perl scripts etc) at hand.

The following method has been suggested at a ns mailing list.

To find the interpretation of all possible trace format when you do the wireless simulation, you’d better read the code of ns2 in file ns2home/trace/cmu-trace{.h, .cc}.

where ns2home denotes the location of ns-allinone-* installation folder.

Usually the format looks like this:

ACTION: [s|r|D|f]: s -- sent, r -- received, D -- dropped,f -- forwarded
WHEN: the time when the action happened
WHERE: the node where the action happened
LAYER: AGT -- application,
 RTR -- routing,
 LL  -- link layer (ARP is done here)
 IFQ -- outgoing packet queue (between link and mac layer)
 MAC -- mac,
 PHY -- physical
flags:
SEQNO: the sequence number of the packet
TYPE: the packet type
  cbr -- CBR data stream packet
  DSR -- DSR routing packet (control packet generated by routing)
  RTS -- RTS packet generated by MAC 802.11
  ARP -- link layer ARP packet
SIZE: the size of packet at current layer, when packet goes down,
  size increases, goes up size decreases
[a b c d]: a -- the packet duration in mac layer header
  b -- the mac address of destination
  c -- the mac address of source
  d -- the mac type of the packet body
flags:
[......]: [
  source node ip : port_number
  destination node ip (-1 means broadcast) : port_number
  ip header ttl
  ip of next hop (0 means node 0 or broadcast)
  ]


So if you have a line like this

s 76.000000000 _98_ AGT – – – – 1812 cbr 32 [0 0 0 0] ——- [98:0 0:0 32 0]

in your trace file.

You should interpret it as

Application 0 (port number) on node 98 sent a CBR packet whose ID is 1812 and size is 32 bytes, at time 76.0 second, to application 0 on node 0 with TTL is 32 hops. The next hop is not decided yet.

Similarly, You should be able to interpret a line such as this:

r 0.010176954 _9_ RTR – – – – 1 gpsr 29 [0 ffffffff 8 800] ——- [8:255 -1:255 32 0]

as

The routing agent on node 9 received a GPSR broadcast (mac address 0xff, and ip address is -1, either of them means broadcast) routing packet whose ID is 1 and size is 29 bytes, at time 0.010176954 second, from node 8 (both mac and ip addresses are 8), port 255 (routing agent).

If you choose to play safe by making use of Tracegraph, then <this> post might help you.

Update:

Recently, I chanced to read <this manual> by Eitman Altman and manual is well organised for intermediate learners in ns2. I have extraced the ns2 trace file part from that and presented it below.

r 40.639943289 _1_ AGT —- 1569 tcp 1032 [a2 1 2 800] —-  [0:0 1:0 32 1] [35 0] 2 0


* The first field is a letter that can have the values r,s,f,D for “received”,”sent”,”forwarded” and “dropped”, respectively.It can also be < for giving a location or a movement indication.
* The second field is the time.
* The third field is the node number.
* The fourth field is MAC to indicate if the packet concerns a MAC layer, it is AGT to indicate the transport layer(e.g. tcp) packet, or RTR if it concerns the routed packet. It can also be IFQ to indicate events related to the interference priority queue(like drop of packets).
* After the dashes come the global sequence number of the packet(this is not the tcp sequence number).
* At the next field comes more information on the packet type(eg. tcp,ack or udp).
* Then comes the packet size in bytes.
* The 4 numbers in the first square brackets concern the mac layer information. The first hexadecimal number,a2(which equals 162 in decimal) specifies the expected time in seconds to send this data packet over the wireless channel. The second number,1, stands for the MAC-id of the sending node, and the third,2, is that of the receiving node. The fourth number,800, specifies that the MAC type is ETHERTYPE_IP.
* The next numbers in the second square brackets concern the IP source and destination addresses, then the ttl(Time To Live) of the packet(in our case 32),
* The third bracket concern the tcp information: its sequence number and the acknowledgment number.

This article is proudly sponsored by Evansys Technologies

Was this post helpful? Then thank me by clicking <this link>

References:

Introduction to Network Simulator NS2

Eitman Altman’s NS2 Tutorial for Beginners

Alternative Reading:

* How to interpret ns2 trace file for wireless simulation?

Recommended Reading:

* Using Eclipse to enhance your experience of ns2

* How to scale your simulation to more nodes (500 nodes) and speed up it?

* Method to analyse ns2 trace file

23 comments on “Manual interpretation of ns2 trace file

  1. Hello sir, please help me, how to interpretation this trace file, i use ns2.35 RC7 with AOMDV routing protokol.

    s 10.000000000 _0_ RTR — 0 AOMDV 52 [0 0 0 0] ——- [0:255 -1:255 30 0] [0x2 0 1 [5 0] [0 4]] (REQUEST)

    r 10.001280707 _1_ RTR — 0 AOMDV 52 [0 ffffffff 0 800] ——- [0:255 -1:255 30 0] [0x2 0 1 [5 0] [0 4]] (REQUEST)

    s 10.008415449 _5_ RTR — 0 AOMDV 52 [0 0 0 0] ——- [5:255 0:255 30 3] [0x4 0 [5 2] 10.000000] (REPLY) [1 3]

    s 10.023572848 _0_ RTR — 0 cbr 532 [0 0 0 0] ——- [0:0 5:0 30 1] [0] 0 0

    s 10.389008077 _4_ RTR — 0 AOMDV 44 [0 0 0 0] ——- [4:255 -1:255 1 0] [0x1 0 [4 2] 4.000000] (HELLO) [0 0]

    r 10.390024577 _2_ RTR — 0 AOMDV 44 [0 ffffffff 4 800] ——- [4:255 -1:255 1 0] [0x1 0 [4 2] 4.000000] (HELLO) [0 0]

    Thank you very much……

  2. Hi,
    i am using ubuntu11.04 and ns2.32.i ran ./trgraph at the shell prompt and getting the following error.

    ./trgraph: error while loading shared libraries: libmwsgl.so: cannot
    open shared object file: No such file or directory

    plz help me how to correct this.

  3. Hi,

    I want to count the number of registration message(REQUEST), REPLY & solicitations in a mobile network……

    Is it possible to find by analysing the trace file…

    If so which type of packets to count……….

  4. thanks sir 🙂
    r 325.809900233 _5_ AGT — 36310 rca 4016 [0 2f000000 ffff0008 0] ——- [r 47 5 -1]
    please can you tell me what does mean “-1” in the end of line !!!!!!

  5. Pingback: NS2 v2.26 installation on Ubuntu 11.10 - Page 4

  6. Hi diamond,

    I’m not sure if this is what you want, but you can parse the TCL file:
    «…
    $node_(0) set X_ 12.0
    $node_(0) set Y_ 27.0
    $node_(0) set Z_ 0.0
    …»

    Best regards.

  7. Pingback: How to generate traffic file in new trace format, for wireless network in NS-2.34?

  8. Pingback: NS2 (Network Simulator2) Materials | Sayyed Mohsen Zahraee

  9. hi sir.

    i am facing error when i generate xgraph from trace(.tr) file like this

    Error in file ‘out.tr’ at line …
    unknown line type
    problems found with input data.

    please sir give me solution it is very important to me.
    pradeep.vanparia@gmail.com

Leave a comment