A Discrete-Event Network Simulator
API
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
ns3::ByteTagList Class Reference

keep track of the tags stored in a packet. More...

#include <byte-tag-list.h>

Classes

class  Iterator
 

Public Member Functions

 ByteTagList (const ByteTagList &o)
 
TagBuffer Add (TypeId tid, uint32_t bufferSize, int32_t start, int32_t end)
 
void Add (const ByteTagList &o)
 
void AddAtEnd (int32_t adjustment, int32_t appendOffset)
 
void AddAtStart (int32_t adjustment, int32_t prependOffset)
 
ByteTagList::Iterator Begin (int32_t offsetStart, int32_t offsetEnd) const
 
ByteTagListoperator= (const ByteTagList &o)
 
void RemoveAll (void)
 

Private Member Functions

struct ByteTagListDataAllocate (uint32_t size)
 
ByteTagList::Iterator BeginAll (void) const
 
void Deallocate (struct ByteTagListData *data)
 
bool IsDirtyAtEnd (int32_t appendOffset)
 
bool IsDirtyAtStart (int32_t prependOffset)
 

Private Attributes

struct ByteTagListDatam_data
 
uint16_t m_used
 

Detailed Description

keep track of the tags stored in a packet.

This class is mostly private to the Packet implementation and users should never have to access it directly.

The implementation of this class is a bit tricky so, there are a couple of things to keep in mind here:

  • it stores all tags in a single byte buffer: each tag is stored as 4 32bit integers (TypeId, tag data size, start, end) followed by the tag data as generated by Tag::Serialize.
  • the struct ByteTagListData structure which contains the tag byte buffer is shared and, thus, reference-counted. This data structure is unshared as-needed to emulate COW semantics.
  • each tag tags a unique set of bytes identified by the pair of offsets (start,end). These offsets are provided by Buffer::GetCurrentStartOffset and Buffer::GetCurrentEndOffset which means that they are relative to the start of the 'virtual byte buffer' as explained in the documentation for the ns3::Buffer class. Whenever the origin of the offset of the Buffer instance associated to this ByteTagList instance changes, the Buffer class reports this to its container Packet class as a bool return value in Buffer::AddAtStart and Buffer::AddAtEnd. In both cases, when this happens the Packet class calls ByteTagList::AddAtEnd and ByteTagList::AddAtStart to update the byte offsets of each tag in the ByteTagList.
  • whenever bytes are removed from the packet byte buffer, the ByteTagList offsets are never updated because we rely on the fact that they will be updated in either the next call to Packet::AddHeader or Packet::AddTrailer or when the user iterates the tag list with Packet::GetTagIterator and TagIterator::Next.

Definition at line 68 of file byte-tag-list.h.

Member Function Documentation

TagBuffer ns3::ByteTagList::Add ( TypeId  tid,
uint32_t  bufferSize,
int32_t  start,
int32_t  end 
)
Parameters
tidthe typeid of the tag added
bufferSizethe size of the tag when its serialization will be completed. Typically, the return value of Tag::GetSerializedSize
startoffset which uniquely identifies the first byte tagged by this tag.
endoffset which uniquely identifies the last byte tagged by this tag.
Returns
a buffer which can be used to write the tag data.

Definition at line 167 of file byte-tag-list.cc.

References ns3::TypeId::GetUid(), NS_ASSERT, NS_LOG_FUNCTION, and ns3::TagBuffer::WriteU32().

Referenced by Add(), AddAtEnd(), ns3::Packet::AddAtEnd(), AddAtStart(), and ns3::Packet::AddByteTag().

void ns3::ByteTagList::Add ( const ByteTagList o)
Parameters
othe other list of tags to aggregate.

Aggregate the two lists of tags.

Definition at line 197 of file byte-tag-list.cc.

References Add(), and NS_LOG_FUNCTION.

void ns3::ByteTagList::AddAtEnd ( int32_t  adjustment,
int32_t  appendOffset 
)

Adjust the offsets stored internally by the adjustment delta and make sure that all offsets are smaller than appendOffset which represents the location where new bytes have been added to the byte buffer.

Definition at line 274 of file byte-tag-list.cc.

References Add(), and NS_LOG_FUNCTION.

Referenced by ns3::Packet::AddAtEnd(), ns3::Packet::AddPaddingAtEnd(), and ns3::Packet::AddTrailer().

void ns3::ByteTagList::AddAtStart ( int32_t  adjustment,
int32_t  prependOffset 
)

Adjust the offsets stored internally by the adjustment delta and make sure that all offsets are bigger than prependOffset which represents the location where new bytes have been added to the byte buffer.

Definition at line 308 of file byte-tag-list.cc.

References Add(), and NS_LOG_FUNCTION.

Referenced by ns3::Packet::AddAtEnd(), and ns3::Packet::AddHeader().

ByteTagList::Iterator ns3::ByteTagList::Begin ( int32_t  offsetStart,
int32_t  offsetEnd 
) const
Parameters
offsetStartthe offset which uniquely identifies the first data byte present in the byte buffer associated to this ByteTagList.
offsetEndthe offset which uniquely identifies the last data byte present in the byte buffer associated to this ByteTagList.
Returns
an iterator

The returned iterator will allow you to loop through the set of tags present in this list: the boundaries of each tag as reported by their start and end offsets will be included within the input offsetStart and offsetEnd.

Definition at line 228 of file byte-tag-list.cc.

References NS_LOG_FUNCTION.

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


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