26
報報報 報報報 NS2 Chapter 26 Trace Support

報告者:黃亮維 NS2 Chapter 26 Trace Support. Outline Trace Support ‧ OTcl Helper Functions Library support and examples The C++ Trace Class Trace File

Embed Size (px)

Citation preview

Page 1: 報告者:黃亮維 NS2 Chapter 26 Trace Support. Outline  Trace Support ‧ OTcl Helper Functions  Library support and examples  The C++ Trace Class  Trace File

報告者:黃亮維

NS2

Chapter 26

Trace Support

Page 2: 報告者:黃亮維 NS2 Chapter 26 Trace Support. Outline  Trace Support ‧ OTcl Helper Functions  Library support and examples  The C++ Trace Class  Trace File

Outline

Trace Support

‧OTcl Helper Functions Library support and examples The C++ Trace Class Trace File Format Packet Types

Page 3: 報告者:黃亮維 NS2 Chapter 26 Trace Support. Outline  Trace Support ‧ OTcl Helper Functions  Library support and examples  The C++ Trace Class  Trace File

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.

Page 4: 報告者:黃亮維 NS2 Chapter 26 Trace Support. Outline  Trace Support ‧ OTcl Helper Functions  Library support and examples  The C++ Trace Class  Trace File

Trace Support The trace support in OTcl consists of a number of specializ

ed classes visible in OTcl but implemented in C++=> Combined with a set of Tcl helper procedures and classes d

efined 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

Page 5: 報告者:黃亮維 NS2 Chapter 26 Trace Support. Outline  Trace Support ‧ OTcl Helper Functions  Library support and examples  The C++ Trace Class  Trace File

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

Page 6: 報告者:黃亮維 NS2 Chapter 26 Trace Support. Outline  Trace Support ‧ OTcl Helper Functions  Library support and examples  The C++ Trace Class  Trace 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>.

Page 7: 報告者:黃亮維 NS2 Chapter 26 Trace Support. Outline  Trace Support ‧ OTcl Helper Functions  Library support and examples  The C++ Trace Class  Trace File

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):

Page 8: 報告者:黃亮維 NS2 Chapter 26 Trace Support. Outline  Trace Support ‧ OTcl Helper Functions  Library support and examples  The C++ Trace Class  Trace File

Library support and examples

1

Page 9: 報告者:黃亮維 NS2 Chapter 26 Trace Support. Outline  Trace Support ‧ OTcl Helper Functions  Library support and examples  The C++ Trace Class  Trace File

加入 Trace對象

Page 10: 報告者:黃亮維 NS2 Chapter 26 Trace Support. Outline  Trace Support ‧ OTcl Helper Functions  Library support and examples  The C++ Trace Class  Trace File

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.

Page 11: 報告者:黃亮維 NS2 Chapter 26 Trace Support. Outline  Trace Support ‧ OTcl Helper Functions  Library support and examples  The C++ Trace Class  Trace File

The C++ Trace Class

The overall class is defined as follows in trace.cc:

Page 12: 報告者:黃亮維 NS2 Chapter 26 Trace Support. Outline  Trace Support ‧ OTcl Helper Functions  Library support and examples  The C++ Trace Class  Trace File

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.

Page 13: 報告者:黃亮維 NS2 Chapter 26 Trace Support. Outline  Trace Support ‧ OTcl Helper Functions  Library support and examples  The C++ Trace Class  Trace File

Trace File Format

Page 14: 報告者:黃亮維 NS2 Chapter 26 Trace Support. Outline  Trace Support ‧ OTcl Helper Functions  Library support and examples  The C++ Trace Class  Trace File

Trace File Format

An example of a trace file (without the tcp header fields) might appear as follows:

Page 15: 報告者:黃亮維 NS2 Chapter 26 Trace Support. Outline  Trace Support ‧ OTcl Helper Functions  Library support and examples  The C++ Trace Class  Trace File

Trace File Format

flags are used for ECN: =>TCP/IP 明確擁塞通知 (ECN) 讓路由器能夠通知

「傳 輸控制通訊協定」 (TCP) 對等體,由於網路擁塞, 緩衝區已滿。 TCP 對等體會以減緩資料傳輸來回 應,協助防止封包損失。

Page 16: 報告者:黃亮維 NS2 Chapter 26 Trace Support. Outline  Trace Support ‧ OTcl Helper Functions  Library support and examples  The C++ Trace Class  Trace File

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.

Page 17: 報告者:黃亮維 NS2 Chapter 26 Trace Support. Outline  Trace Support ‧ OTcl Helper Functions  Library support and examples  The C++ Trace Class  Trace File

Trace Support (wireless)

cmu-trace objects are of three types CMUTrace/Drop CMUTrace/Recv CMUTrace/Send

Page 18: 報告者:黃亮維 NS2 Chapter 26 Trace Support. Outline  Trace Support ‧ OTcl Helper Functions  Library support and examples  The C++ Trace Class  Trace File

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)

Page 19: 報告者:黃亮維 NS2 Chapter 26 Trace Support. Outline  Trace Support ‧ OTcl Helper Functions  Library support and examples  The C++ Trace Class  Trace File

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.

Page 20: 報告者:黃亮維 NS2 Chapter 26 Trace Support. Outline  Trace Support ‧ OTcl Helper Functions  Library support and examples  The C++ Trace Class  Trace File

new trace format

Page 21: 報告者:黃亮維 NS2 Chapter 26 Trace Support. Outline  Trace Support ‧ OTcl Helper Functions  Library support and examples  The C++ Trace Class  Trace File

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

Page 22: 報告者:黃亮維 NS2 Chapter 26 Trace Support. Outline  Trace Support ‧ OTcl Helper Functions  Library support and examples  The C++ Trace Class  Trace File

new trace format

General tag The second field starting with "-t" may stand for time o

r global setting -t time -t * (global setting)

Page 23: 報告者:黃亮維 NS2 Chapter 26 Trace Support. Outline  Trace Support ‧ OTcl Helper Functions  Library support and examples  The C++ Trace Class  Trace File

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 droppin

g a packet are given below:

Page 24: 報告者:黃亮維 NS2 Chapter 26 Trace Support. Outline  Trace Support ‧ OTcl Helper Functions  Library support and examples  The C++ Trace Class  Trace File

new trace format Packet information at IP level The tags for this field start with a leading "-I" and are listed a

long 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

Page 25: 報告者:黃亮維 NS2 Chapter 26 Trace Support. Outline  Trace Support ‧ OTcl Helper Functions  Library support and examples  The C++ Trace Class  Trace File

new trace format Next hop info This field provides next hop info and the tag starts with a lea

ding "-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 lea

ding "-M" as shown below: -Ma: duration -Md: dst’s ethernet address -Ms: src’s ethernet address -Mt: ethernet type

Page 26: 報告者:黃亮維 NS2 Chapter 26 Trace Support. Outline  Trace Support ‧ OTcl Helper Functions  Library support and examples  The C++ Trace Class  Trace File

new trace format

Packet info at "Application level“ The packet information at application level consists of t

he type of application like ARP,TCP, the type of adhoc routing protocol like D

SDV, DSR, AODV etc being traced. This field consists of a leading "-P“ and list of tags