21 #include "ns3/assert.h"
23 #include "ns3/simulator.h"
116 (uint8_t*)m_data->data
140 m_metadata (static_cast<uint64_t> (
Simulator::GetSystemId ()) << 32 | m_globalUid, 0),
147 : m_buffer (o.m_buffer),
148 m_byteTagList (o.m_byteTagList),
149 m_packetTagList (o.m_packetTagList),
150 m_metadata (o.m_metadata)
182 m_metadata (static_cast<uint64_t> (
Simulator::GetSystemId ()) << 32 | m_globalUid, size),
188 : m_buffer (0, false),
208 m_metadata (static_cast<uint64_t> (
Simulator::GetSystemId ()) << 32 | m_globalUid, size),
214 i.
Write (buffer, size);
220 m_byteTagList (byteTagList),
221 m_packetTagList (packetTagList),
222 m_metadata (metadata),
325 appendPrependOffset);
328 appendPrependOffset);
407 if (constructor.
IsNull ())
415 Tag *tag =
dynamic_cast<Tag *
> (constructor ());
464 Chunk *chunk =
dynamic_cast<Chunk *
> (instance);
517 Chunk *chunk =
dynamic_cast<Chunk *
> (instance);
522 std::string attrName = item.
tid.GetAttributeName (j);
526 os << attrName <<
"=" << value;
610 uint32_t* p =
reinterpret_cast<uint32_t *
> (buffer);
617 if (size + nixSize <= maxSize)
626 uint32_t serialized =
632 p += ((nixSize+3) & (~3)) / 4;
649 if (size + 4 <= maxSize)
665 if (size + metaSize <= maxSize)
674 uint32_t serialized =
680 p += ((metaSize+3) & (~3)) / 4;
694 if (size + bufSize <= maxSize)
703 uint32_t serialized =
709 p += ((bufSize+3) & (~3)) / 4;
730 const uint32_t* p =
reinterpret_cast<const uint32_t *
> (buffer);
734 uint32_t nixSize = *p++;
745 uint32_t nixDeserialized = nix->
Deserialize (p, nixSize);
746 if (!nixDeserialized)
755 p += ((((nixSize - 4) + 3) & (~3)) / 4);
764 uint32_t metaSize = *p++;
772 uint32_t metadataDeserialized =
774 if (!metadataDeserialized)
782 p += ((((metaSize - 4) + 3) & (~3)) / 4);
785 uint32_t bufSize = *p++;
793 uint32_t bufferDeserialized =
795 if (!bufferDeserialized)
886 Tag *tag =
dynamic_cast<Tag *
> (instance);
uint32_t RemoveHeader(Header &header)
Deserialize and remove the header from the internal buffer.
PacketMetadata m_metadata
uint32_t GetAttributeN(void) const
bool FindFirstMatchingByteTag(Tag &tag) const
bool Remove(Tag &tag)
Remove (the first instance of) tag from the list.
#define NS_LOG_FUNCTION(parameters)
void PrintPacketTags(std::ostream &os) const
Print the list of packet tags.
Control the scheduling of simulation events.
void RemoveAtEnd(uint32_t end)
struct TagData * next
Pointer to next in list.
uint32_t Deserialize(uint8_t const *buffer, uint32_t size)
void RemoveAtStart(uint32_t start)
virtual uint32_t GetSerializedSize(void) const =0
const struct PacketTagList::TagData * Head(void) const
automatically resized byte buffer
Ptr< NixVector > Copy(void) const
void AddPacketTag(const Tag &tag) const
Add a packet tag.
List of the packet tags stored in a packet.
uint64_t GetUid(void) const
A packet is allocated a new uid when it is created empty or with zero-filled payload.
uint32_t Serialize(uint8_t *buffer, uint32_t maxSize) const
Serialize a packet, tags, and metadata into a byte buffer.
keep track of the byte tags stored in a packet.
bool IsNull(void) const
Check for null implementation.
static uint32_t m_globalUid
#define NS_ASSERT(condition)
TagBuffer Add(TypeId tid, uint32_t bufferSize, int32_t start, int32_t end)
uint32_t GetSize(void) const
uint32_t GetSerializedSize(void) const
#define NS_LOG_FUNCTION_NOARGS()
Output the name of the function.
implement the ns-3 type and attribute system
Ptr< NixVector > GetNixVector(void) const
Get the packet nix-vector.
Item(TypeId tid, uint32_t start, uint32_t end, TagBuffer buffer)
void Print(std::ostream &os) const
Packet & operator=(const Packet &o)
virtual uint32_t Deserialize(Buffer::Iterator start)=0
bool Peek(Tag &tag) const
Find a tag and return its value.
#define NS_FATAL_ERROR(msg)
fatal error handling
PacketTagIterator GetPacketTagIterator(void) const
iterator in a Buffer instance
Callback< ObjectBase * > GetConstructor(void) const
ByteTagList::Iterator m_current
Packet()
Create an empty packet with a new uid (as returned by getUid).
void Add(Tag const &tag) const
Add a tag to the head of this branch.
bool HasConstructor(void) const
void GetTag(Tag &tag) const
Read the requested tag and store it in the user-provided tag instance.
Ptr< Packet > CreateFragment(uint32_t start, uint32_t length) const
Create a new packet which contains a fragment of the original packet.
uint32_t PeekTrailer(Trailer &trailer)
Deserialize but does not remove a trailer from the internal buffer.
void AddAtEnd(Ptr< const Packet > packet)
Concatenate the input packet at the end of the current packet.
void RemoveAll(void)
Removes all of the tags from the ByteTagList.
Tree node for sharing serialized tags.
uint32_t Deserialize(const uint8_t *buffer, uint32_t size)
uint8_t const * PeekData(void) const NS_DEPRECATED
bool PeekPacketTag(Tag &tag) const
Search a matching tag and call Tag::Deserialize if it is found.
void RemoveAllPacketTags(void)
Remove all packet tags.
Identifies a byte tag and a set of bytes within a packet to which the tag applies.
void RemoveAtStart(uint32_t size)
Remove size bytes from the start of the current packet.
bool Replace(Tag &tag)
Replace the value of a tag.
static void EnablePrinting(void)
By default, packets do not keep around enough metadata to perform the operations requested by the Pri...
uint32_t Serialize(uint32_t *buffer, uint32_t maxSize) const
virtual void Print(std::ostream &os) const =0
void SetNixVector(Ptr< NixVector >)
Set the packet nix-vector.
ByteTagList m_byteTagList
bool ReplacePacketTag(Tag &tag)
Replace the value of a packet tag.
uint32_t GetSerializedSize(void) const
Buffer::Iterator End(void) const
static void EnableChecking(void)
The packet metadata is also used to perform extensive sanity checks at runtime when performing operat...
uint8_t const * PeekData(void) const
void AddPaddingAtEnd(uint32_t size)
int32_t start
size of tag data
ByteTagIterator GetByteTagIterator(void) const
void CopyData(std::ostream *os, uint32_t size) const
Copy the specified amount of data from the buffer to the given output stream.
virtual uint32_t Deserialize(Buffer::Iterator end)=0
uint32_t GetEnd(void) const
int32_t GetCurrentEndOffset(void) const
Iterator over the set of packet tags in a packet.
void PrintByteTags(std::ostream &os) const
void AddAtEnd(int32_t adjustment, int32_t appendOffset)
Adjust the offsets stored internally by the adjustment delta and make sure that all offsets are small...
const struct PacketTagList::TagData * m_current
Buffer::Iterator Begin(void) const
struct ByteTagList::Iterator::Item Next(void)
std::ostream & operator<<(std::ostream &os, const Angles &a)
print a struct Angles to output
Ptr< Packet > Copy(void) const
uint32_t PeekHeader(Header &header) const
Deserialize but does not remove the header from the internal buffer.
Protocol trailer serialization and deserialization.
virtual void Serialize(TagBuffer i) const =0
tag a set of bytes in a packet
PacketMetadata::ItemIterator BeginItem(void) const
PacketTagIterator(const struct PacketTagList::TagData *head)
void AddTrailer(const Trailer &trailer)
Add trailer to this packet.
void RemoveAtEnd(uint32_t size)
Remove size bytes from the end of the current packet It is safe to remove more bytes than are present...
Iterator over the set of byte tags in a packet.
virtual void Deserialize(TagBuffer i)=0
uint32_t RemoveTrailer(Trailer &trailer)
Remove a deserialized trailer from the internal buffer.
std::string GetName(void) const
uint32_t GetOffsetStart(void) const
PacketTagList m_packetTagList
NS_LOG_COMPONENT_DEFINE("Packet")
int32_t end
offset to the start of the tag from the virtual byte buffer
TypeId GetTypeId(void) const
void GetAttribute(std::string name, AttributeValue &value) const
Identifies a packet tag within a packet.
uint32_t GetSize(void) const
TypeId GetTypeId(void) const
Buffer CreateFragment(uint32_t start, uint32_t length) const
bool AddAtEnd(uint32_t end)
Item(const struct PacketTagList::TagData *data)
void GetTag(Tag &tag) const
Read the requested tag and store it in the user-provided tag instance.
uint32_t Serialize(uint8_t *buffer, uint32_t maxSize) const
Size of serialization buffer data.
ByteTagList::Iterator Begin(int32_t offsetStart, int32_t offsetEnd) const
TagBuffer buf
offset to the end of the tag from the virtual byte buffer
uint32_t GetStart(void) const
uint32_t GetSerializedSize(void) const
virtual TypeId GetInstanceTypeId(void) const =0
bool RemovePacketTag(Tag &tag)
Remove a packet tag.
void RemoveAllByteTags(void)
Remove all byte tags stored in this packet.
virtual uint32_t GetSerializedSize(void) const =0
Ptr< NixVector > m_nixVector
uint32_t Deserialize(const uint32_t *buffer, uint32_t size)
void Write(uint8_t const *buffer, uint32_t size)
uint32_t CopyData(uint8_t *buffer, uint32_t size) const
Copy the packet contents to a byte buffer.
virtual void Serialize(Buffer::Iterator start) const =0
ByteTagIterator(ByteTagList::Iterator i)
bool AddAtStart(uint32_t start)
int32_t GetCurrentStartOffset(void) const
void RemoveAll(void)
Remove all tags from this list (up to the first merge).
a unique identifier for an interface.
abstract base class for ns3::Header and ns3::Trailer
void AddHeader(const Header &header)
Add header to this packet.
virtual void Print(std::ostream &os) const =0
void AddAtStart(int32_t adjustment, int32_t prependOffset)
Adjust the offsets stored internally by the adjustment delta and make sure that all offsets are bigge...
void AddByteTag(const Tag &tag) const
Tag each byte included in this packet with a new byte tag.