A Discrete-Event Network Simulator
API
drop-tail-queue.h
Go to the documentation of this file.
1/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2/*
3 * Copyright (c) 2007 University of Washington
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
19#ifndef DROPTAIL_H
20#define DROPTAIL_H
21
22#include "ns3/queue.h"
23
24namespace ns3 {
25
31template <typename Item>
32class DropTailQueue : public Queue<Item>
33{
34public:
39 static TypeId GetTypeId (void);
46
47 virtual ~DropTailQueue ();
48
49 virtual bool Enqueue (Ptr<Item> item);
50 virtual Ptr<Item> Dequeue (void);
51 virtual Ptr<Item> Remove (void);
52 virtual Ptr<const Item> Peek (void) const;
53
54private:
56 using Queue<Item>::end;
61
63};
64
65
70template <typename Item>
73{
74 static TypeId tid = TypeId ("ns3::DropTailQueue<" + GetTypeParamName<DropTailQueue<Item> > () + ">")
76 .SetGroupName ("Network")
77 .template AddConstructor<DropTailQueue<Item> > ()
78 .AddAttribute ("MaxSize",
79 "The max queue size",
80 QueueSizeValue (QueueSize ("100p")),
81 MakeQueueSizeAccessor (&QueueBase::SetMaxSize,
83 MakeQueueSizeChecker ())
84 ;
85 return tid;
86}
87
88template <typename Item>
90 Queue<Item> (),
91 NS_LOG_TEMPLATE_DEFINE ("DropTailQueue")
92{
93 NS_LOG_FUNCTION (this);
94}
95
96template <typename Item>
98{
99 NS_LOG_FUNCTION (this);
100}
101
102template <typename Item>
103bool
105{
106 NS_LOG_FUNCTION (this << item);
107
108 return DoEnqueue (end (), item);
109}
110
111template <typename Item>
114{
115 NS_LOG_FUNCTION (this);
116
117 Ptr<Item> item = DoDequeue (begin ());
118
119 NS_LOG_LOGIC ("Popped " << item);
120
121 return item;
122}
123
124template <typename Item>
127{
128 NS_LOG_FUNCTION (this);
129
130 Ptr<Item> item = DoRemove (begin ());
131
132 NS_LOG_LOGIC ("Removed " << item);
133
134 return item;
135}
136
137template <typename Item>
140{
141 NS_LOG_FUNCTION (this);
142
143 return DoPeek (begin ());
144}
145
146// The following explicit template instantiation declarations prevent all the
147// translation units including this header file to implicitly instantiate the
148// DropTailQueue<Packet> class and the DropTailQueue<QueueDiscItem> class. The
149// unique instances of these classes are explicitly created through the macros
150// NS_OBJECT_TEMPLATE_CLASS_DEFINE (DropTailQueue,Packet) and
151// NS_OBJECT_TEMPLATE_CLASS_DEFINE (DropTailQueue,QueueDiscItem), which are included
152// in drop-tail-queue.cc
153extern template class DropTailQueue<Packet>;
154extern template class DropTailQueue<QueueDiscItem>;
155
156} // namespace ns3
157
158#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
virtual bool Enqueue(Ptr< Item > item)
Place an item into the Queue (each subclass defines the position)
virtual ~DropTailQueue()
static TypeId GetTypeId(void)
Get the type ID.
DropTailQueue()
DropTailQueue Constructor.
virtual Ptr< Item > Remove(void)
Remove an item from the Queue (each subclass defines the position), counting it and tracing it as bot...
virtual Ptr< const Item > Peek(void) const
Get a copy of an item in the queue (each subclass defines the position) without removing it.
virtual Ptr< Item > Dequeue(void)
Remove an item from the Queue (each subclass defines the position), counting it and tracing it as deq...
void SetMaxSize(QueueSize size)
Set the maximum size of this queue.
Definition: queue.cc:200
QueueSize GetMaxSize(void) const
Definition: queue.cc:217
Template class for packet Queues.
Definition: queue.h:262
Class for representing queue sizes.
Definition: queue-size.h:95
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:922
#define NS_LOG_TEMPLATE_DEFINE(name)
Initialize a reference to a Log component.
Definition: log.h:239
#define NS_LOG_LOGIC(msg)
Use NS_LOG to output a message of level LOG_LOGIC.
Definition: log.h:289
#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 GetTypeParamName(void)
Helper function to get the name (as a string) of the type parameter of a template class.
Definition: object-base.h:102