21 #include "ns3/packet.h"
22 #include "ns3/uinteger.h"
23 #include "ns3/simulator.h"
39 static TypeId GetTypeId (
void);
40 virtual TypeId GetInstanceTypeId (
void)
const;
41 virtual uint32_t GetSerializedSize (
void)
const;
42 virtual void Serialize (
TagBuffer i)
const;
44 virtual void Print (std::ostream &os)
const;
51 void SetSimpleValue (uint8_t value);
56 uint8_t GetSimpleValue (
void)
const;
66 .AddConstructor<MyTag> ()
67 .AddAttribute (
"SimpleValue",
71 MakeUintegerChecker<uint8_t> ())
93 m_simpleValue = i.
ReadU8 ();
98 os <<
"v=" << (uint32_t)m_simpleValue;
103 m_simpleValue = value;
108 return m_simpleValue;
112 int main (
int argc,
char *argv[])
133 std::cout << std::endl;
A simple example of an Tag implementation.
virtual void Serialize(TagBuffer i) const
static TypeId GetTypeId(void)
Get the type ID.
void SetSimpleValue(uint8_t value)
Set the tag value.
uint8_t m_simpleValue
tag value
virtual TypeId GetInstanceTypeId(void) const
Get the most derived TypeId for this Object.
uint8_t GetSimpleValue(void) const
Get the tag value.
virtual uint32_t GetSerializedSize(void) const
virtual void Print(std::ostream &os) const
virtual void Deserialize(TagBuffer i)
A class for an empty attribute value.
void PrintPacketTags(std::ostream &os) const
Print the list of packet tags.
void AddPacketTag(const Tag &tag) const
Add a packet tag.
bool PeekPacketTag(Tag &tag) const
Search a matching tag and call Tag::Deserialize if it is found.
Ptr< Packet > Copy(void) const
performs a COW copy of the packet.
TAG_BUFFER_INLINE void WriteU8(uint8_t v)
TAG_BUFFER_INLINE uint8_t ReadU8(void)
tag a set of bytes in a packet
a unique identifier for an interface.
TypeId SetParent(TypeId tid)
Set the parent TypeId.
#define NS_ASSERT(condition)
At runtime, in debugging builds, if this condition is not true, the program prints the source file,...
Ptr< const AttributeAccessor > MakeUintegerAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method.
void Print(ComponentCarrier cc)
Every class exported by the ns3 library is enclosed in the ns3 namespace.