NS2 Ultimate
Post processing NS2 Result using NS2 Trace — Trace file format

Table of Contents ] [ Previous Post ] [ Next Post ]

Note: The content in this series is extracted from the book, Introduction to Network Simulator NS2. You may have to read chapters 2 and 13 of the book for better understanding.

What’s in this post?

In the previous post, I showed you how to create a “trace file” in NS2. In this post, I will show you the interpretation of an NS2 trace file.

Example of trace files

When using trace-all in NS2, a trace string is created in a trace file. The trace file would look like this.

Trace file format

The format of a trace string is shown below:

where 12 fields of the trace string are as follows.

1. Type Identifier:

  • +”: a packet enque event
  • -”: a packet deque event
  • r”: a packet reception event
  • d”: a packet drop (e.g., sent to dropHead_) event
  • c”: a packet collision at the MAC level

2. Time: at which the packet tracing string is created.

3-4. Source Node and Destination Node: denote the IDs of the source and the destination nodes of the tracing object.

5. Packet Name: Name of the packet type

6. Packet Size: Size of the packet in bytes.

7. Flags: A 7-digit flag string

  • -”: disable
  • 1st = “E”: ECN (Explicit Congestion Notification) echo is enabled.
  • 2nd = “P”: the priority in the IP header is enabled.
  • 3rd : Not in use
  • 4th = “A”: Congestion action
  • 5th = “E”: Congestion has occurred.
  • 6th = “F”: The TCP fast start is used.
  • 7th = “N”: Explicit Congestion Notification (ECN) is on.

8. Flow ID

9-10. Source Address and Destination Address: the format of these two fields is “a.b”, where “a" is the address and "b" is the port.

11. Sequence Number

12. Packet Unique ID

What’s Next

So, trace files are not so hard to understand after all. But what’s hard is the information overload. There are hundreds or thousands of lines in a trace file. But you don’t need those information.

What you need is perhaps the throughput or delay. So how are you going to compute that from a trace file. I’ll discuss that in the next post.  


T. Issaraiyakul and E. Hossain, “Introduction to Network Simulator NS2”, Springer 2009. Buy it now from Amazon:


You may also find lecture notes and other resource at the following website:http://www.ece.ubc.ca/~teerawat/NS2.htm