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
* 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: Jahanzeb Farooq <jahanzeb.farooq@sophia.inria.fr>
18
*/
19
20
#include "
packet-burst.h
"
21
22
#include "ns3/log.h"
23
#include "ns3/packet.h"
24
25
#include <list>
26
#include <stdint.h>
27
28
namespace
ns3
29
{
30
31
NS_LOG_COMPONENT_DEFINE
(
"PacketBurst"
);
32
33
NS_OBJECT_ENSURE_REGISTERED
(PacketBurst);
34
35
TypeId
36
PacketBurst::GetTypeId
()
37
{
38
static
TypeId
tid =
TypeId
(
"ns3::PacketBurst"
)
39
.
SetParent
<
Object
>()
40
.SetGroupName(
"Network"
)
41
.AddConstructor<
PacketBurst
>();
42
return
tid;
43
}
44
45
PacketBurst::PacketBurst
()
46
{
47
NS_LOG_FUNCTION
(
this
);
48
}
49
50
PacketBurst::~PacketBurst
()
51
{
52
NS_LOG_FUNCTION
(
this
);
53
for
(std::list<
Ptr<Packet>
>::const_iterator iter =
m_packets
.begin(); iter !=
m_packets
.end();
54
++iter)
55
{
56
(*iter)->Unref();
57
}
58
}
59
60
void
61
PacketBurst::DoDispose
()
62
{
63
NS_LOG_FUNCTION
(
this
);
64
m_packets
.clear();
65
}
66
67
Ptr<PacketBurst>
68
PacketBurst::Copy
()
const
69
{
70
NS_LOG_FUNCTION
(
this
);
71
Ptr<PacketBurst>
burst = Create<PacketBurst>();
72
73
for
(std::list<
Ptr<Packet>
>::const_iterator iter =
m_packets
.begin(); iter !=
m_packets
.end();
74
++iter)
75
{
76
Ptr<Packet>
packet = (*iter)->Copy();
77
burst->AddPacket(packet);
78
}
79
return
burst;
80
}
81
82
void
83
PacketBurst::AddPacket
(
Ptr<Packet>
packet)
84
{
85
NS_LOG_FUNCTION
(
this
<< packet);
86
if
(packet)
87
{
88
m_packets
.push_back(packet);
89
}
90
}
91
92
std::list<Ptr<Packet>>
93
PacketBurst::GetPackets
()
const
94
{
95
NS_LOG_FUNCTION
(
this
);
96
return
m_packets
;
97
}
98
99
uint32_t
100
PacketBurst::GetNPackets
()
const
101
{
102
NS_LOG_FUNCTION
(
this
);
103
return
m_packets
.size();
104
}
105
106
uint32_t
107
PacketBurst::GetSize
()
const
108
{
109
NS_LOG_FUNCTION
(
this
);
110
uint32_t
size = 0;
111
for
(std::list<
Ptr<Packet>
>::const_iterator iter =
m_packets
.begin(); iter !=
m_packets
.end();
112
++iter)
113
{
114
Ptr<Packet>
packet = *iter;
115
size += packet->GetSize();
116
}
117
return
size;
118
}
119
120
std::list<Ptr<Packet>>::const_iterator
121
PacketBurst::Begin
()
const
122
{
123
NS_LOG_FUNCTION
(
this
);
124
return
m_packets
.begin();
125
}
126
127
std::list<Ptr<Packet>>::const_iterator
128
PacketBurst::End
()
const
129
{
130
NS_LOG_FUNCTION
(
this
);
131
return
m_packets
.end();
132
}
133
134
}
// namespace ns3
ns3::Object
A base class which provides memory management and object aggregation.
Definition:
object.h:89
ns3::PacketBurst
this class implement a burst as a list of packets
Definition:
packet-burst.h:37
ns3::PacketBurst::PacketBurst
PacketBurst()
Definition:
packet-burst.cc:45
ns3::PacketBurst::~PacketBurst
~PacketBurst() override
Definition:
packet-burst.cc:50
ns3::PacketBurst::End
std::list< Ptr< Packet > >::const_iterator End() const
Returns an iterator to the end of the burst.
Definition:
packet-burst.cc:128
ns3::PacketBurst::GetTypeId
static TypeId GetTypeId()
Get the type ID.
Definition:
packet-burst.cc:36
ns3::PacketBurst::m_packets
std::list< Ptr< Packet > > m_packets
the list of packets in the burst
Definition:
packet-burst.h:88
ns3::PacketBurst::Begin
std::list< Ptr< Packet > >::const_iterator Begin() const
Returns an iterator to the begin of the burst.
Definition:
packet-burst.cc:121
ns3::PacketBurst::Copy
Ptr< PacketBurst > Copy() const
Definition:
packet-burst.cc:68
ns3::PacketBurst::GetNPackets
uint32_t GetNPackets() const
Definition:
packet-burst.cc:100
ns3::PacketBurst::GetPackets
std::list< Ptr< Packet > > GetPackets() const
Definition:
packet-burst.cc:93
ns3::PacketBurst::GetSize
uint32_t GetSize() const
Definition:
packet-burst.cc:107
ns3::PacketBurst::DoDispose
void DoDispose() override
Destructor implementation.
Definition:
packet-burst.cc:61
ns3::PacketBurst::AddPacket
void AddPacket(Ptr< Packet > packet)
add a packet to the list of packet
Definition:
packet-burst.cc:83
ns3::Ptr
Smart pointer class similar to boost::intrusive_ptr.
Definition:
ptr.h:78
ns3::TypeId
a unique identifier for an interface.
Definition:
type-id.h:59
ns3::TypeId::SetParent
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition:
type-id.cc:936
uint32_t
NS_LOG_COMPONENT_DEFINE
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition:
log.h:202
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:238
NS_OBJECT_ENSURE_REGISTERED
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Definition:
object-base.h:46
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 Sun Jul 2 2023 18:21:59 for ns-3 by
1.9.6