A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
flow-id-tag.cc
Go to the documentation of this file.
1/*
2 * Copyright (c) 2008 INRIA
3 *
4 * SPDX-License-Identifier: GPL-2.0-only
5 *
6 * Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
7 */
8#include "flow-id-tag.h"
9
10#include "ns3/log.h"
11
12namespace ns3
13{
14
15NS_LOG_COMPONENT_DEFINE("FlowIdTag");
16
18
19TypeId
21{
22 static TypeId tid = TypeId("ns3::FlowIdTag")
23 .SetParent<Tag>()
24 .SetGroupName("Network")
25 .AddConstructor<FlowIdTag>();
26 return tid;
27}
28
31{
32 return GetTypeId();
33}
34
37{
38 NS_LOG_FUNCTION(this);
39 return 4;
40}
41
42void
44{
45 NS_LOG_FUNCTION(this << &buf);
46 buf.WriteU32(m_flowId);
47}
48
49void
51{
52 NS_LOG_FUNCTION(this << &buf);
53 m_flowId = buf.ReadU32();
54}
55
56void
57FlowIdTag::Print(std::ostream& os) const
58{
59 NS_LOG_FUNCTION(this << &os);
60 os << "FlowId=" << m_flowId;
61}
62
64 : Tag()
65{
66 NS_LOG_FUNCTION(this);
67}
68
70 : Tag(),
71 m_flowId(id)
72{
73 NS_LOG_FUNCTION(this << id);
74}
75
76void
78{
79 NS_LOG_FUNCTION(this << id);
80 m_flowId = id;
81}
82
85{
86 NS_LOG_FUNCTION(this);
87 return m_flowId;
88}
89
92{
94 static uint32_t nextFlowId = 1;
95 uint32_t flowId = nextFlowId;
96 nextFlowId++;
97 return flowId;
98}
99
100} // namespace ns3
void Deserialize(TagBuffer buf) override
uint32_t GetFlowId() const
Gets the flow id for the tag.
void Serialize(TagBuffer buf) const override
void SetFlowId(uint32_t flowId)
Sets the flow id for the tag.
TypeId GetInstanceTypeId() const override
Get the most derived TypeId for this Object.
static TypeId GetTypeId()
Get the type ID.
void Print(std::ostream &os) const override
uint32_t m_flowId
Flow ID.
Definition flow-id-tag.h:54
static uint32_t AllocateFlowId()
Uses a static variable to generate sequential flow id.
uint32_t GetSerializedSize() const override
read and write tag data
Definition tag-buffer.h:41
TAG_BUFFER_INLINE uint32_t ReadU32()
Definition tag-buffer.h:206
TAG_BUFFER_INLINE void WriteU32(uint32_t v)
Definition tag-buffer.h:176
tag a set of bytes in a packet
Definition tag.h:28
a unique identifier for an interface.
Definition type-id.h:48
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition type-id.cc:1001
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition log.h:191
#define NS_LOG_FUNCTION_NOARGS()
Output the name of the function.
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by ",...
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Definition object-base.h:35
Every class exported by the ns3 library is enclosed in the ns3 namespace.