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