A Discrete-Event Network Simulator
Home
Tutorials ▼
English
Documentation ▼
Installation
Manual
Models
Contributing
Wiki
Development ▼
API Docs
Issue Tracker
Merge Requests
API
Loading...
Searching...
No Matches
packet-burst.cc
Go to the documentation of this file.
1
/*
2
* Copyright (c) 2007,2008 INRIA
3
*
4
* SPDX-License-Identifier: GPL-2.0-only
5
*
6
* Author: Jahanzeb Farooq <jahanzeb.farooq@sophia.inria.fr>
7
*/
8
9
#include "
packet-burst.h
"
10
11
#include "ns3/log.h"
12
#include "ns3/packet.h"
13
14
#include <list>
15
#include <stdint.h>
16
17
namespace
ns3
18
{
19
20
NS_LOG_COMPONENT_DEFINE
(
"PacketBurst"
);
21
22
NS_OBJECT_ENSURE_REGISTERED
(PacketBurst);
23
24
TypeId
25
PacketBurst::GetTypeId
()
26
{
27
static
TypeId
tid =
TypeId
(
"ns3::PacketBurst"
)
28
.
SetParent
<
Object
>()
29
.SetGroupName(
"Network"
)
30
.AddConstructor<
PacketBurst
>();
31
return
tid;
32
}
33
34
PacketBurst::PacketBurst
()
35
{
36
NS_LOG_FUNCTION
(
this
);
37
}
38
39
PacketBurst::~PacketBurst
()
40
{
41
NS_LOG_FUNCTION
(
this
);
42
for
(
auto
iter =
m_packets
.begin(); iter !=
m_packets
.end(); ++iter)
43
{
44
(*iter)->Unref();
45
}
46
}
47
48
void
49
PacketBurst::DoDispose
()
50
{
51
NS_LOG_FUNCTION
(
this
);
52
m_packets
.clear();
53
}
54
55
Ptr<PacketBurst>
56
PacketBurst::Copy
()
const
57
{
58
NS_LOG_FUNCTION
(
this
);
59
Ptr<PacketBurst>
burst =
Create<PacketBurst>
();
60
61
for
(
auto
iter =
m_packets
.begin(); iter !=
m_packets
.end(); ++iter)
62
{
63
Ptr<Packet>
packet = (*iter)->Copy();
64
burst->AddPacket(packet);
65
}
66
return
burst;
67
}
68
69
void
70
PacketBurst::AddPacket
(
Ptr<Packet>
packet)
71
{
72
NS_LOG_FUNCTION
(
this
<< packet);
73
if
(packet)
74
{
75
m_packets
.push_back(packet);
76
}
77
}
78
79
std::list<Ptr<Packet>>
80
PacketBurst::GetPackets
()
const
81
{
82
NS_LOG_FUNCTION
(
this
);
83
return
m_packets
;
84
}
85
86
uint32_t
87
PacketBurst::GetNPackets
()
const
88
{
89
NS_LOG_FUNCTION
(
this
);
90
return
m_packets
.size();
91
}
92
93
uint32_t
94
PacketBurst::GetSize
()
const
95
{
96
NS_LOG_FUNCTION
(
this
);
97
uint32_t
size = 0;
98
for
(
auto
iter =
m_packets
.begin(); iter !=
m_packets
.end(); ++iter)
99
{
100
Ptr<Packet>
packet = *iter;
101
size += packet->GetSize();
102
}
103
return
size;
104
}
105
106
std::list<Ptr<Packet>>::const_iterator
107
PacketBurst::Begin
()
const
108
{
109
NS_LOG_FUNCTION
(
this
);
110
return
m_packets
.begin();
111
}
112
113
std::list<Ptr<Packet>>::const_iterator
114
PacketBurst::End
()
const
115
{
116
NS_LOG_FUNCTION
(
this
);
117
return
m_packets
.end();
118
}
119
120
}
// namespace ns3
ns3::Object
A base class which provides memory management and object aggregation.
Definition
object.h:78
ns3::PacketBurst
this class implement a burst as a list of packets
Definition
packet-burst.h:26
ns3::PacketBurst::PacketBurst
PacketBurst()
Definition
packet-burst.cc:34
ns3::PacketBurst::~PacketBurst
~PacketBurst() override
Definition
packet-burst.cc:39
ns3::PacketBurst::End
std::list< Ptr< Packet > >::const_iterator End() const
Returns an iterator to the end of the burst.
Definition
packet-burst.cc:114
ns3::PacketBurst::GetTypeId
static TypeId GetTypeId()
Get the type ID.
Definition
packet-burst.cc:25
ns3::PacketBurst::m_packets
std::list< Ptr< Packet > > m_packets
the list of packets in the burst
Definition
packet-burst.h:77
ns3::PacketBurst::Begin
std::list< Ptr< Packet > >::const_iterator Begin() const
Returns an iterator to the begin of the burst.
Definition
packet-burst.cc:107
ns3::PacketBurst::Copy
Ptr< PacketBurst > Copy() const
Definition
packet-burst.cc:56
ns3::PacketBurst::GetNPackets
uint32_t GetNPackets() const
Definition
packet-burst.cc:87
ns3::PacketBurst::GetPackets
std::list< Ptr< Packet > > GetPackets() const
Definition
packet-burst.cc:80
ns3::PacketBurst::GetSize
uint32_t GetSize() const
Definition
packet-burst.cc:94
ns3::PacketBurst::DoDispose
void DoDispose() override
Destructor implementation.
Definition
packet-burst.cc:49
ns3::PacketBurst::AddPacket
void AddPacket(Ptr< Packet > packet)
add a packet to the list of packet
Definition
packet-burst.cc:70
ns3::Ptr
Smart pointer class similar to boost::intrusive_ptr.
Definition
mpi-test-fixtures.h:37
ns3::TypeId
a unique identifier for an interface.
Definition
type-id.h:48
ns3::TypeId::SetParent
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition
type-id.cc:1001
uint32_t
NS_LOG_COMPONENT_DEFINE
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition
log.h:191
NS_LOG_FUNCTION
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by ",...
Definition
log-macros-enabled.h:229
NS_OBJECT_ENSURE_REGISTERED
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Definition
object-base.h:35
ns3::Create
Ptr< T > Create(Ts &&... args)
Create class instances by constructors with varying numbers of arguments and return them by Ptr.
Definition
ptr.h:436
ns3
Every class exported by the ns3 library is enclosed in the ns3 namespace.
packet-burst.h
src
network
utils
packet-burst.cc
Generated on Fri Nov 1 2024 09:20:45 for ns-3 by
1.11.0