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 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation;
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program; if not, write to the Free Software
15 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16 *
17 * Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
18 */
19#include "flow-id-tag.h"
20
21#include "ns3/log.h"
22
23namespace ns3
24{
25
26NS_LOG_COMPONENT_DEFINE("FlowIdTag");
27
29
30TypeId
32{
33 static TypeId tid = TypeId("ns3::FlowIdTag")
34 .SetParent<Tag>()
35 .SetGroupName("Network")
36 .AddConstructor<FlowIdTag>();
37 return tid;
38}
39
42{
43 return GetTypeId();
44}
45
48{
49 NS_LOG_FUNCTION(this);
50 return 4;
51}
52
53void
55{
56 NS_LOG_FUNCTION(this << &buf);
57 buf.WriteU32(m_flowId);
58}
59
60void
62{
63 NS_LOG_FUNCTION(this << &buf);
64 m_flowId = buf.ReadU32();
65}
66
67void
68FlowIdTag::Print(std::ostream& os) const
69{
70 NS_LOG_FUNCTION(this << &os);
71 os << "FlowId=" << m_flowId;
72}
73
75 : Tag()
76{
77 NS_LOG_FUNCTION(this);
78}
79
81 : Tag(),
82 m_flowId(id)
83{
84 NS_LOG_FUNCTION(this << id);
85}
86
87void
89{
90 NS_LOG_FUNCTION(this << id);
91 m_flowId = id;
92}
93
96{
97 NS_LOG_FUNCTION(this);
98 return m_flowId;
99}
100
103{
105 static uint32_t nextFlowId = 1;
106 uint32_t flowId = nextFlowId;
107 nextFlowId++;
108 return flowId;
109}
110
111} // namespace ns3
Introspection did not find any typical Config paths.
Definition: flow-id-tag.h:28
void Deserialize(TagBuffer buf) override
Definition: flow-id-tag.cc:61
uint32_t GetFlowId() const
Gets the flow id for the tag.
Definition: flow-id-tag.cc:95
void Serialize(TagBuffer buf) const override
Definition: flow-id-tag.cc:54
void SetFlowId(uint32_t flowId)
Sets the flow id for the tag.
Definition: flow-id-tag.cc:88
TypeId GetInstanceTypeId() const override
Get the most derived TypeId for this Object.
Definition: flow-id-tag.cc:41
static TypeId GetTypeId()
Get the type ID.
Definition: flow-id-tag.cc:31
void Print(std::ostream &os) const override
Definition: flow-id-tag.cc:68
uint32_t m_flowId
Flow ID.
Definition: flow-id-tag.h:65
static uint32_t AllocateFlowId()
Uses a static variable to generate sequential flow id.
Definition: flow-id-tag.cc:102
uint32_t GetSerializedSize() const override
Definition: flow-id-tag.cc:47
read and write tag data
Definition: tag-buffer.h:52
TAG_BUFFER_INLINE uint32_t ReadU32()
Definition: tag-buffer.h:217
TAG_BUFFER_INLINE void WriteU32(uint32_t v)
Definition: tag-buffer.h:187
tag a set of bytes in a packet
Definition: tag.h:39
a unique identifier for an interface.
Definition: type-id.h:59
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition: type-id.cc:932
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition: log.h:202
#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:46
Every class exported by the ns3 library is enclosed in the ns3 namespace.