Hi All, Our website moved to a new URL. Please bookmark the new link: https://ns2bloggers.blogspot.com/

TRACE FILES AND DESCRIPTION


The file written by an application (or by the Coverage Server) to store coverage information or overall network information and In NS2 , it is called as Trace File.

In order to generate a trace file. we have to create a trace file in Otcl script.


SYNTAX FOR CREATING A TRACE FILE


# Open the trace file

set nf [open out.tr w]

$ns trace-all $nf


which means we are opening a newtrace file named as "out" and also telling that data must be stored in .tr [trace] format.

"nf" is the file handler that we are used here to handle the trace file.

"w" means write i.e the file out.tr is opened for writing.

>> "r" means reading and "a" means appending

The second line tells the simulator to trace each packet on every link in the topology and for that we give file handler nf for the simulator ns.


# Define finish procedure

proc finish {} {

global ns nf

$ns flush-trace

close nf

exit 0

}

In here the trace data is flushed into the file by using command $ns flush-trace and then file is closed.

While running the ns2 program via terminal, trace file is generated in the selected directory (folder or directory where the program stored).



SNAP SHOT OF A GENERATED TRACE FILE FOR WIRED NETWORK



The format of a trace string is shown below:




In here,there is 12 feilds and we can explain it as;

1. EVENT OR 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 AND DESTINATION NODE : source and destination ID's of tracing objects.

5. PACKET NAME : Name of the packet type.

6. PACKET SIZE : Size of packet in bytes.

7. FLAGS : 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 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

Each trace line starts with an event (+, -, d, r) descriptor followed by the simulation time (in seconds) of that event, and from and to node, which identify the link on which the event occurred. Look at Figure 4 in the Network Components to see where in a link each type of event is traced. The next information in the line before flags (appeared as "------" since no flag is set) is packet type and size (in Bytes). Currently, NS implements only the Explicit Congestion Notification (ECN) bit, and the remaining bits are not used. The next field is flow id (fid) of IPv6 that a user can set for each flow at the input OTcl script. Even though fid field may not used in a simulation, users can use this field for analysis purposes. The fid field is also used when specifying stream color for the NAM display. The next two fields are source and destination address in forms of "node.port". The next field shows the network layer protocol's packet sequence number. Note that even though UDP implementations do not use sequence number, NS keeps track of UDP packet sequence number for analysis purposes. The last field shows the unique id of the packet.


SNAP SHOT OF A GENERATED TRACE FILE FOR WIRELESS NETWORK [NEW TRACE FILE FORMAT]


New Trace File Format
























TRACE FILE DESCRIPTION

Following list shows the trace file variables and its explanations;

s - send packet
r - received packet
d - packet dropped 
f - packet forwarded
c - collision of packet at MAC level
t - time at which packet tracing started
Hs - ID of the hop
Hd - ID of the next hop towards destination 
Ni - Node ID
Nx,Ny,Nz - Co ordinates that the nodes situated
Ne - Node energy level
Nl - Trace level
Nw - Reason of the event
AGT - Agent
RTR -Routing
END - DROP End of Simulation
COL - DROP MAC COLLISION
DUP - DROP MAC DUPLICATE
DERR - DROP MAC PACKET ERROR
RET - DROP MAC RETRY COUNT EXCEED
STA - DROP MAC INVALID STATE
BSY - DROP MAC BUSY
NRTE - DROP RTR - NO ROUTE
LOOP - DROP RTR ROUTE LOOP
TTL - DROP RTR TTL has reached Zero
TOUT - DROP-RTR-QTIME OUT Expired
Is - Source address of source port
Id - Destination address of destination port
Il - Packet Size
If - Flow ID
Ii - Unique ID
Iv - TTL value next hop into

MAC LAYER INFORMATION

Ma - MAC Layer duration
Md - Destn. Ethernet Address
Ms - Source Ethernet Address
Mt - Ethernet Type

PACKET INFORMATION

-P arp - address resolution protocol-Po - ARP Request / Reply
Pm - Source MAC Address
Ps - Source Address
Pa - Destination MAC Address
Pd - Destination Address
Pn - Nodes Transversed
Pq - Flag
Pi - Route Request Sequence Number/ Sequence Number
Pp - Flag
Pl - Reply Length
Pe - src of source routing
Pw - Error Report Flag
Pc - Report to whom 
Pb - Link error from link a to link b
-P cbr - CBR data
Pf - How many level packet leave
Po - Optimal Number of Forward
-P TCP - TCP flow
-Ps - seq. number
Pu - acknowledgement
Pf - Packet Failure



OLD TRACE FORMAT

Old trace format consists of two parts;

Basic trace string: This is similar to the Normal Packet Trace Format(Seen in wired trace file format). It is labeled with numbered 1-12. These fields appear in every trace strings. 
Additional trace string: This string is specific to what NS2 is tracing. For example, the trace strings for IP Trace and AODV-RREQ Trace format are shown above. When NS2 does not trace these two information. These lines will not appear as a part of the trace string, but the Basic trace string would still appear on the string. 

