A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
ns3::Packet Class Reference

network packets More...

#include "packet.h"

+ Inheritance diagram for ns3::Packet:
+ Collaboration diagram for ns3::Packet:

Public Types

typedef void(* AddressTracedCallback) (Ptr< const Packet > packet, const Address &address)
 TracedCallback signature for packet and Address.
 
typedef void(* Mac48AddressTracedCallback) (Ptr< const Packet > packet, Mac48Address mac)
 TracedCallback signature for packet and Mac48Address.
 
typedef void(* SinrTracedCallback) (Ptr< const Packet > packet, double sinr)
 TracedCallback signature for packet and SINR.
 
typedef void(* SizeTracedCallback) (uint32_t oldSize, uint32_t newSize)
 TracedCallback signature for changes in packet size.
 
typedef void(* TracedCallback) (Ptr< const Packet > packet)
 TracedCallback signature for Ptr<Packet>
 
typedef void(* TwoAddressTracedCallback) (const Ptr< const Packet > packet, const Address &srcAddress, const Address &destAddress)
 TracedCallback signature for packet and source/destination addresses.
 

Public Member Functions

 Packet ()
 Create an empty packet with a new uid (as returned by getUid).
 
 Packet (const Packet &o)
 Copy constructor.
 
 Packet (const uint8_t *buffer, uint32_t size)
 Create a packet with payload filled with the content of this buffer.
 
 Packet (const uint8_t *buffer, uint32_t size, bool magic)
 Create a new packet from the serialized buffer.
 
 Packet (uint32_t size)
 Create a packet with a zero-filled payload.
 
void AddAtEnd (Ptr< const Packet > packet)
 Concatenate the input packet at the end of the current packet.
 
void AddByteTag (const Tag &tag) const
 Tag each byte included in this packet with a new byte tag.
 
void AddByteTag (const Tag &tag, uint32_t start, uint32_t end) const
 Tag the indicated byte range of this packet with a new byte tag.
 
void AddHeader (const Header &header)
 Add header to this packet.
 
void AddPacketTag (const Tag &tag) const
 Add a packet tag.
 
void AddPaddingAtEnd (uint32_t size)
 Add a zero-filled padding to the packet.
 
void AddTrailer (const Trailer &trailer)
 Add trailer to this packet.
 
PacketMetadata::ItemIterator BeginItem () const
 Returns an iterator which points to the first 'item' stored in this buffer.
 
Ptr< PacketCopy () const
 performs a COW copy of the packet.
 
void CopyData (std::ostream *os, uint32_t size) const
 Copy the packet contents to an output stream.
 
uint32_t CopyData (uint8_t *buffer, uint32_t size) const
 Copy the packet contents to a byte buffer.
 
Ptr< PacketCreateFragment (uint32_t start, uint32_t length) const
 Create a new packet which contains a fragment of the original packet.
 
bool FindFirstMatchingByteTag (Tag &tag) const
 Finds the first tag matching the parameter Tag type.
 
ByteTagIterator GetByteTagIterator () const
 Returns an iterator over the set of byte tags included in this packet.
 
Ptr< NixVectorGetNixVector () const
 Get the packet nix-vector.
 
PacketTagIterator GetPacketTagIterator () const
 Returns an object which can be used to iterate over the list of packet tags.
 
uint32_t GetSerializedSize () const
 Returns number of bytes required for packet serialization.
 
uint32_t GetSize () const
 Returns the the size in bytes of the packet (including the zero-filled initial payload).
 
uint64_t GetUid () const
 Returns the packet's Uid.
 
Packetoperator= (const Packet &o)
 Basic assignment.
 
uint32_t PeekHeader (Header &header) const
 Deserialize but does not remove the header from the internal buffer.
 
uint32_t PeekHeader (Header &header, uint32_t size) const
 Deserialize but does not remove the header from the internal buffer.
 
bool PeekPacketTag (Tag &tag) const
 Search a matching tag and call Tag::Deserialize if it is found.
 
uint32_t PeekTrailer (Trailer &trailer)
 Deserialize but does not remove a trailer from the internal buffer.
 
void Print (std::ostream &os) const
 Print the packet contents.
 
void PrintByteTags (std::ostream &os) const
 Iterate over the byte tags present in this packet, and invoke the Print method of each tag stored in the packet.
 
void PrintPacketTags (std::ostream &os) const
 Print the list of packet tags.
 
void RemoveAllByteTags ()
 Remove all byte tags stored in this packet.
 
void RemoveAllPacketTags ()
 Remove all packet tags.
 
void RemoveAtEnd (uint32_t size)
 Remove size bytes from the end of the current packet.
 
void RemoveAtStart (uint32_t size)
 Remove size bytes from the start of the current packet.
 
uint32_t RemoveHeader (Header &header)
 Deserialize and remove the header from the internal buffer.
 
uint32_t RemoveHeader (Header &header, uint32_t size)
 Deserialize and remove the header from the internal buffer.
 
bool RemovePacketTag (Tag &tag)
 Remove a packet tag.
 
uint32_t RemoveTrailer (Trailer &trailer)
 Remove a deserialized trailer from the internal buffer.
 
bool ReplacePacketTag (Tag &tag)
 Replace the value of a packet tag.
 
uint32_t Serialize (uint8_t *buffer, uint32_t maxSize) const
 Serialize a packet, tags, and metadata into a byte buffer.
 
void SetNixVector (Ptr< NixVector > nixVector) const
 Set the packet nix-vector.
 
std::string ToString () const
 Return a string representation of the packet.
 
- Public Member Functions inherited from ns3::SimpleRefCount< Packet >
 SimpleRefCount ()
 Default constructor.
 
 SimpleRefCount (const SimpleRefCount &o)
 Copy constructor.
 
uint32_t GetReferenceCount () const
 Get the reference count of the object.
 
SimpleRefCountoperator= (const SimpleRefCount &o)
 Assignment operator.
 
void Ref () const
 Increment the reference count.
 
void Unref () const
 Decrement the reference count.
 

Static Public Member Functions

static void EnableChecking ()
 Enable packets metadata checking.
 
static void EnablePrinting ()
 Enable printing packets metadata.
 

Private Member Functions

 Packet (const Buffer &buffer, const ByteTagList &byteTagList, const PacketTagList &packetTagList, const PacketMetadata &metadata)
 Constructor.
 
uint32_t Deserialize (const uint8_t *buffer, uint32_t size)
 Deserializes a packet.
 

Private Attributes

