A few important use-cases are heavily guided the design of the Packet framework of ns:
- New types of packet headers or trailers are introduced in Ns3 packet to avoid changing the core of the simulator.
- The ease of integration with real-world code and systems are maximized by the Ns3 packet.
- The fragmentation, defragmentation, and, concatenation are easily supported by the Ns3 packet. Especially in wireless systems these are very important concept.
- This Ns3 packet object is efficiently made the memory management.
- For emulated applications the actual application data or dummy application bytes are allowed.
Ns3 packet design
The multiple references are used to the Ns3 packet object. And only so-called “dirty” operations will trigger a deep copy of the packet which is one of the operations of Ns3 packet:
- both versions of ns3::Packet::AddAtEnd()
The Ns3 packet headers are more common component of packets and the buffer should store the class header and the class trailer which are the main parts of the Ns3 packet.
The class Header and class Trailer are the fundamental classes for adding to and removing from the byte buffer. But largely the below discussion also applies to protocols using trailers and the Ns3 packet headers are more common. From a Packet instance every protocol header that needs to be inserted and removed. And it is derived from the abstract Header base class and the private pure virtual methods are also implemented by it. The pure virtual methods are listed below:
Using the packet interface on Ns3 packet
This Ns3 packet using the packet interface section which describes how to create and use the ns3::Packet object.
Creating a new Ns3 packet
The new Ns3 packet with a new unique Id is created by the following command:
Ptr<Packet> pkt = Create<Packet> ();
What is the Uid (unique Id)? To identify packets that the system uses it and are done with the help of an internal id which is calles as Uid. The following method is used to fetch the Uid::uint32_t uid = pkt->GetUid ().
An accurate counter of how many “simulated packets” of a particular protocol are in the system cannot be counted by this uid and which is an internal. And the user should look at the Uid when a user wants to trace actual packet counts. For example an IP ID field or transport sequence numbers, or other packet or frame counters at other c.
The Ns3 packets with zero-filled payloads are created by the protocol layers which has all the possibilities. Actually a memory allocation (i.e., the packet may behave, when delays such as serialization or transmission delays are computed, to have a certain number of payload bytes, but the bytes will only be allocated on-demand when needed) is not required to the Ns3 packets. When the Ns3 packets is created:: Ptr<Packet> pkt = Create<Packet> (N) the command to do this is. Where N is represent as a positive integer. The core simulator changing is also possible in Ns3 packet.
The Ns3 packets can be verified by the GetSize() method::and now the packet has a size of N bytes.
* \returns the size in bytes of the packet (including the zero-filled
* initial payload)