Trace Field Definition
Trace level: The level NS2 is tracing. The common arguments are AGT for agent, MAC for MAC, and RTR for Routing. See the list of possible values in the file  ̃ns /trace/cmu-trace.cc.

Reason: The reason for this trace (e.g., “NRTE” for No RouTe Entry)
Time to Send Data: Expected duration required to transmitted this packet over the wireless channel as indicated by the underlying MAC protocol. 
Ethernet Packet Type: Currently, there are only two Ethernet packet types: RREQ Type: Type as indicated in the field “rq_type” of thehdr_aodv_request struct data type. By default, the value is “AODVTYPE_RREQ” defined as “0×02”.
A general IP packet: The value is “ETHERTYPE_IP” defined as “0×0800”.
An ARP packet: The value is “ETHERTYPE_ARP” defined as “0×0860”.

SNAPSHOT OF AODV TRACE FILE

Basic trace information:
  • The node “_0_” sends (i.e., “s”) at time “21.500275” second.
  • The trace level is at the “MAC” layer.
  • The packet has the unique ID of “0”, contains an “AODV” payload type, and is “106” bytes in size.
  • The MAC protocol assumes that the delay over the underlying wireless channel is zero “0”.
  • The source and destination MAC addresses are “0” and “ffffffff”, respectively.
  • This is an IP packet running over an Ethernet network (i.e., “800”).
IP trace information:
  • The IP source and destination addresses of “0” and “1”, respectively.
  • The ports for both source and destination are “255”.
  • The time to live and the address of the next hop node are “30” hops and “0”, respectively.
AODV trace information:
  1. This is an RREQ packet tagged with the ID “0×2”.
  2. The number of hop counts is “1” and the broadcast ID is “4”.
  3. The destination IP address and sequence number are 1 and 0, respectively.
  4. The source IP address and sequence number are 0 and 10, respectively.
  5. The string “(REQUEST)” confirms that this is the RREQ packet.


DSR TRACE FILE FORMAT




s: means send
606.210364161: time stamp
_39_:  node id
RTR: means router message
1306:  id of this packet
DSR: DSR agent
44: size in the common header hdr_cmn()
[13a a 27 800] MAC detail:  13a: means the expected transmission time ( note that packet size is large, 44 bytes, 314second?)
                                               a: means the receiving node: 10
                                               27: means the sending node is 39
                                               800:  IP header: 0x0800, (ETHERTYPE_ARP is 0x0806)
[39:255 8:255 255 8] IP detail: src address: IP 39 means 0.0.0.39
                                                  port 255
                                                  dst address: IP 8 means 0.0.0.8
                                                  port 255
                                                  TTL: 255
                                                  Next-hop: 8
2 [0 0] [0 0 0 0->0] [1 1 8 39->10] DSR detail:
                                                   2:  num_addrs()
                                                   [0 0] route-request option, this is not a route request, the second 0 is labeled for sequence number
                                                   [0 0 0 0->0]    route-reply option: [ " route-reply?" "Rreq seqno" "reply length" "dst of src  route", "src of the src route"]
                                                   [1 1 8 39->10], 1: shows this is a route error
                                                                            1: number of route errors
                                                                            8: tp notify node 8.
                                                                            39->10: link 39-10 is broken  

16 comments :

  1. Nice work...

    ReplyDelete
  2. good job thanks to all

    ReplyDelete
  3. Awesome work. Thank you.

    ReplyDelete
  4. Can you give me some detail explanation of some cognitive radio MAC protocol in ns2

    ReplyDelete
  5. This comment has been removed by the author.

    ReplyDelete
  6. hi
    can you helep me
    i need the file awk which gives time and energy consumption if you can me
    this my mail belkacemiroumeissa@gmail.com

    ReplyDelete
  7. Can u show me the meaning of fields in trace file? HELP ME


    s 11.007514174 _11_ AGT --- 968 rca 4016 [0 b000000 0 0] ------- [s 11 59 -1]
    r 11.007514175 _35_ AGT --- 963 rca 304 [0 3b000000 ffff0008 0] ------- [D 59 59 -1]

    ReplyDelete
  8. how can i find the number of rts and cts packet exhanged at mac layer from a trace file.

    ReplyDelete
  9. thnku so much i really understnd this jumbling of alphabets

    ReplyDelete
  10. How could I know the path followed by the protocol(AODV or AOMDV) looking at this trace files?

    ReplyDelete
  11. Thank for the very good explanation
    does M means mobility in the beginning of the line ? (New trace file)

    ReplyDelete
  12. how to change to new trace format sir? thankyou

    ReplyDelete
  13. What is the meaning of this
    "exec awk -f toXg temp1"
    Could anybody please explain. I am getting error while running the tcl file.

    The error is like this

    ns: finish: awk: fatal: can't open source file `toXg' for reading (No such file or directory)
    while executing
    "exec awk -f toXg temp1"
    (procedure "finish" line 14)
    invoked from within
    "finish"

    Thank you in advance

    ReplyDelete
  14. Bnj dans l'ancienne FORMAT DE TRACE
    Comment lire les positions $1 $2 ....(les colonnes ). Car un peut compliqué
    2eme j'ai besoin d l'ancienne format de trace protocoles dsdv

    ReplyDelete