# HG changeset patch # User Mathieu Lacage # Date 1212535217 25200 # Node ID 1a754d09c4ba162e0839ce54ff312db60a0f6dd1 # Parent 72be532011a34916eb1c23eed1d310e88caf9c62 bug 200: Packet::PrintTags is not implemented. diff -r 72be532011a3 -r 1a754d09c4ba samples/main-packet-tag.cc --- a/samples/main-packet-tag.cc Mon Jun 02 10:51:55 2008 -0700 +++ b/samples/main-packet-tag.cc Tue Jun 03 16:20:17 2008 -0700 @@ -33,6 +33,7 @@ virtual uint32_t GetSerializedSize (void) const; virtual void Serialize (TagBuffer i) const; virtual void Deserialize (TagBuffer i); + virtual void Print (std::ostream &os) const; // these are our accessors to our tag structure void SetSimpleValue (uint8_t value); @@ -76,6 +77,11 @@ m_simpleValue = i.ReadU8 (); } void +MyTag::Print (std::ostream &os) const +{ + os << "v=" << (uint32_t)m_simpleValue; +} +void MyTag::SetSimpleValue (uint8_t value) { m_simpleValue = value; @@ -94,7 +100,7 @@ tag.SetSimpleValue (0x56); // store the tag in a packet. - Ptr p = Create (); + Ptr p = Create (100); p->AddTag (tag); // create a copy of the packet diff -r 72be532011a3 -r 1a754d09c4ba src/common/packet.cc --- a/src/common/packet.cc Mon Jun 02 10:51:55 2008 -0700 +++ b/src/common/packet.cc Tue Jun 03 16:20:17 2008 -0700 @@ -291,8 +291,30 @@ void Packet::PrintTags (std::ostream &os) const { - // XXX: - //m_tagList.Print (os, " "); + TagIterator i = GetTagIterator (); + while (i.HasNext ()) + { + TagIterator::Item item = i.Next (); + os << item.GetTypeId ().GetName () << " [" << item.GetStart () << "-" << item.GetEnd () << "]"; + Callback constructor = item.GetTypeId ().GetConstructor (); + if (constructor.IsNull ()) + { + if (i.HasNext ()) + { + os << " "; + } + continue; + } + Tag *tag = dynamic_cast (constructor ()); + NS_ASSERT (tag != 0); + os << " "; + tag->Print (os); + if (i.HasNext ()) + { + os << " "; + } + delete tag; + } } void @@ -576,6 +598,9 @@ } } } + virtual void Print (std::ostream &os) const { + os << N; + } ATestTag () : ATestTagBase () {} }; diff -r 72be532011a3 -r 1a754d09c4ba src/common/tag.h --- a/src/common/tag.h Mon Jun 02 10:51:55 2008 -0700 +++ b/src/common/tag.h Tue Jun 03 16:20:17 2008 -0700 @@ -61,6 +61,13 @@ * Tag::Serialize. */ virtual void Deserialize (TagBuffer i) = 0; + + /** + * \param os the stream to print to + * + * This method is typically invoked from the Packet::PrintTags method + */ + virtual void Print (std::ostream &os) const = 0; }; } // namespace ns3 diff -r 72be532011a3 -r 1a754d09c4ba src/contrib/delay-jitter-estimation.cc --- a/src/contrib/delay-jitter-estimation.cc Mon Jun 02 10:51:55 2008 -0700 +++ b/src/contrib/delay-jitter-estimation.cc Tue Jun 03 16:20:17 2008 -0700 @@ -16,7 +16,7 @@ virtual uint32_t GetSerializedSize (void) const; virtual void Serialize (TagBuffer i) const; virtual void Deserialize (TagBuffer i); - + virtual void Print (std::ostream &os) const; Time GetTxTime (void) const; private: @@ -62,6 +62,11 @@ { m_creationTime = i.ReadU64 (); } +void +DelayJitterEstimationTimestampTag::Print (std::ostream &os) const +{ + os << "CreationTime=" << m_creationTime; +} Time DelayJitterEstimationTimestampTag::GetTxTime (void) const { diff -r 72be532011a3 -r 1a754d09c4ba src/devices/wifi/mac-low.cc --- a/src/devices/wifi/mac-low.cc Mon Jun 02 10:51:55 2008 -0700 +++ b/src/devices/wifi/mac-low.cc Tue Jun 03 16:20:17 2008 -0700 @@ -47,6 +47,7 @@ virtual uint32_t GetSerializedSize (void) const; virtual void Serialize (TagBuffer i) const; virtual void Deserialize (TagBuffer i); + virtual void Print (std::ostream &os) const; void Set (double snr); double Get (void) const; @@ -89,6 +90,11 @@ m_snr = i.ReadDouble (); } void +SnrTag::Print (std::ostream &os) const +{ + os << "Snr=" << m_snr; +} +void SnrTag::Set (double snr) { m_snr = snr; diff -r 72be532011a3 -r 1a754d09c4ba src/devices/wifi/wifi-remote-station-manager.cc --- a/src/devices/wifi/wifi-remote-station-manager.cc Mon Jun 02 10:51:55 2008 -0700 +++ b/src/devices/wifi/wifi-remote-station-manager.cc Tue Jun 03 16:20:17 2008 -0700 @@ -319,6 +319,7 @@ virtual uint32_t GetSerializedSize (void) const; virtual void Serialize (TagBuffer i) const; virtual void Deserialize (TagBuffer i); + virtual void Print (std::ostream &os) const; private: WifiMode m_rtsMode; WifiMode m_dataMode; @@ -381,6 +382,11 @@ i.Read ((uint8_t *)&m_rtsMode, sizeof (WifiMode)); i.Read ((uint8_t *)&m_dataMode, sizeof (WifiMode)); } +void +TxModeTag::Print (std::ostream &os) const +{ + os << "Rts=" << m_rtsMode << ", Data=" << m_dataMode; +} } // namespace ns3 diff -r 72be532011a3 -r 1a754d09c4ba src/node/socket.cc --- a/src/node/socket.cc Mon Jun 02 10:51:55 2008 -0700 +++ b/src/node/socket.cc Tue Jun 03 16:20:17 2008 -0700 @@ -311,6 +311,11 @@ { m_address.Deserialize (i); } +void +SocketRxAddressTag::Print (std::ostream &os) const +{ + os << "address=" << m_address; +} SocketIpTtlTag::SocketIpTtlTag () { @@ -359,5 +364,10 @@ { m_ttl = i.ReadU8 (); } +void +SocketIpTtlTag::Print (std::ostream &os) const +{ + os << "Ttl=" << (uint32_t) m_ttl; +} }//namespace ns3 diff -r 72be532011a3 -r 1a754d09c4ba src/node/socket.h --- a/src/node/socket.h Mon Jun 02 10:51:55 2008 -0700 +++ b/src/node/socket.h Tue Jun 03 16:20:17 2008 -0700 @@ -398,6 +398,7 @@ virtual uint32_t GetSerializedSize (void) const; virtual void Serialize (TagBuffer i) const; virtual void Deserialize (TagBuffer i); + virtual void Print (std::ostream &os) const; private: Address m_address; @@ -419,6 +420,7 @@ virtual uint32_t GetSerializedSize (void) const; virtual void Serialize (TagBuffer i) const; virtual void Deserialize (TagBuffer i); + virtual void Print (std::ostream &os) const; private: uint8_t m_ttl; diff -r 72be532011a3 -r 1a754d09c4ba utils/bench-packets.cc --- a/utils/bench-packets.cc Mon Jun 02 10:51:55 2008 -0700 +++ b/utils/bench-packets.cc Tue Jun 03 16:20:17 2008 -0700 @@ -149,6 +149,9 @@ buf.ReadU8 (); } } + virtual void Print (std::ostream &os) const { + os << "N=" << N; + } BenchTag () : Tag () {} };