A Discrete-Event Network Simulator
API
drop-tail-queue.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2007 University of Washington
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
18#ifndef DROPTAIL_H
19#define DROPTAIL_H
20
21#include "ns3/queue.h"
22
23namespace ns3
24{
25
31template <typename Item>
32class DropTailQueue : public Queue<Item>
33{
34 public:
39 static TypeId GetTypeId();
46
47 ~DropTailQueue() override;
48
49 bool Enqueue(Ptr<Item> item) override;
50 Ptr<Item> Dequeue() override;
51 Ptr<Item> Remove() override;
52 Ptr<const Item> Peek() const override;
53
54 private:
60
62};
63
68template <typename Item>
71{
72 static TypeId tid =
75 .SetGroupName("Network")
76 .template AddConstructor<DropTailQueue<Item>>()
77 .AddAttribute("MaxSize",
78 "The max queue size",
80 MakeQueueSizeAccessor(&QueueBase::SetMaxSize, &QueueBase::GetMaxSize),
81 MakeQueueSizeChecker());
82 return tid;
83}
84
85template <typename Item>
87 : Queue<Item>(),
88 NS_LOG_TEMPLATE_DEFINE("DropTailQueue")
89{
90 NS_LOG_FUNCTION(this);
91}
92
93template <typename Item>
95{
96 NS_LOG_FUNCTION(this);
97}
98
99template <typename Item>
100bool
102{
103 NS_LOG_FUNCTION(this << item);
104
105 return DoEnqueue(GetContainer().end(), item);
106}
107
108template <typename Item>
111{
112 NS_LOG_FUNCTION(this);
113
114 Ptr<Item> item = DoDequeue(GetContainer().begin());
115
116 NS_LOG_LOGIC("Popped " << item);
117
118 return item;
119}
120
121template <typename Item>
124{
125 NS_LOG_FUNCTION(this);
126
127 Ptr<Item> item = DoRemove(GetContainer().begin());
128
129 NS_LOG_LOGIC("Removed " << item);
130
131 return item;
132}
133
134template <typename Item>
137{
138 NS_LOG_FUNCTION(this);
139
140 return DoPeek(GetContainer().begin());
141}
142
143// The following explicit template instantiation declarations prevent all the
144// translation units including this header file to implicitly instantiate the
145// DropTailQueue<Packet> class and the DropTailQueue<QueueDiscItem> class. The
146// unique instances of these classes are explicitly created through the macros
147// NS_OBJECT_TEMPLATE_CLASS_DEFINE (DropTailQueue,Packet) and
148// NS_OBJECT_TEMPLATE_CLASS_DEFINE (DropTailQueue,QueueDiscItem), which are included
149// in drop-tail-queue.cc
150extern template class DropTailQueue<Packet>;
151extern template class DropTailQueue<QueueDiscItem>;
152
153} // namespace ns3
154
155#endif /* DROPTAIL_H */
Introspection did not find any typical Config paths.
A FIFO packet queue that drops tail-end packets on overflow.
NS_LOG_TEMPLATE_DECLARE
redefinition of the log component
static TypeId GetTypeId()
Get the type ID.
Ptr< const Item > Peek() const override
Get a copy of an item in the queue (each subclass defines the position) without removing it.
DropTailQueue()
DropTailQueue Constructor.
bool Enqueue(Ptr< Item > item) override
Place an item into the Queue (each subclass defines the position)
Ptr< Item > Remove() override
Remove an item from the Queue (each subclass defines the position), counting it and tracing it as bot...
Ptr< Item > Dequeue() override
Remove an item from the Queue (each subclass defines the position), counting it and tracing it as deq...
~DropTailQueue() override
Smart pointer class similar to boost::intrusive_ptr.
Definition: ptr.h:78
QueueSize GetMaxSize() const
Definition: queue.cc:217
void SetMaxSize(QueueSize size)
Set the maximum size of this queue.
Definition: queue.cc:200
Template class for packet Queues.
Definition: queue.h:267
Class for representing queue sizes.
Definition: queue-size.h:96
AttributeValue implementation for QueueSize.
a unique identifier for an interface.
Definition: type-id.h:59
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition: type-id.cc:935
#define NS_LOG_TEMPLATE_DEFINE(name)
Initialize a reference to a Log component.
Definition: log.h:236
#define NS_LOG_LOGIC(msg)
Use NS_LOG to output a message of level LOG_LOGIC.
Definition: log.h:282
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by ",...
Every class exported by the ns3 library is enclosed in the ns3 namespace.
std::string GetTemplateClassName()
Helper function to get the name (as a string) of the type of a template class.
Definition: object-base.h:155