Assuming we wish to create a new header called newhdr the following steps are performed:
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.