Packet Headers Format and Trace 698430007 Outline Introduction

  • Slides: 26
Download presentation
Packet Headers Format and Trace 蕭博鴻 698430007

Packet Headers Format and Trace 蕭博鴻 698430007

Outline Introduction Packet Module Packet Header Mapping to Otcl Packet Header Manager in NS

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

Introduction Packet consists of packet header and data payload. In most cases, NS 2

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

Packet Module Here comes your footer Page 4

Packet Module Here comes your footer Page 4

Here comes your footer Page 5

Here comes your footer Page 5

C++ Variables of class Packet unsigned char* bits_ App. Data* data_ int hdr_len_ bool

C++ Variables of class Packet unsigned char* bits_ App. Data* 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 Here comes your footer Page 6

C++ Functions of class Packet void init(Packet* ) - Clears the packet header bits_

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. Here comes your footer Page 7

Cont’ void allocdata(int) - Allocates “n” bytes of data payload to the variable data_.

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). Here comes your footer Page 8

Link List of Packet Here comes your footer Page 9

Link List of Packet Here comes your footer Page 9

Packet Queue Here comes your footer Page 10

Packet Queue Here comes your footer Page 10

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

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

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

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

Packet Header Here comes your footer Page 13

Packet Header Here comes your footer Page 13

Packet Header Module Here comes your footer Page 14

Packet Header Module Here comes your footer Page 14

Common Header Structure Here comes your footer Page 15

Common Header Structure Here comes your footer Page 15

Packet Type Here comes your footer Page 16

Packet Type Here comes your footer Page 16

Class/Object Name C++ Structure hdr_cmn OTcl Class Packet. Header/Common Mapping Class Common. Header. Class

Class/Object Name C++ Structure hdr_cmn OTcl Class Packet. Header/Common Mapping Class Common. Header. Class Mapping Variable class_cmnhdr Here comes your footer Packet Header Mapping to OTcl Page 17

Here comes your footer Page 18

Here comes your footer Page 18

Packet Header Manager in NS 2 Here comes your footer Page 19

Packet Header Manager in NS 2 Here comes your footer Page 19

Packet Header Manager Here comes your footer Page 20

Packet Header Manager Here comes your footer Page 20

Packet Header Manager add Packet Header Add all Packet Header to Ns 2 Init

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

The Other Command add-packet-header args - This global proc will tell simulator to include

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. Here comes your footer Page 22

Defining a New Packet Header to NS 2 Step by Step 1. Define a

Defining a New Packet Header to NS 2 Step by Step 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 “Echo. Back” 3. Define a protocol specific header OTcl class Packet. Header/Echo. Back 4. Derive a mapping class Echo. Back. Header. Class from Packet. Header. Class − At the construction, feed Packet. Header/Echo. Back and sizeof(struct hdr_echo_back) of class Packet. Header. Class − From within the constructor, Use bind_offset function to bind hdr_echo_back: : offset_ 5. Active Header into the Packet. Header. Manager protocol list. − Added Echo. Back into the foreach loop 6. Edit Makefile to Compile your header, then clean the ns 2 and recompile ns 2. Here comes your footer Page 23

抽考題目 在NS 2的封包內新增一個表頭(Echo. Back)。 Here comes your footer Page 24

抽考題目 在NS 2的封包內新增一個表頭(Echo. Back)。 Here comes your footer Page 24

抽考題目(提示) 根據下面步驟來完成新增動作。 1. Define a protocol specific header C++ struct hdr_echo_back − Declare variable

抽考題目(提示) 根據下面步驟來完成新增動作。 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 “Echo. Back” 3. Define a protocol specific header OTcl class Packet. Header/Echo. Back 4. Derive a mapping class Echo. Back. Header. Class from Packet. Header. Class − At the construction, feed Packet. Header/Echo. Back and sizeof(struct hdr_echo_back) of class Packet. Header. Class − From within the constructor, Use bind_offset function to bind hdr_echo_back: : offset_ 5. Active Header into the Packet. Header. Manager protocol list. − Added Echo. Back into the foreach loop 6. Edit Makefile to Compile your header, then clean the ns 2 and recompile ns 2. § 程式碼的部分已經完成,將echo_back. cc跟 echo_back. h 放到NS 2的資料夾內,根據上面的步 驟完成 2、5、6的步驟 Here comes your footer Page 25

THANK YOU Here comes your footer Page 26

THANK YOU Here comes your footer Page 26