A Discrete-Event Network Simulator
API
Public Member Functions | Private Attributes | List of all members
ns3::TagBuffer Class Reference

read and write tag data More...

#include "tag-buffer.h"

Public Member Functions

 TagBuffer (uint8_t *start, uint8_t *end)
 Constructor. More...
 
void CopyFrom (TagBuffer o)
 Copy the nternal structure of another TagBuffer. More...
 
void Read (uint8_t *buffer, uint32_t size)
 
double ReadDouble (void)
 
TAG_BUFFER_INLINE uint16_t ReadU16 (void)
 
TAG_BUFFER_INLINE uint32_t ReadU32 (void)
 
uint64_t ReadU64 (void)
 
TAG_BUFFER_INLINE uint8_t ReadU8 (void)
 
void TrimAtEnd (uint32_t trim)
 Trim some space from the end. More...
 
void Write (const uint8_t *buffer, uint32_t size)
 
void WriteDouble (double v)
 
TAG_BUFFER_INLINE void WriteU16 (uint16_t v)
 
TAG_BUFFER_INLINE void WriteU32 (uint32_t v)
 
void WriteU64 (uint64_t v)
 
TAG_BUFFER_INLINE void WriteU8 (uint8_t v)
 

Private Attributes

uint8_t * m_current
 current TagBuffer position More...
 
uint8_t * m_end
 end TagBuffer position More...
 

Detailed Description

read and write tag data

This class allows subclasses of the ns3::Tag base class to serialize and deserialize their data through a stream-like API. This class keeps track of the "current" point in the buffer and advances that "current" point every time data is written. The in-memory format of the data written by this class is unspecified.

If the user attempts to write more data in the buffer than he allocated with Tag::GetSerializedSize, he will trigger an NS_ASSERT error.

Definition at line 51 of file tag-buffer.h.

Constructor & Destructor Documentation

◆ TagBuffer()

ns3::TagBuffer::TagBuffer ( uint8_t *  start,
uint8_t *  end 
)

Constructor.

Parameters
startstart position
endend position

Definition at line 183 of file tag-buffer.cc.

References NS_LOG_FUNCTION, and visualizer.core::start().

Member Function Documentation

◆ CopyFrom()

void ns3::TagBuffer::CopyFrom ( TagBuffer  o)

Copy the nternal structure of another TagBuffer.

Parameters
othe TagBuffer to copy from

Definition at line 199 of file tag-buffer.cc.

References m_current, m_end, NS_ASSERT, and NS_LOG_FUNCTION.

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

◆ Read()

void ns3::TagBuffer::Read ( uint8_t *  buffer,
uint32_t  size 
)

◆ ReadDouble()

double ns3::TagBuffer::ReadDouble ( void  )
Returns
the value read

Read a double, advance the "current" point by the size of the data read, and, return the value read.

Definition at line 164 of file tag-buffer.cc.

References NS_LOG_FUNCTION, and ReadU8().

Referenced by ns3::SnrTag::Deserialize().

◆ ReadU16()

uint16_t ns3::TagBuffer::ReadU16 ( void  )
Returns
the value read

Read two bytes, advance the "current" point by two, and return the value read.

Definition at line 205 of file tag-buffer.h.

References data, and ReadU8().

Referenced by ns3::SimpleTag::Deserialize(), ns3::LtePhyTag::Deserialize(), ns3::EpsBearerTag::Deserialize(), ns3::WifiPhyTag::Deserialize(), and ns3::LteRadioBearerTag::Deserialize().

◆ ReadU32()

uint32_t ns3::TagBuffer::ReadU32 ( void  )

◆ ReadU64()

uint64_t ns3::TagBuffer::ReadU64 ( void  )
Returns
the value read

Read eight bytes, advance the "current" point by eight, and return the value read.

Definition at line 134 of file tag-buffer.cc.

References data, NS_LOG_FUNCTION, and ReadU8().

Referenced by ns3::DelayJitterEstimationTimestampTag::Deserialize(), IPv4TestTag::Deserialize(), IPv6TestTag::Deserialize(), and ns3::AnimByteTag::Deserialize().

◆ ReadU8()

uint8_t ns3::TagBuffer::ReadU8 ( void  )

◆ TrimAtEnd()

void ns3::TagBuffer::TrimAtEnd ( uint32_t  trim)

Trim some space from the end.

Parameters
trimspace to remove

Definition at line 191 of file tag-buffer.cc.

References m_current, m_end, NS_ASSERT, and NS_LOG_FUNCTION.

Referenced by ns3::ByteTagList::Iterator::Next().

◆ Write()

void ns3::TagBuffer::Write ( const uint8_t *  buffer,
uint32_t  size 
)

◆ WriteDouble()

void ns3::TagBuffer::WriteDouble ( double  v)
Parameters
vthe value to write

Write a double and advance the "current" point by the size of the data written.

Definition at line 115 of file tag-buffer.cc.

References NS_LOG_FUNCTION, and WriteU8().

Referenced by ns3::SnrTag::Serialize().

◆ WriteU16()

void ns3::TagBuffer::WriteU16 ( uint16_t  v)
Parameters
vthe value to write

Write two bytes and advance the "current" point by two.

Definition at line 180 of file tag-buffer.h.

References data, and WriteU8().

Referenced by ns3::SimpleTag::Serialize(), ns3::LtePhyTag::Serialize(), ns3::EpsBearerTag::Serialize(), ns3::WifiPhyTag::Serialize(), and ns3::LteRadioBearerTag::Serialize().

◆ WriteU32()

void ns3::TagBuffer::WriteU32 ( uint32_t  v)

◆ WriteU64()

void ns3::TagBuffer::WriteU64 ( uint64_t  v)
Parameters
vthe value to write

Write eight bytes and advance the "current" point by eight.

Definition at line 102 of file tag-buffer.cc.

References data, NS_LOG_FUNCTION, and WriteU8().

Referenced by ns3::DelayJitterEstimationTimestampTag::Serialize(), IPv4TestTag::Serialize(), IPv6TestTag::Serialize(), and ns3::AnimByteTag::Serialize().

◆ WriteU8()

void ns3::TagBuffer::WriteU8 ( uint8_t  v)

Member Data Documentation

◆ m_current

uint8_t* ns3::TagBuffer::m_current
private

current TagBuffer position

Definition at line 159 of file tag-buffer.h.

Referenced by CopyFrom(), Read(), ReadU8(), TrimAtEnd(), and WriteU8().

◆ m_end

uint8_t* ns3::TagBuffer::m_end
private

end TagBuffer position

Definition at line 160 of file tag-buffer.h.

Referenced by CopyFrom(), Read(), ReadU8(), TrimAtEnd(), and WriteU8().


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