260 likes | 502 Views
NS2 Chapter 26 Trace Support. 報告者:黃亮維. Outline. Trace Support ‧OTcl Helper Functions Library support and examples The C++ Trace Class Trace File Format Packet Types. Trace Support. Traces
E N D
NS2 Chapter 26 Trace Support 報告者:黃亮維
Outline • Trace Support ‧OTcl Helper Functions • Library support and examples • The C++ Trace Class • Trace File Format • Packet Types
Trace Support • Traces => Record each individual packet as it arrives, departs, or is dropped at a link or queue. • Trace data is either displayed directly during execution of the simulation, or (more commonly) stored in a file to be post-processed and analyzed.
Trace Support • The trace support in OTcl consists of a number of specialized classes visible in OTcl but implemented in C++ => Combined with a set of Tcl helper procedures and classes defined in the library. Trace/Hop: trace a hop Trace/Enque: packet arrival Trace/Deque: packet departure Trace/Drop: packet drop Trace/Recvpacket: receive event at the destination node of a link
OTcl Helper Functions • The following helper functions may be used within simulation scripts to help in attaching trace elements (see tcl/lib/ns-lib.tcl). $ns_ flush-trace This command flushes the trace buffer. $ns_ create-trace type file src dst This command creates a trace object of type <type> between the <src> and <dst> nodes. The traces are written into the <file>.
OTcl Helper Functions $ns_ trace-queue n1 n2 optional:file This command creates a trace object for tracing events on the link represented by the nodes <n1> and <n2>. $ns_ drop-trace n1 n2 trace This command makes the given <trace> object a drop- target for the queue associated with the link between nodes <n1> and <n2>.
Library support and examples • The Simulator procedures described above require the trace and init-monitor methods associated with the OTcl Link class. • The trace function is defined as follows (in ns-link.tcl):
The C++ Trace Class • The single C++ Trace class is used to implement the OTcl classes Trace/Hop, Trace/Enque, Trace/Deque, and Trace/Drop. • The type _ field is used to differentiate among the various types of traces any particular Trace object might implement. Currently, this field may contain one of the following symbolic characters: => + for enque,-for deque, h for hop, and d for drop.
The C++ Trace Class • The overall class is defined as follows in trace.cc:
Trace File Format • The []Trace::format method defines the trace file format used in trace files produced by the Trace class. • It formats the source, destination, and type fields defined in the trace object (not in the packet headers), the current time, along with various packet header fields including, type of packet (as a name), size, flags (symbolically), flow identifier, source and destination packet header fields, sequence number (if present), and unique identifier.
Trace File Format • An example of a trace file (without the tcp header fields) might appear as follows:
Trace File Format • flags are used for ECN: =>TCP/IP 明確擁塞通知 (ECN) 讓路由器能夠通知「傳 輸控制通訊協定」(TCP) 對等體,由於網路擁塞, 緩衝區已滿。TCP 對等體會以減緩資料傳輸來回 應,協助防止封包損失。
Packet Types • Each packet contains a packet type field used by Trace::format to print out the type of packet encountered. • Initialization of the type field in packets is performed by the Agent::allocpkt method. • The type field is set to integer values associated with the definition passed to the Agent constructor.
Trace Support (wireless) • cmu-trace objects are of three types • CMUTrace/Drop • CMUTrace/Recv • CMUTrace/Send
Trace Support (wireless) • An example of a trace for a tcp packet is as follows: • CMUTrace::format() defines and dictates the trace file format. (cmu-trace.cc)
Revised format for wireless traces • cmu-trace objects • $ns use-newtrace =>This command should be called before the universal trace command $ns trace-all <trace-fd> • Note: Currently this new trace support is available for wireless.
new trace format • Event type • In the traces above, the first field (as in the older trace format) describes the type of event taking place at the node and can be one of the four types: • s send • r receive • d drop • f forward
new trace format • General tag • The second field starting with "-t" may stand for time or global setting • -t time • -t * (global setting)
new trace format • Node property tags • denotes the node properties like node-id, the level at which tracing is being done like agent,router or MAC. The tags start with a leading "-N" and are listed as below: • -Ni: node id • -Nx: node’s x-coordinate • -Ny: node’s y-coordinate • -Nz: node’s z-coordinate • -Ne: node energy level • -Nl: trace level, such as AGT, RTR, MAC • -Nw: reason for the event. The different reasons for dropping a packet are given below:
new trace format • Packet information at IP level • The tags for this field start with a leading "-I" and are listed along with their explanations as following: • -Is: source address.source port number • -Id: dest address.dest port number • -It: packet type • -Il: packet size • -If: flow id • -Ii: unique id • -Iv: ttl value
new trace format • Next hop info • This field provides next hop info and the tag starts with a leading "-H". • -Hs: id for this node • -Hd: id for next hop towards the destination. • Packet info at MAC level • This field gives MAC layer information and starts with a leading "-M" as shown below: • -Ma: duration • -Md: dst’s ethernet address • -Ms: src’s ethernet address • -Mt: ethernet type
new trace format • Packet info at "Application level“ • The packet information at application level consists of the type of application • like ARP,TCP, the type of adhoc routing protocol like DSDV, DSR, AODV etc being traced. • This field consists of a leading "-P“ and list of tags