ns-3
|
automatically resized byte buffer More...
#include <buffer.h>
Classes | |
struct | Data |
class | Iterator |
iterator in a Buffer instance More... |
Public Member Functions | |
uint32_t | GetSize (void) const |
uint8_t const * | PeekData (void) const |
bool | AddAtStart (uint32_t start) |
bool | AddAtEnd (uint32_t end) |
void | AddAtEnd (const Buffer &o) |
void | RemoveAtStart (uint32_t start) |
void | RemoveAtEnd (uint32_t end) |
Buffer | CreateFragment (uint32_t start, uint32_t length) const |
Buffer::Iterator | Begin (void) const |
Buffer::Iterator | End (void) const |
Buffer | CreateFullCopy (void) const |
uint32_t | GetSerializedSize (void) const |
uint32_t | Serialize (uint8_t *buffer, uint32_t maxSize) const |
uint32_t | Deserialize (const uint8_t *buffer, uint32_t size) |
int32_t | GetCurrentStartOffset (void) const |
int32_t | GetCurrentEndOffset (void) const |
void | CopyData (std::ostream *os, uint32_t size) const |
uint32_t | CopyData (uint8_t *buffer, uint32_t size) const |
Buffer (Buffer const &o) | |
Buffer & | operator= (Buffer const &o) |
Buffer (uint32_t dataSize) | |
Buffer (uint32_t dataSize, bool initialize) |
automatically resized byte buffer
This represents a buffer of bytes. Its size is automatically adjusted to hold any data prepended or appended by the user. Its implementation is optimized to ensure that the number of buffer resizes is minimized, by creating new Buffers of the maximum size ever used. The correct maximum size is learned at runtime during use by recording the maximum size of each packet.
bool ns3::Buffer::AddAtEnd | ( | uint32_t | end | ) |
end | size to reserve |
Add bytes at the end of the Buffer. The content of these bytes is undefined but debugging builds initialize them to 0x33. Any call to this method invalidates any Iterator pointing to this Buffer.
References NS_ASSERT, and NS_LOG_FUNCTION.
Referenced by ns3::Packet::AddAtEnd(), AddAtEnd(), ns3::dsr::DsrOptionField::AddDsrOption(), ns3::OptionField::AddOption(), ns3::Packet::AddPaddingAtEnd(), ns3::Packet::AddTrailer(), ns3::Ipv6ExtensionHeader::Deserialize(), ns3::dsr::DsrOptionHeader::Deserialize(), ns3::Ipv6OptionHeader::Deserialize(), ns3::dsr::DsrFsHeader::Deserialize(), ns3::OptionField::Deserialize(), ns3::dsr::DsrOptionField::Deserialize(), Deserialize(), ns3::dsr::DsrOptionRerrHeader::Deserialize(), and ns3::WifiInformationElement::operator==().
void ns3::Buffer::AddAtEnd | ( | const Buffer & | o | ) |
o | the buffer to append to the end of this buffer. |
Add bytes at the end of the Buffer. Any call to this method invalidates any Iterator pointing to this Buffer.
This is an optimization which kicks in when we attempt to aggregate two buffers which contain adjacent zero areas.
References AddAtEnd(), Begin(), End(), GetSize(), NS_ASSERT, NS_LOG_FUNCTION, ns3::Buffer::Iterator::Prev(), and ns3::Buffer::Iterator::Write().
bool ns3::Buffer::AddAtStart | ( | uint32_t | start | ) |
start | size to reserve |
Add bytes at the start of the Buffer. The content of these bytes is undefined but debugging builds initialize them to 0x33. Any call to this method invalidates any Iterator pointing to this Buffer.
References NS_ASSERT, and NS_LOG_FUNCTION.
Referenced by ns3::Packet::AddHeader(), ns3::Icmpv6Header::CalculatePseudoHeaderChecksum(), Deserialize(), ns3::PbbTlv::Deserialize(), ns3::Packet::Packet(), ns3::Ipv6ExtensionLooseRouting::Process(), ns3::PbbTlv::SetValue(), and ns3::PcapFile::Write().
|
inline |
References NS_ASSERT.
Referenced by AddAtEnd(), ns3::Packet::AddHeader(), ns3::Icmpv6Header::CalculatePseudoHeaderChecksum(), ns3::Ipv6ExtensionHeader::Deserialize(), ns3::dsr::DsrOptionHeader::Deserialize(), ns3::Ipv6OptionHeader::Deserialize(), ns3::dsr::DsrFsHeader::Deserialize(), ns3::OptionField::Deserialize(), ns3::dsr::DsrOptionField::Deserialize(), Deserialize(), ns3::dsr::DsrOptionRerrHeader::Deserialize(), ns3::PbbTlv::Deserialize(), ns3::WifiInformationElement::operator==(), ns3::Packet::Packet(), ns3::Packet::PeekHeader(), ns3::Ipv6ExtensionLooseRouting::Process(), ns3::Packet::RemoveHeader(), ns3::dsr::DsrOptionHeader::Serialize(), ns3::Ipv6OptionHeader::Serialize(), ns3::OptionField::Serialize(), ns3::dsr::DsrOptionField::Serialize(), ns3::dsr::DsrOptionRerrHeader::Serialize(), ns3::PbbTlv::SetValue(), and ns3::PcapFile::Write().
void ns3::Buffer::CopyData | ( | std::ostream * | os, |
uint32_t | size | ||
) | const |
Copy the specified amount of data from the buffer to the given output stream.
os | the output stream |
size | the maximum amount of bytes to copy. If zero, nothing is copied. |
Referenced by ns3::Packet::CopyData(), and ns3::PcapFile::Write().
Buffer ns3::Buffer::CreateFragment | ( | uint32_t | start, |
uint32_t | length | ||
) | const |
start | offset from start of packet |
length |
References GetSize(), NS_ASSERT, NS_LOG_FUNCTION, RemoveAtEnd(), and RemoveAtStart().
Referenced by ns3::Packet::CreateFragment().
uint32_t ns3::Buffer::Deserialize | ( | const uint8_t * | buffer, |
uint32_t | size | ||
) |
buffer | points to buffer for deserialization |
size | number of bytes to deserialize |
The raw character buffer is deserialized and all the data is placed into this buffer.
References AddAtEnd(), AddAtStart(), Begin(), End(), NS_ASSERT, ns3::Buffer::Iterator::Prev(), and ns3::Buffer::Iterator::Write().
|
inline |
References NS_ASSERT.
Referenced by AddAtEnd(), ns3::dsr::DsrOptionField::AddDsrOption(), ns3::OptionField::AddOption(), ns3::Packet::AddTrailer(), Deserialize(), ns3::Packet::PeekTrailer(), ns3::Packet::RemoveTrailer(), ns3::Ipv6OptionHeader::Serialize(), ns3::dsr::DsrOptionHeader::Serialize(), ns3::OptionField::Serialize(), ns3::dsr::DsrOptionField::Serialize(), and ns3::dsr::DsrOptionRerrHeader::Serialize().
uint32_t ns3::Buffer::GetSerializedSize | ( | void | ) | const |
Referenced by ns3::Packet::GetSerializedSize().
|
inline |
Referenced by ns3::Packet::AddAtEnd(), AddAtEnd(), ns3::Packet::CreateFragment(), CreateFragment(), ns3::Ipv6ExtensionHeader::Deserialize(), ns3::dsr::DsrFsHeader::Deserialize(), ns3::OptionField::GetSerializedSize(), ns3::dsr::DsrOptionField::GetSerializedSize(), ns3::PbbTlv::GetSerializedSize(), ns3::Packet::GetSize(), ns3::PbbTlv::Print(), ns3::Ipv6ExtensionHeader::Serialize(), ns3::dsr::DsrFsHeader::Serialize(), and ns3::PbbTlv::Serialize().
uint8_t const * ns3::Buffer::PeekData | ( | void | ) | const |
The returned pointer points to an area of memory which is ns3::Buffer::GetSize () bytes big. Please, try to never ever use this method. It is really evil and is present only for a few specific uses.
References NS_ASSERT.
Referenced by ns3::WifiInformationElement::operator==(), ns3::Packet::PeekData(), ns3::Ipv6ExtensionHeader::Serialize(), and ns3::dsr::DsrFsHeader::Serialize().
void ns3::Buffer::RemoveAtEnd | ( | uint32_t | end | ) |
end | size to remove |
Remove bytes at the end of the Buffer. Any call to this method invalidates any Iterator pointing to this Buffer.
References NS_ASSERT, and NS_LOG_FUNCTION.
Referenced by CreateFragment(), ns3::Ipv6ExtensionHeader::Deserialize(), ns3::dsr::DsrFsHeader::Deserialize(), ns3::Packet::RemoveAtEnd(), and ns3::Packet::RemoveTrailer().
void ns3::Buffer::RemoveAtStart | ( | uint32_t | start | ) |
start | size to remove |
Remove bytes at the start of the Buffer. Any call to this method invalidates any Iterator pointing to this Buffer.
References NS_ASSERT, and NS_LOG_FUNCTION.
Referenced by CreateFragment(), ns3::Packet::RemoveAtStart(), and ns3::Packet::RemoveHeader().
uint32_t ns3::Buffer::Serialize | ( | uint8_t * | buffer, |
uint32_t | maxSize | ||
) | const |
buffer | points to serialization buffer |
maxSize | max number of bytes to write |
This buffer's contents are serialized into the raw character buffer parameter. Note: The zero length data is not copied entirely. Only the length of zero byte data is serialized.
References NS_LOG_FUNCTION.