network packets More...
#include "packet.h"
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< Packet > | Copy () 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< Packet > | CreateFragment (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< NixVector > | GetNixVector () 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. | |
Packet & | operator= (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. | |
SimpleRefCount & | operator= (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< NixVector > | m_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. | |
network packets
Each network packet contains a byte buffer, a set of byte tags, a set of packet tags, and metadata.
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
typedef void(* ns3::Packet::AddressTracedCallback) (Ptr< const Packet > packet, const Address &address) |
TracedCallback signature for packet and Address.
[in] | packet | The packet. |
[in] | address | The address. |
typedef void(* ns3::Packet::Mac48AddressTracedCallback) (Ptr< const Packet > packet, Mac48Address mac) |
TracedCallback signature for packet and Mac48Address.
[in] | packet | The packet. |
[in] | mac | The Mac48Address. |
TracedCallback signature for packet and SINR.
[in] | packet | The packet. |
[in] | sinr | The received SINR. |
TracedCallback signature for changes in packet size.
[in] | oldSize | The previous packet's size. |
[in] | newSize | The actual packet's size. |
TracedCallback signature for Ptr<Packet>
[in] | packet | The packet. |
typedef void(* ns3::Packet::TwoAddressTracedCallback) (const Ptr< const Packet > packet, const Address &srcAddress, const Address &destAddress) |
TracedCallback signature for packet and source/destination addresses.
[in] | packet | The packet. |
[in] | srcAddress | The source address. |
[in] | destAddress | The destination address. |
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().
ns3::Packet::Packet | ( | const Packet & | o | ) |
Copy constructor.
o | object to copy |
Definition at line 144 of file packet.cc.
References ns3::NixVector::Copy(), and m_nixVector.
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).
size | the size of the zero-filled payload |
Definition at line 168 of file packet.cc.
References m_globalUid.
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
buffer | the serialized packet to be created |
size | the size of the packet for deserialization |
magic | allows packet deserialization; asserts when set to false |
Definition at line 184 of file packet.cc.
References Deserialize(), and NS_ASSERT.
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.
buffer | the data to store in the packet. |
size | the 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().
|
private |
Concatenate the input packet at the end of the current packet.
This does not alter the uid of either packet.
packet | packet 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().
void ns3::Packet::AddByteTag | ( | const Tag & | tag | ) | const |
Tag each byte included in this packet with a new byte tag.
tag | the 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().
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:
tag | the new tag to add to this packet |
start | the position of the first byte tagged by this tag |
end | the 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().
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.
header | a 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().
void ns3::Packet::AddPacketTag | ( | const Tag & | tag | ) | const |
Add a packet tag.
tag | the 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().
void ns3::Packet::AddPaddingAtEnd | ( | uint32_t | size | ) |
Add a zero-filled padding to the packet.
size | number 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.
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.
trailer | a 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().
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.
Definition at line 579 of file packet.cc.
References ns3::PacketMetadata::BeginItem(), m_buffer, and m_metadata.
performs a COW copy of the packet.
The returns packet will behave like an independent copy of the original packet, even though they both share the same datasets internally.
Definition at line 120 of file packet.cc.
References ns3::PacketTagIterator::Packet.
Referenced by ns3::HalfDuplexIdealPhySignalParameters::HalfDuplexIdealPhySignalParameters(), ns3::dsr::DsrRouting::CancelPacketTimerNextHop(), ns3::WimaxMacQueue::Dequeue(), WifiFilsFrameTest::GetFilsDiscFrame(), ns3::TcpTxItem::GetPacketCopy(), ns3::WifiMpdu::GetProtocolDataUnit(), ns3::dsr::DsrRouting::NetworkScheduleTimerExpire(), ns3::lrwpan::LrWpanMac::PdDataConfirm(), ns3::lrwpan::LrWpanMac::PdDataIndication(), ns3::WimaxMacQueue::Peek(), ns3::WimaxMacQueue::Peek(), ns3::WimaxMacQueue::Peek(), ns3::WimaxMacQueue::Peek(), ns3::lrwpan::LrWpanMac::PrepareRetransmission(), ns3::dsr::DsrRouting::ScheduleLinkPacketRetry(), ns3::dsr::DsrRouting::ScheduleNetworkPacketRetry(), ns3::dsr::DsrRouting::SchedulePassivePacketRetry(), ns3::dsr::DsrRouting::SendPacketFromBuffer(), ns3::dsr::DsrRouting::SendRealDown(), and ns3::lrwpan::LrWpanMac::SetLrWpanMacState().
void ns3::Packet::CopyData | ( | std::ostream * | os, |
uint32_t | size ) const |
Copy the packet contents to an output stream.
os | pointer to output stream in which we want to write the packet data. |
size | the 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.
Copy the packet contents to a byte buffer.
buffer | a pointer to a byte buffer where the packet data should be copied. |
size | the size of the byte buffer. |
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().
Create a new packet which contains a fragment of the original packet.
The returned packet shares the same uid as this packet.
start | offset from start of packet to start of fragment to create |
length | length of fragment to create |
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().
Deserializes a packet.
[in] | buffer | the input buffer. |
[in] | size | the buffer size. |
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().
|
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.
|
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().
bool ns3::Packet::FindFirstMatchingByteTag | ( | Tag & | tag | ) | const |
Finds the first tag matching the parameter Tag type.
tag | the byte tag type to search in this packet |
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().
ByteTagIterator ns3::Packet::GetByteTagIterator | ( | ) | const |
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().
Get the packet nix-vector.
See the comment on SetNixVector
Definition at line 251 of file packet.cc.
References m_nixVector.
Referenced by CreateFragment().
PacketTagIterator ns3::Packet::GetPacketTagIterator | ( | ) | const |
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().
uint32_t ns3::Packet::GetSerializedSize | ( | ) | const |
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.
|
inline |
Returns the the size in bytes of the packet (including the zero-filled initial payload).
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().
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.
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().
Basic assignment.
o | object to copy |
Definition at line 154 of file packet.cc.
References ns3::NixVector::Copy(), m_buffer, m_byteTagList, m_metadata, m_nixVector, and m_packetTagList.
Deserialize but does not remove the header from the internal buffer.
s This method invokes Header::Deserialize.
header | a reference to the header to read from the internal buffer. |
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().
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).
header | a reference to the header to read from the internal buffer. |
size | number of bytes to deserialize |
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.
bool ns3::Packet::PeekPacketTag | ( | Tag & | tag | ) | const |
Search a matching tag and call Tag::Deserialize if it is found.
tag | the tag to search in this packet |
Definition at line 972 of file packet.cc.
References m_packetTagList, and ns3::PacketTagList::Peek().
Referenced by Ipv4FragmentationTest::DoRun(), Ipv6FragmentationTest::DoRun(), and PacketTest::DoRun().
Deserialize but does not remove a trailer from the internal buffer.
This method invokes the Trailer::Deserialize method.
trailer | a reference to the trailer to read from the internal buffer. |
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.
void ns3::Packet::Print | ( | std::ostream & | os | ) | const |
Print the packet contents.
os | output 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().
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.
os | output 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().
void ns3::Packet::PrintPacketTags | ( | std::ostream & | os | ) | const |
Print the list of packet tags.
os | the stream on which to print the tags. |
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().
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().
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().
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.
size | number 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().
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.
size | number 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().
Deserialize and remove the header from the internal buffer.
This method invokes Header::Deserialize (begin) and should be used for fixed-length headers.
header | a reference to the header to remove from the internal buffer. |
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().
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).
header | a reference to the header to remove from the internal buffer. |
size | number of bytes to deserialize |
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().
bool ns3::Packet::RemovePacketTag | ( | Tag & | tag | ) |
Remove a packet tag.
tag | the packet tag type to remove from this packet. The tag parameter is set to the value of the tag found. |
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().
Remove a deserialized trailer from the internal buffer.
This method invokes the Deserialize method.
trailer | a reference to the trailer to remove from the internal buffer. |
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().
bool ns3::Packet::ReplacePacketTag | ( | Tag & | tag | ) |
Replace the value of a packet tag.
tag | the packet tag type to replace. To get the old value of the tag, use PeekPacketTag first. |
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().
Serialize a packet, tags, and metadata into a byte buffer.
buffer | a raw byte buffer to which the packet will be serialized |
maxSize | the max size of the buffer for bounds checking |
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().
Set the packet nix-vector.
nixVector | the nix vector |
Definition at line 245 of file packet.cc.
References m_nixVector.
std::string ns3::Packet::ToString | ( | ) | const |
|
private |
the packet buffer (it's actual contents)
Definition at line 779 of file packet.h.
Referenced by Packet(), AddAtEnd(), AddHeader(), AddPaddingAtEnd(), AddTrailer(), BeginItem(), CopyData(), CopyData(), CreateFragment(), Deserialize(), GetSerializedSize(), GetSize(), operator=(), PeekHeader(), PeekHeader(), PeekTrailer(), Print(), RemoveAtEnd(), RemoveAtStart(), RemoveHeader(), RemoveHeader(), RemoveTrailer(), and Serialize().
|
private |
the ByteTag list
Definition at line 780 of file packet.h.
Referenced by AddAtEnd(), AddByteTag(), AddByteTag(), AddHeader(), AddPaddingAtEnd(), AddTrailer(), CreateFragment(), Deserialize(), GetByteTagIterator(), GetSerializedSize(), operator=(), RemoveAllByteTags(), RemoveAtStart(), RemoveHeader(), RemoveHeader(), and Serialize().
|
staticprivate |
|
private |
the packet's metadata
Definition at line 782 of file packet.h.
Referenced by AddAtEnd(), AddHeader(), AddPaddingAtEnd(), AddTrailer(), BeginItem(), CreateFragment(), Deserialize(), GetSerializedSize(), GetUid(), operator=(), Print(), RemoveAtEnd(), RemoveAtStart(), RemoveHeader(), RemoveHeader(), RemoveTrailer(), and Serialize().
the packet's Nix vector
Definition at line 785 of file packet.h.
Referenced by Packet(), Deserialize(), GetNixVector(), GetSerializedSize(), operator=(), Serialize(), and SetNixVector().
|
private |
the packet's Tag list
Definition at line 781 of file packet.h.
Referenced by AddPacketTag(), CreateFragment(), Deserialize(), GetPacketTagIterator(), GetSerializedSize(), operator=(), PeekPacketTag(), RemoveAllPacketTags(), RemovePacketTag(), ReplacePacketTag(), and Serialize().