19 #include "ns3/packet.h"
20 #include "ns3/simulator.h"
22 #include "ns3/uinteger.h"
40 TypeId GetInstanceTypeId()
const override;
41 uint32_t GetSerializedSize()
const override;
42 void Serialize(
TagBuffer i)
const override;
44 void Print(std::ostream& os)
const override;
51 void SetSimpleValue(uint8_t value);
56 uint8_t GetSimpleValue()
const;
67 .AddConstructor<MyTag>()
68 .AddAttribute(
"SimpleValue",
72 MakeUintegerChecker<uint8_t>());
97 m_simpleValue = i.
ReadU8();
103 os <<
"v=" << (uint32_t)m_simpleValue;
109 m_simpleValue = value;
115 return m_simpleValue;
119 main(
int argc,
char* argv[])
140 std::cout << std::endl;
A simple example of an Tag implementation.
static TypeId GetTypeId()
Get the type ID.
void Serialize(TagBuffer i) const override
TypeId GetInstanceTypeId() const override
Get the most derived TypeId for this Object.
uint32_t GetSerializedSize() const override
uint8_t GetSimpleValue() const
Get the tag value.
void SetSimpleValue(uint8_t value)
Set the tag value.
uint8_t m_simpleValue
tag value
void Print(std::ostream &os) const override
void Deserialize(TagBuffer i) override
A class for an empty attribute value.
Ptr< Packet > Copy() const
performs a COW copy of the packet.
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.
TAG_BUFFER_INLINE void WriteU8(uint8_t v)
TAG_BUFFER_INLINE uint8_t ReadU8()
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,...
void Print(ComponentCarrier cc)
Every class exported by the ns3 library is enclosed in the ns3 namespace.
Ptr< const AttributeAccessor > MakeUintegerAccessor(T1 a1)