Handle packet metadata about packet headers and trailers. More...
#include "packet-metadata.h"
Classes | |
struct | Data |
Data structure. More... | |
class | DataFreeList |
Class to hold all the metadata. More... | |
struct | ExtraItem |
ExtraItem structure. More... | |
struct | Item |
structure describing a packet metadata item More... | |
class | ItemIterator |
Iterator class for metadata items. More... | |
struct | SmallItem |
SmallItem structure. More... | |
Public Member Functions | |
PacketMetadata ()=delete | |
PacketMetadata (const PacketMetadata &o) | |
Copy constructor. | |
PacketMetadata (uint64_t uid, uint32_t size) | |
Constructor. | |
~PacketMetadata () | |
void | AddAtEnd (const PacketMetadata &o) |
Add a metadata at the metadata start. | |
void | AddHeader (const Header &header, uint32_t size) |
Add an header. | |
void | AddPaddingAtEnd (uint32_t end) |
Add some padding at the end. | |
void | AddTrailer (const Trailer &trailer, uint32_t size) |
Add a trailer. | |
ItemIterator | BeginItem (Buffer buffer) const |
Initialize the item iterator to the buffer begin. | |
PacketMetadata | CreateFragment (uint32_t start, uint32_t end) const |
Creates a fragment. | |
uint32_t | Deserialize (const uint8_t *buffer, uint32_t size) |
Deserialization from raw uint8_t*. | |
uint32_t | GetSerializedSize () const |
Get the metadata serialized size. | |
uint64_t | GetUid () const |
Get the packet Uid. | |
PacketMetadata & | operator= (const PacketMetadata &o) |
Basic assignment. | |
void | RemoveAtEnd (uint32_t end) |
Remove a chunk of metadata at the metadata end. | |
void | RemoveAtStart (uint32_t start) |
Remove a chunk of metadata at the metadata start. | |
void | RemoveHeader (const Header &header, uint32_t size) |
Remove an header. | |
void | RemoveTrailer (const Trailer &trailer, uint32_t size) |
Remove a trailer. | |
uint32_t | Serialize (uint8_t *buffer, uint32_t maxSize) const |
Serialization to raw uint8_t*. | |
Static Public Member Functions | |
static void | Enable () |
Enable the packet metadata. | |
static void | EnableChecking () |
Enable the packet metadata checking. | |
Private Member Functions | |
friend | DataFreeList::~DataFreeList () |
uint16_t | AddBig (uint32_t head, uint32_t tail, const PacketMetadata::SmallItem *item, const PacketMetadata::ExtraItem *extraItem) |
Add a "Big" Item (a SmallItem plus an ExtraItem) | |
uint16_t | AddSmall (const PacketMetadata::SmallItem *item) |
Add a SmallItem. | |
void | Append16 (uint16_t value, uint8_t *buffer) |
Append a 16-bit value to the buffer. | |
void | Append32 (uint32_t value, uint8_t *buffer) |
Append a 32-bit value to the buffer. | |
void | AppendValue (uint32_t value, uint8_t *buffer) |
Append a value to the buffer. | |
void | AppendValueExtra (uint32_t value, uint8_t *buffer) |
Append a value to the buffer - extra. | |
void | DoAddHeader (uint32_t uid, uint32_t size) |
Add an header. | |
uint32_t | GetTotalSize () const |
Get the total size used by the metadata. | |
uint32_t | GetUleb128Size (uint32_t value) const |
Get the ULEB128 (Unsigned Little Endian Base 128) size. | |
bool | IsPointerOk (uint16_t pointer) const |
Check if the position is valid. | |
bool | IsSharedPointerOk (uint16_t pointer) const |
Check if the position is valid. | |
bool | IsStateOk () const |
Check if the metadata state is ok. | |
uint32_t | ReadItems (uint16_t current, PacketMetadata::SmallItem *item, PacketMetadata::ExtraItem *extraItem) const |
Read items. | |
uint32_t | ReadUleb128 (const uint8_t **pBuffer) const |
Read a ULEB128 (Unsigned Little Endian Base 128) coded number. | |
void | ReplaceTail (PacketMetadata::SmallItem *item, PacketMetadata::ExtraItem *extraItem, uint32_t available) |
Replace the tail. | |
void | Reserve (uint32_t n) |
Reserve space. | |
void | ReserveCopy (uint32_t n) |
Reserve space and make a metadata copy. | |
void | UpdateHead (uint16_t written) |
Update the head. | |
void | UpdateTail (uint16_t written) |
Update the tail. | |
Static Private Member Functions | |
static uint8_t * | AddToRaw (const uint8_t *data, uint32_t dataSize, uint8_t *start, uint8_t *current, uint32_t maxSize) |
Helper for the raw serialization. | |
static uint8_t * | AddToRawU16 (const uint16_t &data, uint8_t *start, uint8_t *current, uint32_t maxSize) |
Helper for the raw serialization. | |
static uint8_t * | AddToRawU32 (const uint32_t &data, uint8_t *start, uint8_t *current, uint32_t maxSize) |
Helper for the raw serialization. | |
static uint8_t * | AddToRawU64 (const uint64_t &data, uint8_t *start, uint8_t *current, uint32_t maxSize) |
Helper for the raw serialization. | |
static uint8_t * | AddToRawU8 (const uint8_t &data, uint8_t *start, uint8_t *current, uint32_t maxSize) |
Helper for the raw serialization. | |
static PacketMetadata::Data * | Allocate (uint32_t n) |
Allocate a buffer data storage. | |
static PacketMetadata::Data * | Create (uint32_t size) |
Create a buffer data storage. | |
static void | Deallocate (PacketMetadata::Data *data) |
Deallocate the buffer memory. | |
static uint8_t * | ReadFromRawU16 (uint16_t &data, const uint8_t *start, const uint8_t *current, uint32_t maxSize) |
Helper for the raw deserialization. | |
static uint8_t * | ReadFromRawU32 (uint32_t &data, const uint8_t *start, const uint8_t *current, uint32_t maxSize) |
Helper for the raw deserialization. | |
static uint8_t * | ReadFromRawU64 (uint64_t &data, const uint8_t *start, const uint8_t *current, uint32_t maxSize) |
Helper for the raw deserialization. | |
static uint8_t * | ReadFromRawU8 (uint8_t &data, const uint8_t *start, const uint8_t *current, uint32_t maxSize) |
Helper for the raw deserialization. | |
static void | Recycle (PacketMetadata::Data *data) |
Recycle the buffer memory. | |
Private Attributes | |
Data * | m_data |
Metadata storage. | |
uint16_t | m_head |
list head | |
uint64_t | m_packetUid |
packet Uid | |
uint16_t | m_tail |
list tail | |
uint32_t | m_used |
used portion | |
Static Private Attributes | |
static uint16_t | m_chunkUid = 0 |
Chunk Uid. | |
static bool | m_enable = false |
Enable the packet metadata. | |
static bool | m_enableChecking = false |
Enable the packet metadata checking. | |
static DataFreeList | m_freeList |
the metadata data storage | |
static uint32_t | m_maxSize = 0 |
maximum metadata size | |
static bool | m_metadataSkipped = false |
Set to true when adding metadata to a packet is skipped because m_enable is false; used to detect enabling of metadata in the middle of a simulation, which isn't allowed. | |
Friends | |
class | ItemIterator |
Friend class. | |
Handle packet metadata about packet headers and trailers.
This class is used by the Packet class to record every operation performed on the packet's buffer. This class also provides an implementation of the Packet::Print methods which uses the metadata to analyse the content of the packet's buffer.
To achieve this, this class maintains a linked list of so-called "items", each of which represents a header or a trailer, or payload, or a fragment of any of these. Each item contains a "next" and a "prev" field which point to the next and previous entries in the linked list. The PacketMetadata class maintains a pair of pointers to the head and the tail of the linked list.
Each entry in the list also maintains:
This linked list is flattened in a byte buffer stored in struct PacketMetadata::Data. Each entry of the linked list is identified by an offset which identifies the first byte of the entry from the start of the data buffer. The size of this data buffer is 2^16-1 bytes maximum which somewhat limits the number of entries which can be stored in this linked list but it is quite unlikely to hit this limit in practice.
Each item of the linked list is a variable-sized byte buffer made of a number of fields. Some of these fields are stored as fixed-size 32 bit integers, others as fixed-size 16 bit integers, and some others as variable-size 32-bit integers. The variable-size 32 bit integers are stored using the uleb128 encoding.
Definition at line 69 of file packet-metadata.h.
|
inline |
Constructor.
uid | packet uid |
size | size of the header |
Definition at line 698 of file packet-metadata.h.
References DoAddHeader(), ns3::PacketMetadata::Data::m_data, and m_data.
|
inline |
Copy constructor.
o | the object to copy |
Definition at line 712 of file packet-metadata.h.
References ns3::PacketMetadata::Data::m_count, m_data, and NS_ASSERT.
|
inline |
Definition at line 747 of file packet-metadata.h.
References ns3::PacketMetadata::Data::m_count, m_data, NS_ASSERT, and Recycle().
|
delete |
|
private |
void ns3::PacketMetadata::AddAtEnd | ( | const PacketMetadata & | o | ) |
Add a metadata at the metadata start.
o | the metadata to add |
Definition at line 781 of file packet-metadata.cc.
References AddBig(), ns3::PacketMetadata::SmallItem::chunkUid, ns3::PacketMetadata::ExtraItem::fragmentEnd, ns3::PacketMetadata::ExtraItem::fragmentStart, IsStateOk(), m_enable, m_head, m_metadataSkipped, m_tail, ns3::PacketMetadata::SmallItem::next, NS_ASSERT, NS_LOG_FUNCTION, ns3::PacketMetadata::ExtraItem::packetUid, ReadItems(), ReplaceTail(), ns3::PacketMetadata::SmallItem::size, ns3::PacketMetadata::SmallItem::typeUid, and UpdateTail().
Referenced by ns3::Packet::AddAtEnd().
|
private |
Add a "Big" Item (a SmallItem plus an ExtraItem)
Definition at line 395 of file packet-metadata.cc.
References Append16(), Append32(), AppendValue(), ns3::PacketMetadata::SmallItem::chunkUid, ns3::PacketMetadata::ExtraItem::fragmentEnd, ns3::PacketMetadata::ExtraItem::fragmentStart, GetUleb128Size(), ns3::PacketMetadata::Data::m_count, ns3::PacketMetadata::Data::m_data, m_data, ns3::PacketMetadata::Data::m_dirtyEnd, m_head, ns3::PacketMetadata::Data::m_size, m_used, ns3::PacketMetadata::SmallItem::next, NS_ASSERT, NS_LOG_FUNCTION, ns3::PacketMetadata::ExtraItem::packetUid, ns3::PacketMetadata::SmallItem::prev, prev, ReserveCopy(), ns3::PacketMetadata::SmallItem::size, and ns3::PacketMetadata::SmallItem::typeUid.
Referenced by AddAtEnd(), Deserialize(), RemoveAtEnd(), RemoveAtStart(), and ReplaceTail().
Add an header.
header | header to add |
size | header serialized size |
Definition at line 639 of file packet-metadata.cc.
References DoAddHeader(), ns3::ObjectBase::GetInstanceTypeId(), ns3::TypeId::GetUid(), IsStateOk(), NS_ASSERT, and NS_LOG_FUNCTION.
Referenced by ns3::Packet::AddHeader().
void ns3::PacketMetadata::AddPaddingAtEnd | ( | uint32_t | end | ) |
Add some padding at the end.
end | size of padding |
Definition at line 857 of file packet-metadata.cc.
References m_enable, m_metadataSkipped, and NS_LOG_FUNCTION.
Referenced by ns3::Packet::AddPaddingAtEnd().
|
inlineprivate |
Add a SmallItem.
item | the SmallItem to add |
Definition at line 367 of file packet-metadata.cc.
References Append16(), AppendValue(), ns3::PacketMetadata::SmallItem::chunkUid, GetUleb128Size(), ns3::PacketMetadata::Data::m_count, ns3::PacketMetadata::Data::m_data, m_data, ns3::PacketMetadata::Data::m_dirtyEnd, m_head, ns3::PacketMetadata::Data::m_size, m_used, ns3::PacketMetadata::SmallItem::next, NS_ASSERT, NS_LOG_FUNCTION, ns3::PacketMetadata::SmallItem::prev, ReserveCopy(), ns3::PacketMetadata::SmallItem::size, and ns3::PacketMetadata::SmallItem::typeUid.
Referenced by AddTrailer(), and DoAddHeader().
|
staticprivate |
Helper for the raw serialization.
data | the buffer to write to |
dataSize | the data size to write to |
start | start index |
current | current index |
maxSize | maximum size |
Definition at line 1378 of file packet-metadata.cc.
References data, and NS_LOG_FUNCTION.
Referenced by Serialize().
|
staticprivate |
Helper for the raw serialization.
data | the buffer to write to |
start | start index |
current | current index |
maxSize | maximum size |
Definition at line 1330 of file packet-metadata.cc.
References data, and NS_LOG_FUNCTION.
Referenced by Serialize().
|
staticprivate |
Helper for the raw serialization.
data | the buffer to write to |
start | start index |
current | current index |
maxSize | maximum size |
Definition at line 1346 of file packet-metadata.cc.
References data, and NS_LOG_FUNCTION.
Referenced by Serialize().
|
staticprivate |
Helper for the raw serialization.
data | the buffer to write to |
start | start index |
current | current index |
maxSize | maximum size |
Definition at line 1362 of file packet-metadata.cc.
References data, and NS_LOG_FUNCTION.
Referenced by Serialize().
|
staticprivate |
Helper for the raw serialization.
data | the buffer to write to |
start | start index |
current | current index |
maxSize | maximum size |
Definition at line 1317 of file packet-metadata.cc.
References data, and NS_LOG_FUNCTION.
Referenced by Serialize().
Add a trailer.
trailer | trailer to add |
size | trailer serialized size |
Definition at line 714 of file packet-metadata.cc.
References AddSmall(), ns3::PacketMetadata::SmallItem::chunkUid, ns3::ObjectBase::GetInstanceTypeId(), ns3::TypeId::GetUid(), IsStateOk(), m_chunkUid, m_enable, m_metadataSkipped, m_tail, ns3::PacketMetadata::SmallItem::next, NS_ASSERT, NS_LOG_FUNCTION, ns3::PacketMetadata::SmallItem::prev, ns3::PacketMetadata::SmallItem::size, ns3::PacketMetadata::SmallItem::typeUid, and UpdateTail().
Referenced by ns3::Packet::AddTrailer().
|
staticprivate |
Allocate a buffer data storage.
n | the storage size to create |
Definition at line 603 of file packet-metadata.cc.
References data, NS_LOG_FUNCTION, and PACKET_METADATA_DATA_M_DATA_SIZE.
Referenced by Create().
|
inlineprivate |
Append a 16-bit value to the buffer.
value | the value to add |
buffer | the buffer to write to |
Definition at line 230 of file packet-metadata.cc.
References NS_LOG_FUNCTION.
Referenced by AddBig(), AddSmall(), ReplaceTail(), ReserveCopy(), UpdateHead(), and UpdateTail().
|
inlineprivate |
Append a 32-bit value to the buffer.
value | the value to add |
buffer | the buffer to write to |
Definition at line 239 of file packet-metadata.cc.
References NS_LOG_FUNCTION.
Referenced by AddBig(), and ReplaceTail().
|
inlineprivate |
Append a value to the buffer.
value | the value to add |
buffer | the buffer to write to |
Definition at line 295 of file packet-metadata.cc.
References AppendValueExtra(), and NS_LOG_FUNCTION.
Referenced by AddBig(), AddSmall(), and ReplaceTail().
|
private |
Append a value to the buffer - extra.
This function is called by AppendValue
value | the value to add |
buffer | the buffer to write to |
Definition at line 249 of file packet-metadata.cc.
References NS_LOG_FUNCTION.
Referenced by AppendValue().
PacketMetadata::ItemIterator ns3::PacketMetadata::BeginItem | ( | Buffer | buffer | ) | const |
Initialize the item iterator to the buffer begin.
buffer | buffer to initialize. |
Definition at line 1022 of file packet-metadata.cc.
References ItemIterator, and NS_LOG_FUNCTION.
Referenced by ns3::Packet::BeginItem(), and ns3::Packet::Print().
|
staticprivate |
Create a buffer data storage.
size | the storage size to create |
Definition at line 556 of file packet-metadata.cc.
References Allocate(), data, Deallocate(), m_freeList, m_maxSize, NS_LOG_FUNCTION, and NS_LOG_LOGIC.
Referenced by ReserveCopy().
PacketMetadata ns3::PacketMetadata::CreateFragment | ( | uint32_t | start, |
uint32_t | end ) const |
Creates a fragment.
start | the amount of stuff to remove from the start |
end | the amount of stuff to remove from the end |
Calling this method is equivalent to calling RemoveAtStart (start) and then, RemoveAtEnd (end).
Definition at line 629 of file packet-metadata.cc.
References NS_LOG_FUNCTION, RemoveAtEnd(), and RemoveAtStart().
Referenced by ns3::Packet::CreateFragment().
|
staticprivate |
Deallocate the buffer memory.
data | the buffer data storage |
Definition at line 621 of file packet-metadata.cc.
References data, and NS_LOG_FUNCTION.
Referenced by ns3::PacketMetadata::DataFreeList::~DataFreeList(), Create(), and Recycle().
Deserialization from raw uint8_t*.
buffer | the buffer to deserialize from |
size | the size |
Definition at line 1256 of file packet-metadata.cc.
References AddBig(), ns3::PacketMetadata::SmallItem::chunkUid, ns3::PacketMetadata::ExtraItem::fragmentEnd, ns3::PacketMetadata::ExtraItem::fragmentStart, ns3::TypeId::GetUid(), ns3::TypeId::LookupByName(), m_packetUid, m_tail, NS_ASSERT, NS_LOG_FUNCTION, NS_LOG_LOGIC, ns3::PacketMetadata::ExtraItem::packetUid, ReadFromRawU16(), ReadFromRawU32(), ReadFromRawU64(), ReadFromRawU8(), ns3::PacketMetadata::SmallItem::size, ns3::PacketMetadata::SmallItem::typeUid, and UpdateTail().
Referenced by ns3::Packet::Deserialize().
Add an header.
uid | header's uid to add |
size | header serialized size |
Definition at line 648 of file packet-metadata.cc.
References AddSmall(), ns3::PacketMetadata::SmallItem::chunkUid, m_chunkUid, m_enable, m_head, m_metadataSkipped, ns3::PacketMetadata::SmallItem::next, NS_LOG_FUNCTION, ns3::PacketMetadata::SmallItem::prev, ns3::PacketMetadata::SmallItem::size, ns3::PacketMetadata::SmallItem::typeUid, and UpdateHead().
Referenced by PacketMetadata(), and AddHeader().
|
static |
Enable the packet metadata.
Definition at line 44 of file packet-metadata.cc.
References m_enable, m_metadataSkipped, NS_ASSERT_MSG, and NS_LOG_FUNCTION_NOARGS.
Referenced by ns3::VisualSimulatorImpl::VisualSimulatorImpl(), MeshTest::Configure(), EpcTftClassifierTestCase::DoRun(), PacketMetadataTest::DoRun(), EnableChecking(), and ns3::Packet::EnablePrinting().
|
static |
Enable the packet metadata checking.
Definition at line 58 of file packet-metadata.cc.
References Enable(), m_enableChecking, and NS_LOG_FUNCTION_NOARGS.
Referenced by ns3::Packet::EnableChecking().
uint32_t ns3::PacketMetadata::GetSerializedSize | ( | ) | const |
Get the metadata serialized size.
Definition at line 1105 of file packet-metadata.cc.
References ns3::TypeId::GetName(), m_enable, m_head, m_tail, ns3::PacketMetadata::SmallItem::next, NS_ASSERT, NS_LOG_FUNCTION, ReadItems(), ns3::TypeId::SetUid(), and ns3::PacketMetadata::SmallItem::typeUid.
Referenced by ns3::Packet::GetSerializedSize(), and ns3::Packet::Serialize().
|
private |
Get the total size used by the metadata.
Definition at line 992 of file packet-metadata.cc.
References ns3::PacketMetadata::ExtraItem::fragmentEnd, ns3::PacketMetadata::ExtraItem::fragmentStart, m_head, m_tail, ns3::PacketMetadata::SmallItem::next, NS_ASSERT, NS_LOG_FUNCTION, and ReadItems().
uint64_t ns3::PacketMetadata::GetUid | ( | ) | const |
Get the packet Uid.
Definition at line 1015 of file packet-metadata.cc.
References m_packetUid, and NS_LOG_FUNCTION.
Referenced by ns3::Packet::GetUid().
Get the ULEB128 (Unsigned Little Endian Base 128) size.
value | the value |
Definition at line 157 of file packet-metadata.cc.
References NS_LOG_FUNCTION.
Referenced by AddBig(), AddSmall(), and ReplaceTail().
|
private |
Check if the position is valid.
pointer | the position to check |
Definition at line 117 of file packet-metadata.cc.
References m_used, and NS_LOG_FUNCTION.
Referenced by IsStateOk().
|
private |
Check if the position is valid.
pointer | the position to check |
Definition at line 109 of file packet-metadata.cc.
References m_data, ns3::PacketMetadata::Data::m_size, and NS_LOG_FUNCTION.
Referenced by IsStateOk().
|
private |
Check if the metadata state is ok.
Definition at line 125 of file packet-metadata.cc.
References IsPointerOk(), IsSharedPointerOk(), m_data, m_head, ns3::PacketMetadata::Data::m_size, m_tail, m_used, ns3::PacketMetadata::SmallItem::next, NS_LOG_FUNCTION, ns3::PacketMetadata::SmallItem::prev, and ReadItems().
Referenced by AddAtEnd(), AddHeader(), AddTrailer(), RemoveAtEnd(), RemoveAtStart(), RemoveHeader(), and RemoveTrailer().
|
inline |
Basic assignment.
o | the object to copy |
Definition at line 725 of file packet-metadata.h.
References ns3::PacketMetadata::Data::m_count, m_data, m_head, m_packetUid, m_tail, m_used, NS_ASSERT, and Recycle().
|
staticprivate |
Helper for the raw deserialization.
data | the buffer to read from |
start | start index |
current | current index |
maxSize | maximum size |
Definition at line 1411 of file packet-metadata.cc.
References data, and NS_LOG_FUNCTION.
Referenced by Deserialize().
|
staticprivate |
Helper for the raw deserialization.
data | the buffer to read from |
start | start index |
current | current index |
maxSize | maximum size |
Definition at line 1427 of file packet-metadata.cc.
References data, and NS_LOG_FUNCTION.
Referenced by Deserialize().
|
staticprivate |
Helper for the raw deserialization.
data | the buffer to read from |
start | start index |
current | current index |
maxSize | maximum size |
Definition at line 1443 of file packet-metadata.cc.
References data, and NS_LOG_FUNCTION.
Referenced by Deserialize().
|
staticprivate |
Helper for the raw deserialization.
data | the buffer to read from |
start | start index |
current | current index |
maxSize | maximum size |
Definition at line 1395 of file packet-metadata.cc.
References data, and NS_LOG_FUNCTION.
Referenced by Deserialize().
|
private |
Read items.
current | the offset we should start reading the data from |
item | pointer to where we should store the data to return to the caller |
extraItem | pointer to where we should store the data to return to the caller |
Definition at line 514 of file packet-metadata.cc.
References ns3::PacketMetadata::SmallItem::chunkUid, ns3::PacketMetadata::ExtraItem::fragmentEnd, ns3::PacketMetadata::ExtraItem::fragmentStart, ns3::PacketMetadata::Data::m_data, m_data, m_packetUid, ns3::PacketMetadata::Data::m_size, ns3::PacketMetadata::SmallItem::next, NS_ASSERT, NS_LOG_FUNCTION, ns3::PacketMetadata::ExtraItem::packetUid, ns3::PacketMetadata::SmallItem::prev, ReadUleb128(), ns3::PacketMetadata::SmallItem::size, and ns3::PacketMetadata::SmallItem::typeUid.
Referenced by AddAtEnd(), GetSerializedSize(), GetTotalSize(), IsStateOk(), RemoveAtEnd(), RemoveAtStart(), RemoveHeader(), RemoveTrailer(), ReplaceTail(), and Serialize().
|
private |
Read a ULEB128 (Unsigned Little Endian Base 128) coded number.
pBuffer | the buffer to read from |
Definition at line 180 of file packet-metadata.cc.
References NS_ASSERT, and NS_LOG_FUNCTION.
Referenced by ReadItems().
|
staticprivate |
Recycle the buffer memory.
data | the buffer data storage |
Definition at line 582 of file packet-metadata.cc.
References data, Deallocate(), m_enable, m_freeList, m_maxSize, NS_ASSERT, NS_LOG_FUNCTION, and NS_LOG_LOGIC.
Referenced by ~PacketMetadata(), operator=(), and ReserveCopy().
void ns3::PacketMetadata::RemoveAtEnd | ( | uint32_t | end | ) |
Remove a chunk of metadata at the metadata end.
end | the size of metadata to remove |
Definition at line 929 of file packet-metadata.cc.
References AddBig(), ns3::PacketMetadata::ExtraItem::fragmentEnd, ns3::PacketMetadata::ExtraItem::fragmentStart, IsStateOk(), m_data, m_enable, m_head, m_metadataSkipped, m_packetUid, m_tail, NS_ASSERT, NS_LOG_FUNCTION, ns3::PacketMetadata::SmallItem::prev, ReadItems(), ns3::PacketMetadata::SmallItem::size, and UpdateHead().
Referenced by CreateFragment(), and ns3::Packet::RemoveAtEnd().
void ns3::PacketMetadata::RemoveAtStart | ( | uint32_t | start | ) |
Remove a chunk of metadata at the metadata start.
start | the size of metadata to remove |
Definition at line 868 of file packet-metadata.cc.
References AddBig(), ns3::PacketMetadata::ExtraItem::fragmentEnd, ns3::PacketMetadata::ExtraItem::fragmentStart, IsStateOk(), m_data, m_enable, m_head, m_metadataSkipped, m_packetUid, m_tail, ns3::PacketMetadata::SmallItem::next, NS_ASSERT, NS_LOG_FUNCTION, ReadItems(), ns3::PacketMetadata::SmallItem::size, and UpdateTail().
Referenced by CreateFragment(), and ns3::Packet::RemoveAtStart().
Remove an header.
header | header to remove |
size | header serialized size |
Definition at line 669 of file packet-metadata.cc.
References ns3::PacketMetadata::ExtraItem::fragmentEnd, ns3::PacketMetadata::ExtraItem::fragmentStart, ns3::ObjectBase::GetInstanceTypeId(), ns3::TypeId::GetUid(), IsStateOk(), m_enable, m_enableChecking, m_head, m_metadataSkipped, m_tail, m_used, ns3::PacketMetadata::SmallItem::next, NS_ASSERT, NS_FATAL_ERROR, NS_LOG_FUNCTION, ReadItems(), ns3::PacketMetadata::SmallItem::size, and ns3::PacketMetadata::SmallItem::typeUid.
Referenced by ns3::Packet::RemoveHeader(), and ns3::Packet::RemoveHeader().
Remove a trailer.
trailer | trailer to remove |
size | trailer serialized size |
Definition at line 736 of file packet-metadata.cc.
References ns3::PacketMetadata::ExtraItem::fragmentEnd, ns3::PacketMetadata::ExtraItem::fragmentStart, ns3::ObjectBase::GetInstanceTypeId(), ns3::TypeId::GetUid(), IsStateOk(), m_enable, m_enableChecking, m_head, m_metadataSkipped, m_tail, m_used, NS_ASSERT, NS_FATAL_ERROR, NS_LOG_FUNCTION, ns3::PacketMetadata::SmallItem::prev, ReadItems(), ns3::PacketMetadata::SmallItem::size, and ns3::PacketMetadata::SmallItem::typeUid.
Referenced by ns3::Packet::RemoveTrailer().
|
private |
Replace the tail.
item | the item data to write |
extraItem | the extra item data to write |
available | the number of bytes which can be written without having to rewrite the buffer entirely. |
Definition at line 441 of file packet-metadata.cc.
References AddBig(), Append16(), Append32(), AppendValue(), ns3::PacketMetadata::SmallItem::chunkUid, ns3::PacketMetadata::ExtraItem::fragmentEnd, ns3::PacketMetadata::ExtraItem::fragmentStart, GetUleb128Size(), ns3::PacketMetadata::Data::m_count, ns3::PacketMetadata::Data::m_data, m_data, ns3::PacketMetadata::Data::m_dirtyEnd, m_head, m_packetUid, ns3::PacketMetadata::Data::m_size, m_tail, m_used, ns3::PacketMetadata::SmallItem::next, NS_ASSERT, NS_LOG_FUNCTION, ns3::PacketMetadata::ExtraItem::packetUid, ns3::PacketMetadata::SmallItem::prev, ReadItems(), ns3::PacketMetadata::SmallItem::size, ns3::PacketMetadata::SmallItem::typeUid, and UpdateTail().
Referenced by AddAtEnd().
|
inlineprivate |
Reserve space.
n | space to reserve |
Definition at line 92 of file packet-metadata.cc.
References ns3::PacketMetadata::Data::m_count, m_data, ns3::PacketMetadata::Data::m_dirtyEnd, m_head, ns3::PacketMetadata::Data::m_size, m_used, NS_ASSERT, NS_LOG_FUNCTION, and ReserveCopy().
|
private |
Reserve space and make a metadata copy.
n | space to reserve |
Definition at line 66 of file packet-metadata.cc.
References Append16(), Create(), ns3::PacketMetadata::Data::m_count, ns3::PacketMetadata::Data::m_data, m_data, ns3::PacketMetadata::Data::m_dirtyEnd, m_head, m_tail, m_used, NS_ASSERT, NS_LOG_FUNCTION, and Recycle().
Referenced by AddBig(), AddSmall(), and Reserve().
Serialization to raw uint8_t*.
buffer | the buffer to serialize to |
maxSize | the maximum serialization size |
Definition at line 1150 of file packet-metadata.cc.
References AddToRaw(), AddToRawU16(), AddToRawU32(), AddToRawU64(), AddToRawU8(), ns3::PacketMetadata::SmallItem::chunkUid, ns3::PacketMetadata::ExtraItem::fragmentEnd, ns3::PacketMetadata::ExtraItem::fragmentStart, ns3::TypeId::GetName(), m_head, m_packetUid, m_tail, ns3::PacketMetadata::SmallItem::next, NS_ASSERT, NS_LOG_FUNCTION, NS_LOG_LOGIC, ns3::PacketMetadata::ExtraItem::packetUid, ReadItems(), ns3::TypeId::SetUid(), ns3::PacketMetadata::SmallItem::size, and ns3::PacketMetadata::SmallItem::typeUid.
Referenced by ns3::Packet::Serialize().
|
inlineprivate |
Update the head.
written | the used bytes |
Definition at line 341 of file packet-metadata.cc.
References Append16(), ns3::PacketMetadata::Data::m_data, m_data, ns3::PacketMetadata::Data::m_dirtyEnd, m_head, m_tail, m_used, NS_ASSERT, and NS_LOG_FUNCTION.
Referenced by DoAddHeader(), and RemoveAtEnd().
|
inlineprivate |
Update the tail.
written | the used bytes |
Definition at line 315 of file packet-metadata.cc.
References Append16(), ns3::PacketMetadata::Data::m_data, m_data, ns3::PacketMetadata::Data::m_dirtyEnd, m_head, m_tail, m_used, NS_ASSERT, and NS_LOG_FUNCTION.
Referenced by AddAtEnd(), AddTrailer(), Deserialize(), RemoveAtStart(), and ReplaceTail().
|
friend |
|
staticprivate |
Chunk Uid.
Definition at line 679 of file packet-metadata.h.
Referenced by AddTrailer(), and DoAddHeader().
|
private |
Metadata storage.
Definition at line 681 of file packet-metadata.h.
Referenced by PacketMetadata(), PacketMetadata(), ~PacketMetadata(), AddBig(), AddSmall(), IsSharedPointerOk(), IsStateOk(), operator=(), ReadItems(), RemoveAtEnd(), RemoveAtStart(), ReplaceTail(), Reserve(), ReserveCopy(), UpdateHead(), and UpdateTail().
|
staticprivate |
Enable the packet metadata.
Definition at line 668 of file packet-metadata.h.
Referenced by ns3::PacketMetadata::DataFreeList::~DataFreeList(), AddAtEnd(), AddPaddingAtEnd(), AddTrailer(), DoAddHeader(), Enable(), GetSerializedSize(), Recycle(), RemoveAtEnd(), RemoveAtStart(), RemoveHeader(), and RemoveTrailer().
|
staticprivate |
Enable the packet metadata checking.
Definition at line 669 of file packet-metadata.h.
Referenced by EnableChecking(), RemoveHeader(), and RemoveTrailer().
|
staticprivate |
the metadata data storage
Definition at line 667 of file packet-metadata.h.
|
private |
list head
Definition at line 687 of file packet-metadata.h.
Referenced by AddAtEnd(), AddBig(), AddSmall(), DoAddHeader(), GetSerializedSize(), GetTotalSize(), IsStateOk(), operator=(), RemoveAtEnd(), RemoveAtStart(), RemoveHeader(), RemoveTrailer(), ReplaceTail(), Reserve(), ReserveCopy(), Serialize(), UpdateHead(), and UpdateTail().
|
staticprivate |
maximum metadata size
Definition at line 678 of file packet-metadata.h.
|
staticprivate |
Set to true when adding metadata to a packet is skipped because m_enable is false; used to detect enabling of metadata in the middle of a simulation, which isn't allowed.
Definition at line 676 of file packet-metadata.h.
Referenced by AddAtEnd(), AddPaddingAtEnd(), AddTrailer(), DoAddHeader(), Enable(), RemoveAtEnd(), RemoveAtStart(), RemoveHeader(), and RemoveTrailer().
|
private |
packet Uid
Definition at line 690 of file packet-metadata.h.
Referenced by Deserialize(), GetUid(), operator=(), ReadItems(), RemoveAtEnd(), RemoveAtStart(), ReplaceTail(), and Serialize().
|
private |
list tail
Definition at line 688 of file packet-metadata.h.
Referenced by AddAtEnd(), AddTrailer(), Deserialize(), GetSerializedSize(), GetTotalSize(), IsStateOk(), operator=(), RemoveAtEnd(), RemoveAtStart(), RemoveHeader(), RemoveTrailer(), ReplaceTail(), ReserveCopy(), Serialize(), UpdateHead(), and UpdateTail().
|
private |
used portion
Definition at line 689 of file packet-metadata.h.
Referenced by AddBig(), AddSmall(), IsPointerOk(), IsStateOk(), operator=(), RemoveHeader(), RemoveTrailer(), ReplaceTail(), Reserve(), ReserveCopy(), UpdateHead(), and UpdateTail().