12.1.1 Adding a New Packet Header Type

Assuming we wish to create a new header called newhdr the following steps are performed:

  1. create a new structure defining the raw fields (called hdr_newhdr), define offset_ and access methods.
  2. define member functions for needed fields.
  3. create a static class to perform OTcl linkage (defines PacketHeader/Newhdr), do bind_offset() in its constructor.
  4. edit ~ns/tcl/lib/ns-packet.tcl to enable new packet format (see 12.2.2, 12.2.4).

This is the recommended way to add your packet headers. If you do not follow this method, your simulation may still work, but it may behave in a unpredictable way when more protocols are added into your simulation. The reason is that the BOB (Bag of Bits, Section 12.2.1) in ns packet is a large sparse space, assigning one wrong packet header offset may not trigger failure immediately.



Tom Henderson 2011-11-05