A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
ns3::PacketMetadata Class Reference

Handle packet metadata about packet headers and trailers. More...

#include "packet-metadata.h"

+ Collaboration diagram for ns3::PacketMetadata:

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.
 
PacketMetadataoperator= (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::DataAllocate (uint32_t n)
 Allocate a buffer data storage.
 
static PacketMetadata::DataCreate (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

Datam_data
 Metadata storage.
 
uint16_t m_head
 list head
 
uint64_t m_packetUid
 packet Uid
 
uint16_t m_tail
 list tail
 
uint16_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.
 

Detailed Description

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:

  • its native size (the size it had when it was first added to the packet)
  • its type: identifies what kind of header, what kind of trailer, if it is payload or not
  • the uid of the packet to which it was first added
  • the start and end of the area represented by a fragment if it is one.

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 80 of file packet-metadata.h.

Constructor & Destructor Documentation

◆ PacketMetadata() [1/3]

ns3::PacketMetadata::PacketMetadata ( uint64_t  uid,
uint32_t  size 
)
inline

Constructor.

Parameters
uidpacket uid
sizesize of the header

Definition at line 709 of file packet-metadata.h.

References DoAddHeader(), ns3::PacketMetadata::Data::m_data, and m_data.

+ Here is the call graph for this function:

◆ PacketMetadata() [2/3]

ns3::PacketMetadata::PacketMetadata ( const PacketMetadata o)
inline

Copy constructor.

Parameters
othe object to copy

Definition at line 723 of file packet-metadata.h.

References ns3::PacketMetadata::Data::m_count, m_data, and NS_ASSERT.

◆ ~PacketMetadata()

ns3::PacketMetadata::~PacketMetadata ( )
inline

Definition at line 758 of file packet-metadata.h.

References ns3::PacketMetadata::Data::m_count, m_data, NS_ASSERT, and Recycle().

+ Here is the call graph for this function:

◆ PacketMetadata() [3/3]

ns3::PacketMetadata::PacketMetadata ( )
delete

◆ DataFreeList::~DataFreeList()

Member Function Documentation

◆ AddAtEnd()

void ns3::PacketMetadata::AddAtEnd ( const PacketMetadata o)

◆ AddBig()

◆ AddHeader()

void ns3::PacketMetadata::AddHeader ( const Header header,
uint32_t  size 
)

Add an header.

Parameters
headerheader to add
sizeheader serialized size

Definition at line 650 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().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ AddPaddingAtEnd()

void ns3::PacketMetadata::AddPaddingAtEnd ( uint32_t  end)

Add some padding at the end.

Parameters
endsize of padding

Definition at line 868 of file packet-metadata.cc.

References m_enable, m_metadataSkipped, and NS_LOG_FUNCTION.

Referenced by ns3::Packet::AddPaddingAtEnd().

+ Here is the caller graph for this function:

◆ AddSmall()

◆ AddToRaw()

uint8_t * ns3::PacketMetadata::AddToRaw ( const uint8_t *  data,
uint32_t  dataSize,
uint8_t *  start,
uint8_t *  current,
uint32_t  maxSize 
)
staticprivate

Helper for the raw serialization.

Parameters
datathe buffer to write to
dataSizethe data size to write to
startstart index
currentcurrent index
maxSizemaximum size
Returns
updated current index

Definition at line 1389 of file packet-metadata.cc.

References data, and NS_LOG_FUNCTION.

Referenced by Serialize().

+ Here is the caller graph for this function:

◆ AddToRawU16()

uint8_t * ns3::PacketMetadata::AddToRawU16 ( const uint16_t &  data,
uint8_t *  start,
uint8_t *  current,
uint32_t  maxSize 
)
staticprivate

Helper for the raw serialization.

Parameters
datathe buffer to write to
startstart index
currentcurrent index
maxSizemaximum size
Returns
updated current index

Definition at line 1341 of file packet-metadata.cc.

References data, and NS_LOG_FUNCTION.

Referenced by Serialize().

+ Here is the caller graph for this function:

◆ AddToRawU32()

uint8_t * ns3::PacketMetadata::AddToRawU32 ( const uint32_t data,
uint8_t *  start,
uint8_t *  current,
uint32_t  maxSize 
)
staticprivate

Helper for the raw serialization.

Parameters
datathe buffer to write to
startstart index
currentcurrent index
maxSizemaximum size
Returns
updated current index

Definition at line 1357 of file packet-metadata.cc.

References data, and NS_LOG_FUNCTION.

Referenced by Serialize().

+ Here is the caller graph for this function:

◆ AddToRawU64()

uint8_t * ns3::PacketMetadata::AddToRawU64 ( const uint64_t &  data,
uint8_t *  start,
uint8_t *  current,
uint32_t  maxSize 
)
staticprivate

Helper for the raw serialization.

Parameters
datathe buffer to write to
startstart index
currentcurrent index
maxSizemaximum size
Returns
updated current index

Definition at line 1373 of file packet-metadata.cc.

References data, and NS_LOG_FUNCTION.

Referenced by Serialize().

+ Here is the caller graph for this function:

◆ AddToRawU8()

uint8_t * ns3::PacketMetadata::AddToRawU8 ( const uint8_t &  data,
uint8_t *  start,
uint8_t *  current,
uint32_t  maxSize 
)
staticprivate

Helper for the raw serialization.

Parameters
datathe buffer to write to
startstart index
currentcurrent index
maxSizemaximum size
Returns
updated current index

Definition at line 1328 of file packet-metadata.cc.

References data, and NS_LOG_FUNCTION.

Referenced by Serialize().

+ Here is the caller graph for this function:

◆ AddTrailer()

void ns3::PacketMetadata::AddTrailer ( const Trailer trailer,
uint32_t  size 
)

◆ Allocate()

PacketMetadata::Data * ns3::PacketMetadata::Allocate ( uint32_t  n)
staticprivate

Allocate a buffer data storage.

Parameters
nthe storage size to create
Returns
a pointer to the allocated buffer storage

Definition at line 614 of file packet-metadata.cc.

References data, NS_LOG_FUNCTION, and PACKET_METADATA_DATA_M_DATA_SIZE.

Referenced by Create().

+ Here is the caller graph for this function:

◆ Append16()

void ns3::PacketMetadata::Append16 ( uint16_t  value,
uint8_t *  buffer 
)
inlineprivate

Append a 16-bit value to the buffer.

Parameters
valuethe value to add
bufferthe buffer to write to

Definition at line 241 of file packet-metadata.cc.

References NS_LOG_FUNCTION.

Referenced by AddBig(), AddSmall(), ReplaceTail(), ReserveCopy(), UpdateHead(), and UpdateTail().

+ Here is the caller graph for this function:

◆ Append32()

void ns3::PacketMetadata::Append32 ( uint32_t  value,
uint8_t *  buffer 
)
inlineprivate

Append a 32-bit value to the buffer.

Parameters
valuethe value to add
bufferthe buffer to write to

Definition at line 250 of file packet-metadata.cc.

References NS_LOG_FUNCTION.

Referenced by AddBig(), and ReplaceTail().

+ Here is the caller graph for this function:

◆ AppendValue()

void ns3::PacketMetadata::AppendValue ( uint32_t  value,
uint8_t *  buffer 
)
inlineprivate

Append a value to the buffer.

Parameters
valuethe value to add
bufferthe buffer to write to

Definition at line 306 of file packet-metadata.cc.

References AppendValueExtra(), and NS_LOG_FUNCTION.

Referenced by AddBig(), AddSmall(), and ReplaceTail().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ AppendValueExtra()

void ns3::PacketMetadata::AppendValueExtra ( uint32_t  value,
uint8_t *  buffer 
)
private

Append a value to the buffer - extra.

This function is called by AppendValue

Parameters
valuethe value to add
bufferthe buffer to write to

Definition at line 260 of file packet-metadata.cc.

References NS_LOG_FUNCTION.

Referenced by AppendValue().

+ Here is the caller graph for this function:

◆ BeginItem()

PacketMetadata::ItemIterator ns3::PacketMetadata::BeginItem ( Buffer  buffer) const

Initialize the item iterator to the buffer begin.

Parameters
bufferbuffer to initialize.
Returns
the buffer iterator.

Definition at line 1033 of file packet-metadata.cc.

References NS_LOG_FUNCTION.

Referenced by ns3::Packet::BeginItem(), and ns3::Packet::Print().

+ Here is the caller graph for this function:

◆ Create()

PacketMetadata::Data * ns3::PacketMetadata::Create ( uint32_t  size)
staticprivate

Create a buffer data storage.

Parameters
sizethe storage size to create
Returns
a pointer to the created buffer storage

Definition at line 567 of file packet-metadata.cc.

References Allocate(), data, Deallocate(), m_freeList, m_maxSize, NS_LOG_FUNCTION, and NS_LOG_LOGIC.

Referenced by ReserveCopy().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ CreateFragment()

PacketMetadata ns3::PacketMetadata::CreateFragment ( uint32_t  start,
uint32_t  end 
) const

Creates a fragment.

Parameters
startthe amount of stuff to remove from the start
endthe amount of stuff to remove from the end
Returns
the fragment's metadata

Calling this method is equivalent to calling RemoveAtStart (start) and then, RemoveAtEnd (end).

Definition at line 640 of file packet-metadata.cc.

References NS_LOG_FUNCTION, RemoveAtEnd(), and RemoveAtStart().

Referenced by ns3::Packet::CreateFragment().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ Deallocate()

void ns3::PacketMetadata::Deallocate ( PacketMetadata::Data data)
staticprivate

Deallocate the buffer memory.

Parameters
datathe buffer data storage

Definition at line 632 of file packet-metadata.cc.

References data, and NS_LOG_FUNCTION.

Referenced by ns3::PacketMetadata::DataFreeList::~DataFreeList(), Create(), and Recycle().

+ Here is the caller graph for this function:

◆ Deserialize()

uint32_t ns3::PacketMetadata::Deserialize ( const uint8_t *  buffer,
uint32_t  size 
)

◆ DoAddHeader()

void ns3::PacketMetadata::DoAddHeader ( uint32_t  uid,
uint32_t  size 
)
private

Add an header.

Parameters
uidheader's uid to add
sizeheader serialized size

Definition at line 659 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().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ Enable()

void ns3::PacketMetadata::Enable ( )
static

◆ EnableChecking()

void ns3::PacketMetadata::EnableChecking ( )
static

Enable the packet metadata checking.

Definition at line 69 of file packet-metadata.cc.

References Enable(), m_enableChecking, and NS_LOG_FUNCTION_NOARGS.

Referenced by ns3::Packet::EnableChecking().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ GetSerializedSize()

uint32_t ns3::PacketMetadata::GetSerializedSize ( ) const

Get the metadata serialized size.

Returns
the serialized size

Definition at line 1116 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().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ GetTotalSize()

uint32_t ns3::PacketMetadata::GetTotalSize ( ) const
private

Get the total size used by the metadata.

Returns
the metadata used size

Definition at line 1003 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().

+ Here is the call graph for this function:

◆ GetUid()

uint64_t ns3::PacketMetadata::GetUid ( ) const

Get the packet Uid.

Returns
the packet Uid

Definition at line 1026 of file packet-metadata.cc.

References m_packetUid, and NS_LOG_FUNCTION.

Referenced by ns3::Packet::GetUid().

+ Here is the caller graph for this function:

◆ GetUleb128Size()

uint32_t ns3::PacketMetadata::GetUleb128Size ( uint32_t  value) const
inlineprivate

Get the ULEB128 (Unsigned Little Endian Base 128) size.

Parameters
valuethe value
Returns
the value's ULEB128 size

Definition at line 168 of file packet-metadata.cc.

References NS_LOG_FUNCTION.

Referenced by AddBig(), AddSmall(), and ReplaceTail().

+ Here is the caller graph for this function:

◆ IsPointerOk()

bool ns3::PacketMetadata::IsPointerOk ( uint16_t  pointer) const
private

Check if the position is valid.

Parameters
pointerthe position to check
Returns
true if the position is valid

Definition at line 128 of file packet-metadata.cc.

References m_used, and NS_LOG_FUNCTION.

Referenced by IsStateOk().

+ Here is the caller graph for this function:

◆ IsSharedPointerOk()

bool ns3::PacketMetadata::IsSharedPointerOk ( uint16_t  pointer) const
private

Check if the position is valid.

Parameters
pointerthe position to check
Returns
true if the position is valid

Definition at line 120 of file packet-metadata.cc.

References m_data, ns3::PacketMetadata::Data::m_size, and NS_LOG_FUNCTION.

Referenced by IsStateOk().

+ Here is the caller graph for this function:

◆ IsStateOk()

bool ns3::PacketMetadata::IsStateOk ( ) const
private

Check if the metadata state is ok.

Returns
true if the internal state is ok

Definition at line 136 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().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ operator=()

PacketMetadata & ns3::PacketMetadata::operator= ( const PacketMetadata o)
inline

Basic assignment.

Parameters
othe object to copy
Returns
a copied object

Definition at line 736 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().

+ Here is the call graph for this function:

◆ ReadFromRawU16()

uint8_t * ns3::PacketMetadata::ReadFromRawU16 ( uint16_t &  data,
const uint8_t *  start,
const uint8_t *  current,
uint32_t  maxSize 
)
staticprivate

Helper for the raw deserialization.

Parameters
datathe buffer to read from
startstart index
currentcurrent index
maxSizemaximum size
Returns
updated current index

Definition at line 1422 of file packet-metadata.cc.

References data, and NS_LOG_FUNCTION.

Referenced by Deserialize().

+ Here is the caller graph for this function:

◆ ReadFromRawU32()

uint8_t * ns3::PacketMetadata::ReadFromRawU32 ( uint32_t data,
const uint8_t *  start,
const uint8_t *  current,
uint32_t  maxSize 
)
staticprivate

Helper for the raw deserialization.

Parameters
datathe buffer to read from
startstart index
currentcurrent index
maxSizemaximum size
Returns
updated current index

Definition at line 1438 of file packet-metadata.cc.

References data, and NS_LOG_FUNCTION.

Referenced by Deserialize().

+ Here is the caller graph for this function:

◆ ReadFromRawU64()

uint8_t * ns3::PacketMetadata::ReadFromRawU64 ( uint64_t &  data,
const uint8_t *  start,
const uint8_t *  current,
uint32_t  maxSize 
)
staticprivate

Helper for the raw deserialization.

Parameters
datathe buffer to read from
startstart index
currentcurrent index
maxSizemaximum size
Returns
updated current index

Definition at line 1454 of file packet-metadata.cc.

References data, and NS_LOG_FUNCTION.

Referenced by Deserialize().

+ Here is the caller graph for this function:

◆ ReadFromRawU8()

uint8_t * ns3::PacketMetadata::ReadFromRawU8 ( uint8_t &  data,
const uint8_t *  start,
const uint8_t *  current,
uint32_t  maxSize 
)
staticprivate

Helper for the raw deserialization.

Parameters
datathe buffer to read from
startstart index
currentcurrent index
maxSizemaximum size
Returns
updated current index

Definition at line 1406 of file packet-metadata.cc.

References data, and NS_LOG_FUNCTION.

Referenced by Deserialize().

+ Here is the caller graph for this function:

◆ ReadItems()

uint32_t ns3::PacketMetadata::ReadItems ( uint16_t  current,
PacketMetadata::SmallItem item,
PacketMetadata::ExtraItem extraItem 
) const
private

Read items.

Parameters
currentthe offset we should start reading the data from
itempointer to where we should store the data to return to the caller
extraItempointer to where we should store the data to return to the caller
Returns
the number of bytes read.

Definition at line 525 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().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ ReadUleb128()

uint32_t ns3::PacketMetadata::ReadUleb128 ( const uint8_t **  pBuffer) const
private

Read a ULEB128 (Unsigned Little Endian Base 128) coded number.

Parameters
pBufferthe buffer to read from
Returns
the value

Definition at line 191 of file packet-metadata.cc.

References NS_ASSERT, and NS_LOG_FUNCTION.

Referenced by ReadItems().

+ Here is the caller graph for this function:

◆ Recycle()

void ns3::PacketMetadata::Recycle ( PacketMetadata::Data data)
staticprivate

Recycle the buffer memory.

Parameters
datathe buffer data storage

Definition at line 593 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().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ RemoveAtEnd()

void ns3::PacketMetadata::RemoveAtEnd ( uint32_t  end)

Remove a chunk of metadata at the metadata end.

Parameters
endthe size of metadata to remove

Definition at line 940 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().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ RemoveAtStart()

void ns3::PacketMetadata::RemoveAtStart ( uint32_t  start)

Remove a chunk of metadata at the metadata start.

Parameters
startthe size of metadata to remove

Definition at line 879 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().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ RemoveHeader()

void ns3::PacketMetadata::RemoveHeader ( const Header header,
uint32_t  size 
)

◆ RemoveTrailer()

void ns3::PacketMetadata::RemoveTrailer ( const Trailer trailer,
uint32_t  size 
)

◆ ReplaceTail()

void ns3::PacketMetadata::ReplaceTail ( PacketMetadata::SmallItem item,
PacketMetadata::ExtraItem extraItem,
uint32_t  available 
)
private

◆ Reserve()

void ns3::PacketMetadata::Reserve ( uint32_t  n)
inlineprivate

Reserve space.

Parameters
nspace to reserve

Definition at line 103 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().

+ Here is the call graph for this function:

◆ ReserveCopy()

void ns3::PacketMetadata::ReserveCopy ( uint32_t  n)
private

Reserve space and make a metadata copy.

Parameters
nspace to reserve

Definition at line 77 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().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ Serialize()

uint32_t ns3::PacketMetadata::Serialize ( uint8_t *  buffer,
uint32_t  maxSize 
) const

Serialization to raw uint8_t*.

Parameters
bufferthe buffer to serialize to
maxSizethe maximum serialization size
Returns
1 on success, 0 on failure

Definition at line 1161 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().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ UpdateHead()

void ns3::PacketMetadata::UpdateHead ( uint16_t  written)
inlineprivate

Update the head.

Parameters
writtenthe used bytes

Definition at line 352 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().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ UpdateTail()

void ns3::PacketMetadata::UpdateTail ( uint16_t  written)
inlineprivate

Update the tail.

Parameters
writtenthe used bytes

Definition at line 326 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().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Friends And Related Function Documentation

◆ ItemIterator

friend class ItemIterator
friend

Friend class.

Definition at line 523 of file packet-metadata.h.

Member Data Documentation

◆ m_chunkUid

uint16_t ns3::PacketMetadata::m_chunkUid = 0
staticprivate

Chunk Uid.

Definition at line 690 of file packet-metadata.h.

Referenced by AddTrailer(), and DoAddHeader().

◆ m_data

◆ m_enable

bool ns3::PacketMetadata::m_enable = false
staticprivate

◆ m_enableChecking

bool ns3::PacketMetadata::m_enableChecking = false
staticprivate

Enable the packet metadata checking.

Definition at line 680 of file packet-metadata.h.

Referenced by EnableChecking(), RemoveHeader(), and RemoveTrailer().

◆ m_freeList

PacketMetadata::DataFreeList ns3::PacketMetadata::m_freeList
staticprivate

the metadata data storage

Definition at line 678 of file packet-metadata.h.

Referenced by Create(), and Recycle().

◆ m_head

◆ m_maxSize

uint32_t ns3::PacketMetadata::m_maxSize = 0
staticprivate

maximum metadata size

Definition at line 689 of file packet-metadata.h.

Referenced by Create(), and Recycle().

◆ m_metadataSkipped

bool ns3::PacketMetadata::m_metadataSkipped = false
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 687 of file packet-metadata.h.

Referenced by AddAtEnd(), AddPaddingAtEnd(), AddTrailer(), DoAddHeader(), Enable(), RemoveAtEnd(), RemoveAtStart(), RemoveHeader(), and RemoveTrailer().

◆ m_packetUid

uint64_t ns3::PacketMetadata::m_packetUid
private

◆ m_tail

◆ m_used

uint16_t ns3::PacketMetadata::m_used
private

The documentation for this class was generated from the following files: