A Discrete-Event Network Simulator
Home
Tutorials ▼
English
Portuguese
Docs ▼
Wiki
Manual
Models
Develop ▼
API
Bugs
API
Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Properties
Friends
Macros
Groups
Pages
packet-burst.cc
Go to the documentation of this file.
1
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2
/*
3
* Copyright (c) 2007,2008 INRIA
4
*
5
* This program is free software; you can redistribute it and/or modify
6
* it under the terms of the GNU General Public License version 2 as
7
* published by the Free Software Foundation;
8
*
9
* This program is distributed in the hope that it will be useful,
10
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
* GNU General Public License for more details.
13
*
14
* You should have received a copy of the GNU General Public License
15
* along with this program; if not, write to the Free Software
16
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17
*
18
* Author: Jahanzeb Farooq <jahanzeb.farooq@sophia.inria.fr>
19
*/
20
21
#include <stdint.h>
22
#include <list>
23
#include "ns3/packet.h"
24
#include "
packet-burst.h
"
25
#include "ns3/log.h"
26
27
NS_LOG_COMPONENT_DEFINE
(
"PacketBurst"
);
28
29
namespace
ns3 {
30
31
NS_OBJECT_ENSURE_REGISTERED
(PacketBurst);
32
33
TypeId
34
PacketBurst::GetTypeId
(
void
)
35
{
36
static
TypeId
tid =
TypeId
(
"ns3::PacketBurst"
)
37
.
SetParent
<
Object
> ()
38
.AddConstructor<PacketBurst> ()
39
;
40
return
tid;
41
}
42
43
PacketBurst::PacketBurst
(
void
)
44
{
45
}
46
47
PacketBurst::~PacketBurst
(
void
)
48
{
49
for
(
std::list
<
Ptr<Packet>
>::const_iterator iter =
m_packets
.begin (); iter
50
!=
m_packets
.end (); ++iter)
51
{
52
(*iter)->Unref ();
53
54
}
55
}
56
57
void
58
PacketBurst::DoDispose
(
void
)
59
{
60
m_packets
.clear ();
61
}
62
63
Ptr<PacketBurst>
PacketBurst::Copy
(
void
)
const
64
{
65
Ptr<PacketBurst>
burst = Create<PacketBurst> ();
66
67
for
(
std::list
<
Ptr<Packet>
>::const_iterator iter =
m_packets
.begin (); iter
68
!=
m_packets
.end (); ++iter)
69
{
70
Ptr<Packet>
packet = (*iter)->
Copy
();
71
burst->
AddPacket
(packet);
72
}
73
return
burst;
74
}
75
76
void
77
PacketBurst::AddPacket
(
Ptr<Packet>
packet)
78
{
79
if
(packet)
80
{
81
m_packets
.push_back (packet);
82
}
83
}
84
85
std::list<Ptr<Packet> >
86
PacketBurst::GetPackets
(
void
)
const
87
{
88
return
m_packets
;
89
}
90
91
uint32_t
92
PacketBurst::GetNPackets
(
void
)
const
93
{
94
return
m_packets
.size ();
95
}
96
97
uint32_t
98
PacketBurst::GetSize
(
void
)
const
99
{
100
uint32_t size = 0;
101
for
(
std::list
<
Ptr<Packet>
>::const_iterator iter =
m_packets
.begin (); iter
102
!=
m_packets
.end (); ++iter)
103
{
104
Ptr<Packet>
packet = *iter;
105
size += packet->
GetSize
();
106
}
107
return
size;
108
}
109
110
std::list<Ptr<Packet> >::const_iterator
111
PacketBurst::Begin
(
void
)
const
112
{
113
return
m_packets
.begin ();
114
}
115
116
std::list<Ptr<Packet> >::const_iterator
117
PacketBurst::End
(
void
)
const
118
{
119
return
m_packets
.end ();
120
}
121
122
123
}
// namespace ns3
124
125
src
network
utils
packet-burst.cc
Generated on Tue Oct 9 2012 16:45:44 for ns-3 by
1.8.1.2