diff --git a/src/common/packet.cc b/src/common/packet.cc index 9b7f2f658..1b7df9993 100644 --- a/src/common/packet.cc +++ b/src/common/packet.cc @@ -38,16 +38,17 @@ Packet::Packet (uint32_t size) { m_global_uid++; } -Packet::Packet (Buffer buffer, Tags tags) +Packet::Packet (Buffer buffer, Tags tags, uint32_t uid) : m_buffer (buffer), - m_tags (tags) + m_tags (tags), + m_uid (uid) {} Packet Packet::createFragment (uint32_t start, uint32_t length) const { Buffer tmp = m_buffer.createFragment (start, length); - return Packet (tmp, m_tags); + return Packet (tmp, m_tags, m_uid); } uint32_t @@ -129,7 +130,7 @@ Packet::peekData (void) const } uint32_t -Packet::getUid (void) +Packet::getUid (void) const { return m_uid; } diff --git a/src/common/packet.h b/src/common/packet.h index edc49bb4e..9e3967fe6 100644 --- a/src/common/packet.h +++ b/src/common/packet.h @@ -87,7 +87,8 @@ namespace ns3 { class Packet { public: /** - * Create an empty packet. + * Create an empty packet with a new uid (as returned + * by getUid). */ Packet (); /** @@ -95,14 +96,15 @@ public: * 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. + * bytes. The packet is allocated with a new uid (as + * returned by getUid). * * \param size the size of the zero-filled payload */ Packet (uint32_t size); /** * Create a new packet which contains a fragment of the original - * packet. + * packet. The returned packet shares the same uid as this packet. * * \param start offset from start of packet to start of fragment to create * \param length length of fragment to create @@ -183,7 +185,7 @@ public: void removeAllTags (void); /** * Concatenate the input packet at the end of the current - * packet. + * packet. This does not alter the uid of either packet. * * \param packet packet to concatenate */ @@ -191,7 +193,7 @@ public: /** * Concatenate the fragment of the input packet identified * by the offset and size parameters at the end of the current - * packet. + * packet. This does not alter the uid of either packet. * * \param packet to concatenate * \param offset offset of fragment to copy from the start of the input packet @@ -223,9 +225,16 @@ public: */ uint8_t const *peekData (void) const; + /** + * A packet is allocated a new uid when it is created + * empty or with zero-filled payload. + * + * \returns an integer identifier which uniquely + * identifies this packet. + */ uint32_t getUid (void) const; private: - Packet (Buffer buffer, Tags tags); + Packet (Buffer buffer, Tags tags, uint32_t uid); Buffer m_buffer; Tags m_tags; uint32_t m_uid;