Presentation is loading. Please wait.

Presentation is loading. Please wait.

Packet Headers Format and Trace 蕭博鴻 698430007. Here comes your footer Outline  Introduction  Packet Module  Packet Header  Packet Header Mapping to.

Similar presentations


Presentation on theme: "Packet Headers Format and Trace 蕭博鴻 698430007. Here comes your footer Outline  Introduction  Packet Module  Packet Header  Packet Header Mapping to."— Presentation transcript:

1 Packet Headers Format and Trace 蕭博鴻

2 Here comes your footer Outline  Introduction  Packet Module  Packet Header  Packet Header Mapping to Otcl  Packet Header Manager in NS2  Defining a New Packet Header to NS2 [Step by Step]  Trace Page 2

3 Here comes your footer Introduction  Packet consists of packet header and data payload.  In most cases, NS2 extracts information from data payload and stores the information into packet header.  By default, NS2 includes All packet headers of All protocols in every packet.  In NS2, Class Packet is derived from class Event. s.schedule(target_, p, txt + delay_) Page 3

4 Here comes your footer Page 4 Packet Module

5 Here comes your footer Page 5

6 Here comes your footer C++ Variables of class Packet  unsigned char* bits_  AppData* data_  int hdr_len_  bool fflag_ -Set to true if the packet is currently referred to by other objects and false otherwise  Packet* free_ -Pointer to the head of the packet free list  int ref_count_ -Number of objects which currently refer to the packet  Packet* next_ -Pointer to the next packet in the linked list of packets Page 6

7 Here comes your footer C++ Functions of class Packet  void init(Packet* ) -Clears the packet header bits_ of the input packet p.  Packet* copy() -Returns a pointer to a duplicated packet.  Packet* refcopy() -Increases the number of objects, which refer to the packet  Packet* alloc() -Creates a new packet and returns a pointer to the created packet.  Packet* alloc(n) -Creates a new packet with “n” bytes of data payload and returns a pointer to the created packet. Page 7

8 Here comes your footer Cont’  void allocdata(int) - Allocates “n” bytes of data payload to the variable data_.  void free(Packet*) -Deallocates packet.  char* access(int) -Retrieves a reference to a certain point (specified by the offset “off”) of the variable bits_ (i.e., packet header). Page 8

9 Here comes your footer Link List of Packet Page 9

10 Here comes your footer Page 10 Packet Queue

11 Here comes your footer Packet Allocation  Packet* alloc()  Packet* alloc(n) Page 11

12 Here comes your footer Packet Deallocation  void free(Packet*) Page 12

13 Here comes your footer Page 13 Packet Header

14 Here comes your footer Page 14 Packet Header Module

15 Here comes your footer Page 15 Common Header Structure

16 Here comes your footer Page 16 Packet Type

17 Here comes your footer Page 17 Packet Header Mapping to OTcl Class/ObjectName C++ Structurehdr_cmn OTcl ClassPacketHeader/Common Mapping ClassCommonHeaderClass Mapping Variableclass_cmnhdr

18 Here comes your footer Page 18

19 Here comes your footer Page 19 Packet Header Manager in NS2

20 Here comes your footer Page 20 Packet Header Manager

21 Here comes your footer Page 21 Packet Header Manager add Packet Header Add all Packet Header to Ns2 Init Simulator And Create Packet Format Init Simulator And Create Packet Format Allocate Packet Header Offset In Packet And increase header length Allocate Packet Header Offset In Packet And increase header length

22 Here comes your footer The Other Command  add-packet-header args -This global proc will tell simulator to include the specified packet header(s) in your simulation.  remove-packet-header args -operates in the same syntax, but it removes the specified headers from your simulation; notice that it does not remove the common header even it is instructed to do so.  remove-all-packet-headers -It takes no argument and removes all packet headers, except the common header, from your simulation. Page 22

23 Here comes your footer 1.Define a protocol specific header C++ struct hdr_echo_back −Declare variable offset_ −Define function access(p) −Include all member variables require to hold new packet attributes 2.Include new packet type into packet_t and class p_info −Declare variable PT_ECHOBACK −Protocol header ‘s name is “EchoBack” 3.Define a protocol specific header OTcl class PacketHeader/EchoBack 4.Derive a mapping class EchoBackHeaderClass from PacketHeaderClass −At the construction, feed PacketHeader/EchoBack and sizeof(struct hdr_echo_back) of class PacketHeaderClass −From within the constructor, Use bind_offset function to bind hdr_echo_back::offset_ 5.Active Header into the PacketHeaderManager protocol list. −Added EchoBack into the foreach loop 6.Edit Makefile to Compile your header, then clean the ns2 and recompile ns2. Page 23 Defining a New Packet Header to NS2 Step by Step

24 Here comes your footer Page 24 抽考題目  在 NS2 的封包內新增一個表頭 (EchoBack) 。

25 Here comes your footer  根據下面步驟來完成新增動作。 1.Define a protocol specific header C++ struct hdr_echo_back −Declare variable offset_ −Define function access(p) −Include all member variables require to hold new packet attributes 2.Include new packet type into packet_t and class p_info −Declare variable PT_ECHOBACK −Protocol header ‘s name is “EchoBack” 3.Define a protocol specific header OTcl class PacketHeader/EchoBack 4.Derive a mapping class EchoBackHeaderClass from PacketHeaderClass −At the construction, feed PacketHeader/EchoBack and sizeof(struct hdr_echo_back) of class PacketHeaderClass −From within the constructor, Use bind_offset function to bind hdr_echo_back::offset_ 5.Active Header into the PacketHeaderManager protocol list. −Added EchoBack into the foreach loop 6.Edit Makefile to Compile your header, then clean the ns2 and recompile ns2. Page 25  程式碼的部分已經完成,將 echo_back.cc 跟 echo_back.h 放到 NS2 的資料夾內,根據上面的步 驟完成 2 、 5 、 6 的步驟 抽考題目 ( 提示 )

26 Here comes your footer Page 26 THANK YOU


Download ppt "Packet Headers Format and Trace 蕭博鴻 698430007. Here comes your footer Outline  Introduction  Packet Module  Packet Header  Packet Header Mapping to."

Similar presentations


Ads by Google