Buffer m_buffer
 the packet buffer (it's actual contents)
 
ByteTagList m_byteTagList
 the ByteTag list
 
PacketMetadata m_metadata
 the packet's metadata
 
Ptr< NixVectorm_nixVector
 the packet's Nix vector
 
PacketTagList m_packetTagList
 the packet's Tag list
 

Static Private Attributes

static uint32_t m_globalUid = 0
 Global counter of packets Uid.
 

Detailed Description

network packets

Each network packet contains a byte buffer, a set of byte tags, a set of packet tags, and metadata.

  • The byte buffer stores the serialized content of the headers and trailers added to a packet. The serialized representation of these headers is expected to match that of real network packets bit for bit (although nothing forces you to do this) which means that the content of a packet buffer is expected to be that of a real packet.
  • The metadata describes the type of the headers and trailers which were serialized in the byte buffer. The maintenance of metadata is optional and disabled by default. To enable it, you must call Packet::EnablePrinting and this will allow you to get non-empty output from Packet::Print. If you wish to only enable checking of metadata, and do not need any printing capability, you can call Packet::EnableChecking: its runtime cost is lower than Packet::EnablePrinting.
  • The set of tags contain simulation-specific information which cannot be stored in the packet byte buffer because the protocol headers or trailers have no standard-conformant field for this information. So-called 'byte' tags are used to tag a subset of the bytes in the packet byte buffer while 'packet' tags are used to tag the packet itself. The main difference between these two kinds of tags is what happens when packets are copied, fragmented, and reassembled: 'byte' tags follow bytes while 'packet' tags follow packets. Another important difference between these two kinds of tags is that byte tags cannot be removed and are expected to be written once, and read many times, while packet tags are expected to be written once, read many times, and removed exactly once. An example of a 'byte' tag is a FlowIdTag which contains a flow id and is set by the application generating traffic. An example of a 'packet' tag is a cross-layer qos class id set by an application and processed by a lower-level MAC layer.

Implementing a new type of Header or Trailer for a new protocol is pretty easy and is a matter of creating a subclass of the ns3::Header or of the ns3::Trailer base class, and implementing the methods described in their respective API documentation.

Implementing a new type of Tag requires roughly the same amount of work and this work is described in the ns3::Tag API documentation.

The performance aspects copy-on-write semantics of the Packet API are discussed in Packet Performance

Definition at line 227 of file packet.h.

Member Typedef Documentation

◆ AddressTracedCallback

typedef void(* ns3::Packet::AddressTracedCallback) (Ptr< const Packet > packet, const Address &address)

TracedCallback signature for packet and Address.

Parameters
[in]packetThe packet.
[in]addressThe address.

Definition at line 721 of file packet.h.

◆ Mac48AddressTracedCallback

typedef void(* ns3::Packet::Mac48AddressTracedCallback) (Ptr< const Packet > packet, Mac48Address mac)

TracedCallback signature for packet and Mac48Address.

Parameters
[in]packetThe packet.
[in]macThe Mac48Address.

Definition at line 740 of file packet.h.

◆ SinrTracedCallback

typedef void(* ns3::Packet::SinrTracedCallback) (Ptr< const Packet > packet, double sinr)

TracedCallback signature for packet and SINR.

Parameters
[in]packetThe packet.
[in]sinrThe received SINR.

Definition at line 756 of file packet.h.

◆ SizeTracedCallback

typedef void(* ns3::Packet::SizeTracedCallback) (uint32_t oldSize, uint32_t newSize)

TracedCallback signature for changes in packet size.

Parameters
[in]oldSizeThe previous packet's size.
[in]newSizeThe actual packet's size.

Definition at line 748 of file packet.h.

◆ TracedCallback

typedef void(* ns3::Packet::TracedCallback) (Ptr< const Packet > packet)

TracedCallback signature for Ptr<Packet>

Parameters
[in]packetThe packet.

Definition at line 713 of file packet.h.

◆ TwoAddressTracedCallback

typedef void(* ns3::Packet::TwoAddressTracedCallback) (const Ptr< const Packet > packet, const Address &srcAddress, const Address &destAddress)

TracedCallback signature for packet and source/destination addresses.

Parameters
[in]packetThe packet.
[in]srcAddressThe source address.
[in]destAddressThe destination address.

Definition at line 730 of file packet.h.

Constructor & Destructor Documentation

◆ Packet() [1/6]

ns3::Packet::Packet ( )

Create an empty packet with a new uid (as returned by getUid).

Definition at line 128 of file packet.cc.

References m_globalUid.

Referenced by CreateFragment().

+ Here is the caller graph for this function:

◆ Packet() [2/6]

ns3::Packet::Packet ( const Packet & o)

Copy constructor.

Parameters
oobject to copy

Definition at line 144 of file packet.cc.

References ns3::NixVector::Copy(), and m_nixVector.

+ Here is the call graph for this function:

◆ Packet() [3/6]

ns3::Packet::Packet ( uint32_t size)

Create a packet with a zero-filled payload.

The memory necessary for the payload is not allocated: it will be allocated at any later point if you attempt to fragment this packet or to access the zero-filled bytes. The packet is allocated with a new uid (as returned by getUid).

Parameters
sizethe size of the zero-filled payload

Definition at line 168 of file packet.cc.

References m_globalUid.

◆ Packet() [4/6]

ns3::Packet::Packet ( const uint8_t * buffer,
uint32_t size,
bool magic )

Create a new packet from the serialized buffer.

This new packet is identical to the serialized packet contained in the buffer and is magically deserialized for you

Parameters
bufferthe serialized packet to be created
sizethe size of the packet for deserialization
magicallows packet deserialization; asserts when set to false

Definition at line 184 of file packet.cc.

References Deserialize(), and NS_ASSERT.

+ Here is the call graph for this function:

◆ Packet() [5/6]

ns3::Packet::Packet ( const uint8_t * buffer,
uint32_t size )

Create a packet with payload filled with the content of this buffer.

The input data is copied: the input buffer is untouched.

Parameters
bufferthe data to store in the packet.
sizethe size of the input buffer.

Definition at line 195 of file packet.cc.

References ns3::Buffer::AddAtStart(), ns3::Buffer::Begin(), m_buffer, m_globalUid, and ns3::Buffer::Iterator::Write().

+ Here is the call graph for this function:

◆ Packet() [6/6]

ns3::Packet::Packet ( const Buffer & buffer,
const ByteTagList & byteTagList,
const PacketTagList & packetTagList,
const PacketMetadata & metadata )
private

Constructor.

Parameters
bufferthe packet buffer
byteTagListthe ByteTag list
packetTagListthe packet's Tag list
metadatathe packet's metadata

Definition at line 214 of file packet.cc.

Member Function Documentation

◆ AddAtEnd()

void ns3::Packet::AddAtEnd ( Ptr< const Packet > packet)

Concatenate the input packet at the end of the current packet.

This does not alter the uid of either packet.

Parameters
packetpacket to concatenate

Definition at line 343 of file packet.cc.

References ns3::ByteTagList::Add(), ns3::Buffer::AddAtEnd(), ns3::ByteTagList::AddAtEnd(), ns3::PacketMetadata::AddAtEnd(), ns3::ByteTagList::AddAtStart(), ns3::ByteTagList::Adjust(), GetSize(), m_buffer, m_byteTagList, m_metadata, and NS_LOG_FUNCTION.

Referenced by ns3::TcpTxBuffer::MergeItems(), ns3::LteRlcAm::ReassembleAndDeliver(), ns3::LteRlcUm::ReassembleAndDeliver(), and ns3::ThreeGppHttpClient::Receive().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ AddByteTag() [1/2]

void ns3::Packet::AddByteTag ( const Tag & tag) const

Tag each byte included in this packet with a new byte tag.

Parameters
tagthe new tag to add to this packet

Note that adding a tag is a const operation which is pretty un-intuitive. The rationale is that the content and behavior of a packet is not changed when a tag is added to a packet: any code which was not aware of the new tag is going to work just the same if the new tag is added. The real reason why adding a tag was made a const operation is to allow a trace sink which gets a packet to tag the packet, even if the packet is const (and most trace sources should use const packets because it would be totally evil to allow a trace sink to modify the content of a packet).

Definition at line 904 of file packet.cc.

References ns3::ObjectBase::GetInstanceTypeId(), ns3::TypeId::GetName(), ns3::Tag::GetSerializedSize(), GetSize(), m_byteTagList, NS_LOG_FUNCTION, and ns3::Tag::Serialize().

Referenced by PacketTest::DoRun().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ AddByteTag() [2/2]

void ns3::Packet::AddByteTag ( const Tag & tag,
uint32_t start,
uint32_t end ) const

Tag the indicated byte range of this packet with a new byte tag.

As parameters for this method, we do not use indexes, but byte position. Moreover, as there is no 0-th position, the first position is 1.

As example, if you want to tag the first 10 bytes, you have to call the method in this way:

Ptr<Packet> p = ... ;
SomeTag tag;
p->AddByteTag (tag, 1, 10);
Smart pointer class similar to boost::intrusive_ptr.
Parameters
tagthe new tag to add to this packet
startthe position of the first byte tagged by this tag
endthe position of the last byte tagged by this tag

Definition at line 913 of file packet.cc.

References ns3::ObjectBase::GetInstanceTypeId(), ns3::TypeId::GetName(), ns3::Tag::GetSerializedSize(), m_byteTagList, NS_ABORT_MSG_IF, NS_LOG_FUNCTION, and ns3::Tag::Serialize().

+ Here is the call graph for this function:

◆ AddHeader()

void ns3::Packet::AddHeader ( const Header & header)

Add header to this packet.

This method invokes the Header::GetSerializedSize and Header::Serialize methods to reserve space in the buffer and request the header to serialize itself in the packet buffer.

Parameters
headera reference to the header to add to this packet.

Definition at line 257 of file packet.cc.

References ns3::Buffer::AddAtStart(), ns3::ByteTagList::AddAtStart(), ns3::PacketMetadata::AddHeader(), ns3::ByteTagList::Adjust(), ns3::Buffer::Begin(), ns3::ObjectBase::GetInstanceTypeId(), ns3::TypeId::GetName(), ns3::Header::GetSerializedSize(), m_buffer, m_byteTagList, m_metadata, NS_LOG_FUNCTION, and ns3::Header::Serialize().

Referenced by EpsGtpuHeaderTestCase::DoRun(), HandoverPreparationInfoTestCase::DoRun(), MeasurementReportTestCase::DoRun(), OlsrHelloTestCase::DoRun(), OlsrHnaTestCase::DoRun(), OlsrMidTestCase::DoRun(), OlsrTcTestCase::DoRun(), RrcConnectionReconfigurationCompleteTestCase::DoRun(), RrcConnectionReconfigurationTestCase::DoRun(), RrcConnectionReestablishmentCompleteTestCase::DoRun(), RrcConnectionReestablishmentRequestTestCase::DoRun(), RrcConnectionReestablishmentTestCase::DoRun(), RrcConnectionRejectTestCase::DoRun(), RrcConnectionRequestTestCase::DoRun(), RrcConnectionSetupCompleteTestCase::DoRun(), RrcConnectionSetupTestCase::DoRun(), and ns3::ThreeGppHttpClient::Receive().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ AddPacketTag()

void ns3::Packet::AddPacketTag ( const Tag & tag) const

Add a packet tag.

Parameters
tagthe packet tag type to add.

Note that this method is const, that is, it does not modify the state of this packet, which is fairly un-intuitive. See AddByteTag"()" discussion.

Definition at line 949 of file packet.cc.

References ns3::PacketTagList::Add(), ns3::ObjectBase::GetInstanceTypeId(), ns3::TypeId::GetName(), ns3::Tag::GetSerializedSize(), m_packetTagList, and NS_LOG_FUNCTION.

Referenced by PacketTest::DoRun(), ns3::dot11s::HwmpProtocol::ProactivePathResolved(), and ns3::dot11s::HwmpProtocol::ReactivePathResolved().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ AddPaddingAtEnd()

void ns3::Packet::AddPaddingAtEnd ( uint32_t size)

Add a zero-filled padding to the packet.

Parameters
sizenumber of padding bytes to add.

Definition at line 356 of file packet.cc.

References ns3::Buffer::AddAtEnd(), ns3::ByteTagList::AddAtEnd(), ns3::PacketMetadata::AddPaddingAtEnd(), GetSize(), m_buffer, m_byteTagList, m_metadata, and NS_LOG_FUNCTION.

+ Here is the call graph for this function:

◆ AddTrailer()

void ns3::Packet::AddTrailer ( const Trailer & trailer)

Add trailer to this packet.

This method invokes the Trailer::GetSerializedSize and Trailer::Serialize methods to reserve space in the buffer and request the trailer to serialize itself in the packet buffer.

Parameters
trailera reference to the trailer to add to this packet.

Definition at line 313 of file packet.cc.

References ns3::Buffer::AddAtEnd(), ns3::ByteTagList::AddAtEnd(), ns3::PacketMetadata::AddTrailer(), ns3::Buffer::End(), ns3::ObjectBase::GetInstanceTypeId(), ns3::TypeId::GetName(), ns3::Trailer::GetSerializedSize(), GetSize(), m_buffer, m_byteTagList, m_metadata, NS_LOG_FUNCTION, and ns3::Trailer::Serialize().

+ Here is the call graph for this function:

◆ BeginItem()

PacketMetadata::ItemIterator ns3::Packet::BeginItem ( ) const

Returns an iterator which points to the first 'item' stored in this buffer.

Note that this iterator will point to an empty array of items if you don't call EnablePrinting or EnableChecking before.

Returns
an iterator
See also
EnablePrinting EnableChecking

Definition at line 579 of file packet.cc.

References ns3::PacketMetadata::BeginItem(), m_buffer, and m_metadata.

+ Here is the call graph for this function:

◆ Copy()

◆ CopyData() [1/2]

void ns3::Packet::CopyData ( std::ostream * os,
uint32_t size ) const

Copy the packet contents to an output stream.

Parameters
ospointer to output stream in which we want to write the packet data.
sizethe maximum number of bytes we want to write in the output stream.

Definition at line 395 of file packet.cc.

References ns3::Buffer::CopyData(), and m_buffer.

+ Here is the call graph for this function:

◆ CopyData() [2/2]

uint32_t ns3::Packet::CopyData ( uint8_t * buffer,
uint32_t size ) const

Copy the packet contents to a byte buffer.

Parameters
buffera pointer to a byte buffer where the packet data should be copied.
sizethe size of the byte buffer.
Returns
the number of bytes read from the packet

No more than size bytes will be copied by this function.

Definition at line 389 of file packet.cc.

References ns3::Buffer::CopyData(), and m_buffer.

Referenced by Ipv4FragmentationTest::DoRun(), Ipv6FragmentationTest::DoRun(), PointToPointTest::DoRun(), SixlowpanFragmentationTest::DoRun(), SixlowpanHc1ImplTest::DoRun(), SixlowpanIphcImplTest::DoRun(), ns3::Icmpv6DestinationUnreachable::Serialize(), ns3::Icmpv6OptionRedirected::Serialize(), ns3::Icmpv6ParameterError::Serialize(), ns3::Icmpv6TimeExceeded::Serialize(), and ns3::Icmpv6TooBig::Serialize().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ CreateFragment()

Ptr< Packet > ns3::Packet::CreateFragment ( uint32_t start,
uint32_t length ) const

Create a new packet which contains a fragment of the original packet.

The returned packet shares the same uid as this packet.

Parameters
startoffset from start of packet to start of fragment to create
lengthlength of fragment to create
Returns
a fragment of the original packet

Definition at line 227 of file packet.cc.

References Packet(), ns3::ByteTagList::Adjust(), ns3::Buffer::CreateFragment(), ns3::PacketMetadata::CreateFragment(), GetNixVector(), ns3::Buffer::GetSize(), m_buffer, m_byteTagList, m_metadata, m_packetTagList, NS_ASSERT, and NS_LOG_FUNCTION.

Referenced by ns3::TcpTxBuffer::DiscardUpTo(), ns3::FrameExchangeManager::GetFirstFragmentIfNeeded(), ns3::FrameExchangeManager::GetNextFragment(), and ns3::TcpTxBuffer::SplitItems().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ Deserialize()

uint32_t ns3::Packet::Deserialize ( const uint8_t * buffer,
uint32_t size )
private

Deserializes a packet.

Parameters
[in]bufferthe input buffer.
[in]sizethe buffer size.
Returns
the number of deserialized bytes.

Definition at line 794 of file packet.cc.

References ns3::Create(), ns3::Buffer::Deserialize(), ns3::ByteTagList::Deserialize(), ns3::PacketMetadata::Deserialize(), ns3::PacketTagList::Deserialize(), m_buffer, m_byteTagList, m_metadata, m_nixVector, m_packetTagList, NS_ASSERT, and NS_LOG_FUNCTION.

Referenced by Packet().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ EnableChecking()

void ns3::Packet::EnableChecking ( )
static

Enable packets metadata checking.

The packet metadata is also used to perform extensive sanity checks at runtime when performing operations on a Packet. For example, this metadata is used to verify that when you remove a header from a packet, this same header was actually present at the front of the packet. These errors will be detected and will abort the program.

Definition at line 592 of file packet.cc.

References ns3::PacketMetadata::EnableChecking(), and NS_LOG_FUNCTION_NOARGS.

+ Here is the call graph for this function:

◆ EnablePrinting()

void ns3::Packet::EnablePrinting ( )
static

Enable printing packets metadata.

By default, packets do not keep around enough metadata to perform the operations requested by the Print methods. If you want to be able the Packet::Print method, you need to invoke this method at least once during the simulation setup and before any packet is created.

Definition at line 585 of file packet.cc.

References ns3::PacketMetadata::Enable(), and NS_LOG_FUNCTION_NOARGS.

Referenced by Ns3TcpLossTestSuite::Ns3TcpLossTestSuite(), Ns3TcpStateTestSuite::Ns3TcpStateTestSuite(), LrWpanAckTestCase::DoRun(), LteRlcAmTransmitterTestCase::DoRun(), LteRlcUmTransmitterTestCase::DoRun(), ns3::TcpGeneralTest::DoRun(), SixlowpanFragmentationTest::DoRun(), ns3::UanHelper::EnableAscii(), ns3::CsmaHelper::EnableAsciiInternal(), ns3::FdNetDeviceHelper::EnableAsciiInternal(), ns3::LrWpanHelper::EnableAsciiInternal(), ns3::PointToPointHelper::EnableAsciiInternal(), ns3::WifiPhyHelper::EnableAsciiInternal(), ns3::WimaxHelper::EnableAsciiInternal(), ns3::ClickInternetStackHelper::EnableAsciiIpv4Internal(), ns3::InternetStackHelper::EnableAsciiIpv4Internal(), ns3::InternetStackHelper::EnableAsciiIpv6Internal(), ns3::AnimationInterface::EnablePacketMetadata(), and RoutingExperiment::Run().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ FindFirstMatchingByteTag()

bool ns3::Packet::FindFirstMatchingByteTag ( Tag & tag) const

Finds the first tag matching the parameter Tag type.

Parameters
tagthe byte tag type to search in this packet
Returns
true if the requested tag type was found, false otherwise.

If the requested tag type is found, it is copied in the user's provided tag instance.

Definition at line 932 of file packet.cc.

References GetByteTagIterator(), ns3::ObjectBase::GetInstanceTypeId(), ns3::ByteTagIterator::Item::GetTag(), ns3::ByteTagIterator::Item::GetTypeId(), ns3::ByteTagIterator::HasNext(), and ns3::ByteTagIterator::Next().

Referenced by ns3::LteRlcAm::DoReceivePdu(), ns3::LteRlcSm::DoReceivePdu(), and ns3::LteRlcUm::DoReceivePdu().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ GetByteTagIterator()

ByteTagIterator ns3::Packet::GetByteTagIterator ( ) const

Returns an iterator over the set of byte tags included in this packet.

Returns
an iterator over the set of byte tags included in this packet.

Definition at line 926 of file packet.cc.

References ns3::ByteTagList::Begin(), GetSize(), and m_byteTagList.

Referenced by Ipv4FragmentationTest::DoRun(), Ipv6FragmentationTest::DoRun(), FindFirstMatchingByteTag(), and PrintByteTags().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ GetNixVector()

Ptr< NixVector > ns3::Packet::GetNixVector ( ) const

Get the packet nix-vector.

See the comment on SetNixVector

Returns
the Nix vector

Definition at line 251 of file packet.cc.

References m_nixVector.

Referenced by CreateFragment().

+ Here is the caller graph for this function:

◆ GetPacketTagIterator()

PacketTagIterator ns3::Packet::GetPacketTagIterator ( ) const

Returns an object which can be used to iterate over the list of packet tags.

Returns
an object which can be used to iterate over the list of packet tags.

Definition at line 1009 of file packet.cc.

References ns3::PacketTagList::Head(), and m_packetTagList.

Referenced by PrintPacketTags().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ GetSerializedSize()

uint32_t ns3::Packet::GetSerializedSize ( ) const

Returns number of bytes required for packet serialization.

Returns
number of bytes required for packet serialization

For packet serialization, the total size is checked in order to determine the size of the buffer required for serialization

Definition at line 599 of file packet.cc.

References ns3::Buffer::GetSerializedSize(), ns3::ByteTagList::GetSerializedSize(), ns3::NixVector::GetSerializedSize(), ns3::PacketMetadata::GetSerializedSize(), ns3::PacketTagList::GetSerializedSize(), m_buffer, m_byteTagList, m_metadata, m_nixVector, and m_packetTagList.

+ Here is the call graph for this function:

◆ GetSize()

uint32_t ns3::Packet::GetSize ( ) const
inline

Returns the the size in bytes of the packet (including the zero-filled initial payload).

Returns
the size in bytes of the packet

Definition at line 850 of file packet.h.

References ns3::Buffer::GetSize(), and m_buffer.

Referenced by ns3::TcpTxBuffer::~TcpTxBuffer(), AddAtEnd(), AddByteTag(), AddPaddingAtEnd(), AddTrailer(), ns3::TcpTxBuffer::BytesInFlightRFC(), ns3::dot11s::AirtimeLinkMetricCalculator::CalculateMetric(), ns3::dsr::DsrErrorBuffer::Dequeue(), ns3::dsr::DsrMaintainBuffer::Dequeue(), ns3::dsr::DsrPassiveBuffer::Dequeue(), ns3::dsr::DsrSendBuffer::Dequeue(), ns3::WimaxMacQueue::Dequeue(), ns3::TcpTxBuffer::DiscardUpTo(), ns3::LteRlcAm::DoReceivePdu(), ns3::LteRlcSm::DoReceivePdu(), ns3::LteRlcTm::DoReceivePdu(), ns3::LteRlcUm::DoReceivePdu(), IcmpEchoReplyTestCase::DoRun(), IcmpTimeExceedTestCase::DoRun(), IcmpV6EchoReplyTestCase::DoRun(), IcmpV6TimeExceedTestCase::DoRun(), Ipv4ForwardingTest::DoRun(), Ipv4FragmentationTest::DoRun(), Ipv4GlobalRoutingSlash32TestCase::DoRun(), Ipv4HeaderTest::DoRun(), Ipv4RawSocketImplTest::DoRun(), Ipv4RipCountToInfinityTest::DoRun(), Ipv4RipTest::DoRun(), Ipv4StaticRoutingSlash32TestCase::DoRun(), Ipv6ForwardingTest::DoRun(), Ipv6FragmentationTest::DoRun(), Ipv6RawSocketImplTest::DoRun(), Ipv6RipngCountToInfinityTest::DoRun(), Ipv6RipngTest::DoRun(), OlsrHelloTestCase::DoRun(), OlsrHnaTestCase::DoRun(), OlsrTcTestCase::DoRun(), PointToPointTest::DoRun(), SixlowpanFragmentationTest::DoRun(), SixlowpanHc1ImplTest::DoRun(), SixlowpanIphcImplTest::DoRun(), Udp6SocketImplTest::DoRun(), Udp6SocketLoopbackTest::DoRun(), UdpSocketImplTest::DoRun(), UdpSocketLoopbackTest::DoRun(), ns3::TcpTxBuffer::FindHighestSacked(), GetByteTagIterator(), ns3::WimaxMacQueue::GetFirstPacketPayloadSize(), ns3::lrwpan::LrWpanMac::GetIfsSize(), ns3::TcpTxBuffer::GetNewSegment(), ns3::FrameExchangeManager::GetNextFragment(), ns3::WifiMpdu::GetPacketSize(), ns3::TcpTxItem::GetSeqSize(), ns3::Icmpv6OptionRedirected::GetSerializedSize(), ns3::QueueItem::GetSize(), ns3::TcpTxBuffer::GetTransmittedSegment(), ns3::lrwpan::LrWpanMac::GetTxPacketSymbols(), ns3::TcpTxBuffer::MergeItems(), ns3::TcpTxBuffer::NextSeg(), ns3::lrwpan::LrWpanMac::PdDataConfirm(), ns3::lrwpan::LrWpanMac::PlmeSetTRXStateConfirm(), ns3::dot11s::HwmpProtocol::ProactivePathResolved(), ns3::dot11s::HwmpProtocol::ReactivePathResolved(), DynamicNeighborCacheTest::ReceivePkt(), Ipv4ForwardingTest::ReceivePkt(), Ipv4GlobalRoutingSlash32TestCase::ReceivePkt(), Ipv4HeaderTest::ReceivePkt(), Ipv4RawSocketImplTest::ReceivePkt(), Ipv4RipCountToInfinityTest::ReceivePkt(), Ipv4RipTest::ReceivePkt(), Ipv4StaticRoutingSlash32TestCase::ReceivePkt(), Ipv6ForwardingTest::ReceivePkt(), Ipv6RawSocketImplTest::ReceivePkt(), Ipv6RipngCountToInfinityTest::ReceivePkt(), Ipv6RipngTest::ReceivePkt(), NixVectorRoutingTest::ReceivePkt(), SixlowpanHc1ImplTest::ReceivePkt(), SixlowpanIphcImplTest::ReceivePkt(), Udp6SocketImplTest::ReceivePkt(), Udp6SocketLoopbackTest::ReceivePkt(), UdpSocketImplTest::ReceivePkt(), UdpSocketLoopbackTest::ReceivePkt(), Ipv4RawSocketImplTest::ReceivePkt2(), Ipv6RawSocketImplTest::ReceivePkt2(), Udp6SocketImplTest::ReceivePkt2(), UdpSocketImplTest::ReceivePkt2(), ns3::TcpTxBuffer::ResetLastSegmentSent(), ns3::LteTestPdcp::SendData(), ns3::LteTestRrc::SendData(), ns3::Icmpv6DestinationUnreachable::Serialize(), ns3::Icmpv6OptionRedirected::Serialize(), ns3::Icmpv6ParameterError::Serialize(), ns3::Icmpv6TimeExceeded::Serialize(), ns3::Icmpv6TooBig::Serialize(), ns3::Icmpv6OptionRedirected::SetPacket(), ns3::CsmaNetDevice::TransmitStart(), and ns3::TcpTxBuffer::UpdateLostCount().

+ Here is the call graph for this function:

◆ GetUid()

uint64_t ns3::Packet::GetUid ( ) const

Returns the packet's Uid.

A packet is allocated a new uid when it is created empty or with zero-filled payload.

Note: This uid is an internal uid and cannot be counted on to provide an accurate counter of how many "simulated packets" of a particular protocol are in the system. It is not trivial to make this uid into such a counter, because of questions such as what should the uid be when the packet is sent over broadcast media, or when fragmentation occurs. If a user wants to trace actual packet counts, he or she should look at e.g. the IP ID field or transport sequence numbers, or other packet or frame counters at other protocol layers.

Returns
an integer identifier which uniquely identifies this packet.

Definition at line 401 of file packet.cc.

References ns3::PacketMetadata::GetUid(), and m_metadata.

Referenced by ns3::dsr::DsrPassiveBuffer::AllEqual(), ns3::aodv::RequestQueue::Drop(), ns3::dsdv::PacketQueue::Drop(), ns3::dsr::DsrErrorBuffer::Drop(), ns3::dsr::DsrPassiveBuffer::Drop(), ns3::dsr::DsrSendBuffer::Drop(), ns3::dsr::DsrErrorBuffer::DropLink(), ns3::dsr::DsrPassiveBuffer::DropLink(), ns3::aodv::RequestQueue::Enqueue(), ns3::dsdv::PacketQueue::Enqueue(), ns3::dsr::DsrErrorBuffer::Enqueue(), ns3::dsr::DsrPassiveBuffer::Enqueue(), ns3::dsr::DsrSendBuffer::Enqueue(), ns3::CsmaChannel::PropagationCompleteEvent(), ns3::CsmaNetDevice::TransmitAbort(), ns3::CsmaNetDevice::TransmitCompleteEvent(), ns3::CsmaChannel::TransmitEnd(), and ns3::CsmaNetDevice::TransmitStart().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ operator=()

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

Basic assignment.

Parameters
oobject to copy
Returns
the copied object

Definition at line 154 of file packet.cc.

References ns3::NixVector::Copy(), m_buffer, m_byteTagList, m_metadata, m_nixVector, and m_packetTagList.

+ Here is the call graph for this function:

◆ PeekHeader() [1/2]

uint32_t ns3::Packet::PeekHeader ( Header & header) const

Deserialize but does not remove the header from the internal buffer.

s This method invokes Header::Deserialize.

Parameters
headera reference to the header to read from the internal buffer.
Returns
the number of bytes read from the packet.

Definition at line 294 of file packet.cc.

References ns3::Buffer::Begin(), ns3::Header::Deserialize(), ns3::ObjectBase::GetInstanceTypeId(), ns3::TypeId::GetName(), m_buffer, and NS_LOG_FUNCTION.

Referenced by ns3::LteRlcAm::DoReceivePdu(), ns3::LteRlcUm::DoReceivePdu(), ns3::Ipv4QueueDiscItem::Hash(), ns3::Ipv6QueueDiscItem::Hash(), ns3::lrwpan::LrWpanMac::IsCoordDest(), ns3::lrwpan::LrWpanMac::IsTxAckReq(), ns3::lrwpan::LrWpanMac::PdDataConfirm(), ns3::lrwpan::LrWpanMac::PdDataIndication(), ns3::lrwpan::LrWpanMac::PrepareRetransmission(), and Ipv4HeaderTest::ReceivePkt().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ PeekHeader() [2/2]

uint32_t ns3::Packet::PeekHeader ( Header & header,
uint32_t size ) const

Deserialize but does not remove the header from the internal buffer.

s This method invokes Header::Deserialize (begin, end) and should be used for variable-length headers (where the size is determined somehow by the caller).

Parameters
headera reference to the header to read from the internal buffer.
sizenumber of bytes to deserialize
Returns
the number of bytes read from the packet.

Definition at line 302 of file packet.cc.

References ns3::Buffer::Begin(), ns3::Header::Deserialize(), ns3::ObjectBase::GetInstanceTypeId(), ns3::TypeId::GetName(), m_buffer, ns3::Buffer::Iterator::Next(), and NS_LOG_FUNCTION.

+ Here is the call graph for this function:

◆ PeekPacketTag()

bool ns3::Packet::PeekPacketTag ( Tag & tag) const

Search a matching tag and call Tag::Deserialize if it is found.

Parameters
tagthe tag to search in this packet
Returns
true if the requested tag is found, false otherwise.

Definition at line 972 of file packet.cc.

References m_packetTagList, and ns3::PacketTagList::Peek().

Referenced by Ipv4FragmentationTest::DoRun(), Ipv6FragmentationTest::DoRun(), and PacketTest::DoRun().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ PeekTrailer()

uint32_t ns3::Packet::PeekTrailer ( Trailer & trailer)

Deserialize but does not remove a trailer from the internal buffer.

This method invokes the Trailer::Deserialize method.

Parameters
trailera reference to the trailer to read from the internal buffer.
Returns
the number of bytes read from the end of the packet.

Definition at line 335 of file packet.cc.

References ns3::Trailer::Deserialize(), ns3::Buffer::End(), ns3::ObjectBase::GetInstanceTypeId(), ns3::TypeId::GetName(), m_buffer, and NS_LOG_FUNCTION.

+ Here is the call graph for this function:

◆ Print()

void ns3::Packet::Print ( std::ostream & os) const

Print the packet contents.

Parameters
osoutput stream in which the data should be printed.

Iterate over the headers and trailers present in this packet, from the first header to the last trailer and invoke, for each of them, the user-provided method Header::DoPrint or Trailer::DoPrint methods.

Definition at line 445 of file packet.cc.

References ns3::PacketMetadata::BeginItem(), ns3::PacketMetadata::Item::current, ns3::PacketMetadata::Item::currentSize, ns3::PacketMetadata::Item::currentTrimmedFromStart, ns3::Chunk::Deserialize(), ns3::ObjectBase::GetAttribute(), ns3::TypeId::GetAttributeN(), ns3::TypeId::GetConstructor(), ns3::TypeId::GetName(), ns3::TypeId::HasConstructor(), ns3::PacketMetadata::ItemIterator::HasNext(), ns3::PacketMetadata::Item::HEADER, ns3::PacketMetadata::Item::isFragment, ns3::Callback< R, UArgs >::IsNull(), m_buffer, m_metadata, ns3::Buffer::Iterator::Next(), ns3::PacketMetadata::ItemIterator::Next(), NS_ASSERT, ns3::PacketMetadata::Item::PAYLOAD, ns3::Buffer::Iterator::Prev(), ns3::PacketMetadata::Item::tid, ns3::PacketMetadata::Item::TRAILER, and ns3::PacketMetadata::Item::type.

Referenced by ns3::operator<<(), and ToString().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ PrintByteTags()

void ns3::Packet::PrintByteTags ( std::ostream & os) const

Iterate over the byte tags present in this packet, and invoke the Print method of each tag stored in the packet.

Parameters
osoutput stream in which the data should be printed.

Definition at line 407 of file packet.cc.

References GetByteTagIterator(), ns3::TypeId::GetConstructor(), ns3::ByteTagIterator::Item::GetEnd(), ns3::TypeId::GetName(), ns3::ByteTagIterator::Item::GetStart(), ns3::ByteTagIterator::Item::GetTag(), ns3::ByteTagIterator::Item::GetTypeId(), ns3::ByteTagIterator::HasNext(), ns3::Callback< R, UArgs >::IsNull(), ns3::ByteTagIterator::Next(), NS_ASSERT, and ns3::Tag::Print().

+ Here is the call graph for this function:

◆ PrintPacketTags()

void ns3::Packet::PrintPacketTags ( std::ostream & os) const

Print the list of packet tags.

Parameters
osthe stream on which to print the tags.
See also
Packet::AddPacketTag, Packet::RemovePacketTag, Packet::PeekPacketTag, Packet::RemoveAllPacketTags

Definition at line 986 of file packet.cc.

References ns3::TypeId::GetConstructor(), GetPacketTagIterator(), ns3::PacketTagIterator::Item::GetTag(), ns3::PacketTagIterator::Item::GetTypeId(), ns3::TypeId::HasConstructor(), ns3::PacketTagIterator::HasNext(), ns3::Callback< R, UArgs >::IsNull(), ns3::PacketTagIterator::Next(), NS_ASSERT, and ns3::Tag::Print().

+ Here is the call graph for this function:

◆ RemoveAllByteTags()

void ns3::Packet::RemoveAllByteTags ( )

Remove all byte tags stored in this packet.

Definition at line 382 of file packet.cc.

References m_byteTagList, NS_LOG_FUNCTION, and ns3::ByteTagList::RemoveAll().

Referenced by DynamicNeighborCacheTest::DoRun(), Ipv4ForwardingTest::DoRun(), Ipv4HeaderTest::DoRun(), Ipv4RawSocketImplTest::DoRun(), Ipv4RipTest::DoRun(), Ipv6ForwardingTest::DoRun(), Ipv6RawSocketImplTest::DoRun(), Ipv6RipngTest::DoRun(), SixlowpanHc1ImplTest::DoRun(), SixlowpanIphcImplTest::DoRun(), Udp6SocketImplTest::DoRun(), and UdpSocketImplTest::DoRun().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ RemoveAllPacketTags()

void ns3::Packet::RemoveAllPacketTags ( )

Remove all packet tags.

Definition at line 979 of file packet.cc.

References m_packetTagList, NS_LOG_FUNCTION, and ns3::PacketTagList::RemoveAll().

Referenced by PacketTest::DoRun().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ RemoveAtEnd()

void ns3::Packet::RemoveAtEnd ( uint32_t size)

Remove size bytes from the end of the current packet.

It is safe to remove more bytes than are present in the packet.

Parameters
sizenumber of bytes from remove

Definition at line 365 of file packet.cc.

References m_buffer, m_metadata, NS_LOG_FUNCTION, ns3::Buffer::RemoveAtEnd(), and ns3::PacketMetadata::RemoveAtEnd().

+ Here is the call graph for this function:

◆ RemoveAtStart()

void ns3::Packet::RemoveAtStart ( uint32_t size)

Remove size bytes from the start of the current packet.

It is safe to remove more bytes than are present in the packet.

Parameters
sizenumber of bytes from remove

Definition at line 373 of file packet.cc.

References ns3::ByteTagList::Adjust(), m_buffer, m_byteTagList, m_metadata, NS_LOG_FUNCTION, ns3::Buffer::RemoveAtStart(), and ns3::PacketMetadata::RemoveAtStart().

Referenced by ns3::TcpTxBuffer::SplitItems().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ RemoveHeader() [1/2]

uint32_t ns3::Packet::RemoveHeader ( Header & header)

Deserialize and remove the header from the internal buffer.

This method invokes Header::Deserialize (begin) and should be used for fixed-length headers.

Parameters
headera reference to the header to remove from the internal buffer.
Returns
the number of bytes removed from the packet.

Definition at line 283 of file packet.cc.

References ns3::ByteTagList::Adjust(), ns3::Buffer::Begin(), ns3::Header::Deserialize(), ns3::ObjectBase::GetInstanceTypeId(), ns3::TypeId::GetName(), m_buffer, m_byteTagList, m_metadata, NS_LOG_FUNCTION, ns3::Buffer::RemoveAtStart(), and ns3::PacketMetadata::RemoveHeader().

Referenced by EpsGtpuHeaderTestCase::DoRun(), HandoverPreparationInfoTestCase::DoRun(), MeasurementReportTestCase::DoRun(), OlsrHelloTestCase::DoRun(), OlsrHnaTestCase::DoRun(), OlsrMidTestCase::DoRun(), OlsrTcTestCase::DoRun(), RrcConnectionReconfigurationCompleteTestCase::DoRun(), RrcConnectionReconfigurationTestCase::DoRun(), RrcConnectionReestablishmentCompleteTestCase::DoRun(), RrcConnectionReestablishmentRequestTestCase::DoRun(), RrcConnectionReestablishmentTestCase::DoRun(), RrcConnectionRejectTestCase::DoRun(), RrcConnectionRequestTestCase::DoRun(), RrcConnectionSetupCompleteTestCase::DoRun(), and RrcConnectionSetupTestCase::DoRun().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ RemoveHeader() [2/2]

uint32_t ns3::Packet::RemoveHeader ( Header & header,
uint32_t size )

Deserialize and remove the header from the internal buffer.

This method invokes Header::Deserialize (begin, end) and should be used for variable-length headers (where the size is determined somehow by the caller).

Parameters
headera reference to the header to remove from the internal buffer.
sizenumber of bytes to deserialize
Returns
the number of bytes removed from the packet.

Definition at line 269 of file packet.cc.

References ns3::ByteTagList::Adjust(), ns3::Buffer::Begin(), ns3::Header::Deserialize(), ns3::ObjectBase::GetInstanceTypeId(), ns3::TypeId::GetName(), m_buffer, m_byteTagList, m_metadata, ns3::Buffer::Iterator::Next(), NS_LOG_FUNCTION, ns3::Buffer::RemoveAtStart(), and ns3::PacketMetadata::RemoveHeader().

+ Here is the call graph for this function:

◆ RemovePacketTag()

bool ns3::Packet::RemovePacketTag ( Tag & tag)

Remove a packet tag.

Parameters
tagthe packet tag type to remove from this packet. The tag parameter is set to the value of the tag found.
Returns
true if the requested tag is found, false otherwise.

Definition at line 956 of file packet.cc.

References ns3::ObjectBase::GetInstanceTypeId(), ns3::TypeId::GetName(), ns3::Tag::GetSerializedSize(), m_packetTagList, NS_LOG_FUNCTION, and ns3::PacketTagList::Remove().

Referenced by PacketTest::DoRun(), ns3::dot11s::HwmpProtocol::ProactivePathResolved(), and ns3::dot11s::HwmpProtocol::ReactivePathResolved().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ RemoveTrailer()

uint32_t ns3::Packet::RemoveTrailer ( Trailer & trailer)

Remove a deserialized trailer from the internal buffer.

This method invokes the Deserialize method.

Parameters
trailera reference to the trailer to remove from the internal buffer.
Returns
the number of bytes removed from the end of the packet.

Definition at line 325 of file packet.cc.

References ns3::Trailer::Deserialize(), ns3::Buffer::End(), ns3::ObjectBase::GetInstanceTypeId(), ns3::TypeId::GetName(), m_buffer, m_metadata, NS_LOG_FUNCTION, ns3::Buffer::RemoveAtEnd(), and ns3::PacketMetadata::RemoveTrailer().

+ Here is the call graph for this function:

◆ ReplacePacketTag()

bool ns3::Packet::ReplacePacketTag ( Tag & tag)

Replace the value of a packet tag.

Parameters
tagthe packet tag type to replace. To get the old value of the tag, use PeekPacketTag first.
Returns
true if the requested tag is found, false otherwise. If the tag isn't found, Add is performed instead (so the packet is guaranteed to have the new tag value either way).

Definition at line 964 of file packet.cc.

References ns3::ObjectBase::GetInstanceTypeId(), ns3::TypeId::GetName(), ns3::Tag::GetSerializedSize(), m_packetTagList, NS_LOG_FUNCTION, and ns3::PacketTagList::Replace().

+ Here is the call graph for this function:

◆ Serialize()

uint32_t ns3::Packet::Serialize ( uint8_t * buffer,
uint32_t maxSize ) const

Serialize a packet, tags, and metadata into a byte buffer.

Parameters
buffera raw byte buffer to which the packet will be serialized
maxSizethe max size of the buffer for bounds checking
Returns
one if all data were serialized, zero if buffer size was too small.

Definition at line 652 of file packet.cc.

References ns3::Buffer::GetSerializedSize(), ns3::ByteTagList::GetSerializedSize(), ns3::NixVector::GetSerializedSize(), ns3::PacketMetadata::GetSerializedSize(), ns3::PacketTagList::GetSerializedSize(), m_buffer, m_byteTagList, m_metadata, m_nixVector, m_packetTagList, ns3::Buffer::Serialize(), ns3::ByteTagList::Serialize(), ns3::NixVector::Serialize(), ns3::PacketMetadata::Serialize(), and ns3::PacketTagList::Serialize().

+ Here is the call graph for this function:

◆ SetNixVector()

void ns3::Packet::SetNixVector ( Ptr< NixVector > nixVector) const

Set the packet nix-vector.

Note
Note: This function supports a temporary solution to a specific problem in this generic class, i.e. how to associate something specific like nix-vector with a packet. This design methodology should not be followed, and is only here as an impetus to fix this general issue.
Warning
For real this function is not const, as it is the setter for a mutable variable member. The const qualifier is needed to set a private mutable variable of const objects.
Parameters
nixVectorthe nix vector

Definition at line 245 of file packet.cc.

References m_nixVector.

◆ ToString()

std::string ns3::Packet::ToString ( ) const

Return a string representation of the packet.

An empty string is returned if you haven't called EnablePrinting ()

Returns
String representation

Definition at line 437 of file packet.cc.

References Print().

+ Here is the call graph for this function:

Member Data Documentation

◆ m_buffer

◆ m_byteTagList

◆ m_globalUid

uint32_t ns3::Packet::m_globalUid = 0
staticprivate

Global counter of packets Uid.

Definition at line 787 of file packet.h.

Referenced by Packet(), Packet(), and Packet().

◆ m_metadata

◆ m_nixVector

Ptr<NixVector> ns3::Packet::m_nixVector
mutableprivate

the packet's Nix vector

Definition at line 785 of file packet.h.

Referenced by Packet(), Deserialize(), GetNixVector(), GetSerializedSize(), operator=(), Serialize(), and SetNixVector().

◆ m_packetTagList


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