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

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

#include <byte-tag-list.h>

+ Collaboration diagram for ns3::ByteTagList:

Classes

class  Iterator
 An iterator for iterating through a byte tag list. More...
 

Public Member Functions

 ByteTagList ()
 
 ByteTagList (const ByteTagList &o)
 Copy constructor, copies the data and increases reference count. More...
 
 ~ByteTagList ()
 
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)
 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. More...
 
void 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. More...
 
ByteTagList::Iterator Begin (int32_t offsetStart, int32_t offsetEnd) const
 
ByteTagListoperator= (const ByteTagList &o)
 Assignment operator, deallocates current data and assigns value of passed in ByteTagList. More...
 
void RemoveAll (void)
 Removes all of the tags from the ByteTagList. More...
 

Private Member Functions

struct ByteTagListDataAllocate (uint32_t size)
 Allocate the memory for the ByteTagListData. More...
 
ByteTagList::Iterator BeginAll (void) const
 Returns an iterator pointing to the very first tag in this list. More...
 
void Deallocate (struct ByteTagListData *data)
 Deallocates a ByteTagListData. More...
 
bool IsDirtyAtEnd (int32_t appendOffset)
 Check that all offsets are smaller than appendOffset. More...
 
bool IsDirtyAtStart (int32_t prependOffset)
 Check that all offsets are bigger than prependOffset. More...
 

Private Attributes

struct ByteTagListDatam_data
 the ByteTagListData structure More...
 
uint16_t m_used
 the number of used bytes in the buffer More...
 

Detailed Description

keep track of the byte tags stored in a packet.

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

Internal:
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.

Constructor & Destructor Documentation

ns3::ByteTagList::ByteTagList ( )

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

References NS_LOG_FUNCTION.

ns3::ByteTagList::ByteTagList ( const ByteTagList o)

Copy constructor, copies the data and increases reference count.

Parameters
oThe ByteTagList to copy
Returns
The newly created ByteTagList

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

References ns3::ByteTagListData::count, m_data, and NS_LOG_FUNCTION.

ns3::ByteTagList::~ByteTagList ( )

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

References Deallocate(), m_data, m_used, and NS_LOG_FUNCTION.

+ Here is the call graph for this function:

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 181 of file byte-tag-list.cc.

References Allocate(), ns3::ByteTagListData::count, ns3::ByteTagListData::data, Deallocate(), ns3::ByteTagListData::dirty, ns3::TypeId::GetUid(), m_data, m_used, NS_ASSERT, NS_LOG_FUNCTION, ns3::ByteTagListData::size, and ns3::TagBuffer::WriteU32().

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

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void ns3::ByteTagList::Add ( const ByteTagList o)
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.

Parameters
adjustmentvalue to change stored offsets by
appendOffsetmaximum offset value

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

References Add(), BeginAll(), ns3::ByteTagList::Iterator::Item::buf, ns3::TagBuffer::CopyFrom(), ns3::ByteTagList::Iterator::Item::end, ns3::ByteTagList::Iterator::HasNext(), IsDirtyAtEnd(), list, ns3::ByteTagList::Iterator::Next(), NS_LOG_FUNCTION, ns3::ByteTagList::Iterator::Item::size, ns3::ByteTagList::Iterator::Item::start, and ns3::ByteTagList::Iterator::Item::tid.

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

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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.

Parameters
adjustmentvalue to change stored offsets byte
prependOffsetminimum offset value

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

References Add(), BeginAll(), ns3::ByteTagList::Iterator::Item::buf, ns3::TagBuffer::CopyFrom(), ns3::ByteTagList::Iterator::Item::end, ns3::ByteTagList::Iterator::HasNext(), IsDirtyAtStart(), list, ns3::ByteTagList::Iterator::Next(), NS_LOG_FUNCTION, ns3::ByteTagList::Iterator::Item::size, ns3::ByteTagList::Iterator::Item::start, and ns3::ByteTagList::Iterator::Item::tid.

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

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

struct ByteTagListData * ns3::ByteTagList::Allocate ( uint32_t  size)
private

Allocate the memory for the ByteTagListData.

Parameters
sizethe memory to allocate
Returns
the ByteTagListData structure

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

References ns3::ByteTagListData::count, data, ns3::ByteTagListData::dirty, ns3::g_freeList, ns3::g_maxSize, NS_ASSERT, NS_LOG_FUNCTION, and ns3::ByteTagListData::size.

Referenced by Add().

+ Here is the caller graph for this function:

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 242 of file byte-tag-list.cc.

References ns3::ByteTagListData::data, m_data, m_used, and NS_LOG_FUNCTION.

Referenced by BeginAll(), and ns3::Packet::GetByteTagIterator().

+ Here is the caller graph for this function:

ByteTagList::Iterator ns3::ByteTagList::BeginAll ( void  ) const
private

Returns an iterator pointing to the very first tag in this list.

Returns
an iterator

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

References Begin(), NS_LOG_FUNCTION, and OFFSET_MAX.

Referenced by Add(), AddAtEnd(), AddAtStart(), IsDirtyAtEnd(), and IsDirtyAtStart().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void ns3::ByteTagList::Deallocate ( struct ByteTagListData data)
private

Deallocates a ByteTagListData.

Parameters
datathe ByteTagListData to deallocate

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

References ns3::ByteTagListData::count, FREE_LIST_SIZE, ns3::g_freeList, ns3::g_maxSize, NS_LOG_FUNCTION, and ns3::ByteTagListData::size.

Referenced by Add(), operator=(), RemoveAll(), and ~ByteTagList().

+ Here is the caller graph for this function:

bool ns3::ByteTagList::IsDirtyAtEnd ( int32_t  appendOffset)
private

Check that all offsets are smaller than appendOffset.

Parameters
appendOffsetthe append offset to check
Returns
true if the check is false

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

References BeginAll(), ns3::ByteTagList::Iterator::Item::end, ns3::ByteTagList::Iterator::HasNext(), ns3::ByteTagList::Iterator::Next(), and NS_LOG_FUNCTION.

Referenced by AddAtEnd().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

bool ns3::ByteTagList::IsDirtyAtStart ( int32_t  prependOffset)
private

Check that all offsets are bigger than prependOffset.

Parameters
prependOffsetthe prepend offset to check
Returns
true if the check is false

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

References BeginAll(), ns3::ByteTagList::Iterator::HasNext(), ns3::ByteTagList::Iterator::Next(), NS_LOG_FUNCTION, and ns3::ByteTagList::Iterator::Item::start.

Referenced by AddAtStart().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ByteTagList & ns3::ByteTagList::operator= ( const ByteTagList o)

Assignment operator, deallocates current data and assigns value of passed in ByteTagList.

Also increases reference count

Parameters
oreference to the ByteTagList to copy
Returns
reference to the assignee

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

References ns3::ByteTagListData::count, Deallocate(), m_data, and m_used.

+ Here is the call graph for this function:

void ns3::ByteTagList::RemoveAll ( void  )

Removes all of the tags from the ByteTagList.

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

References Deallocate(), m_data, m_used, and NS_LOG_FUNCTION.

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

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Member Data Documentation

struct ByteTagListData* ns3::ByteTagList::m_data
private

the ByteTagListData structure

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

Referenced by Add(), Begin(), ByteTagList(), operator=(), RemoveAll(), and ~ByteTagList().

uint16_t ns3::ByteTagList::m_used
private

the number of used bytes in the buffer

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

Referenced by Add(), Begin(), operator=(), RemoveAll(), and ~ByteTagList().


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