A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
prio-queue-disc.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2017 Universita' degli Studi di Napoli Federico II
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 * Authors: Stefano Avallone <stavallo@unina.it>
18 */
19
20#ifndef PRIO_QUEUE_DISC_H
21#define PRIO_QUEUE_DISC_H
22
23#include "queue-disc.h"
24
25#include <array>
26
27namespace ns3
28{
29
30/// Priority map
31typedef std::array<uint16_t, 16> Priomap;
32
33/**
34 * \ingroup traffic-control
35 *
36 * The Prio qdisc is a simple classful queueing discipline that contains an
37 * arbitrary number of classes of differing priority. The classes are dequeued
38 * in numerical descending order of priority. By default, three Fifo queue
39 * discs are created, unless the user provides (at least two) child queue
40 * discs.
41 *
42 * If no packet filter is installed or able to classify a packet, then the
43 * packet is assigned a priority band based on its priority (modulo 16), which
44 * is used as an index into an array called priomap. If a packet is classified
45 * by a packet filter and the returned value is non-negative and less than the
46 * number of priority bands, then the packet is assigned the priority band
47 * corresponding to the value returned by the packet filter. Otherwise, the
48 * packet is assigned the priority band specified by the first element of the
49 * priomap array.
50 */
52{
53 public:
54 /**
55 * \brief Get the type ID.
56 * \return the object TypeId
57 */
58 static TypeId GetTypeId();
59 /**
60 * \brief PrioQueueDisc constructor
61 */
63
64 ~PrioQueueDisc() override;
65
66 /**
67 * Set the band (class) assigned to packets with specified priority.
68 *
69 * \param prio the priority of packets (a value between 0 and 15).
70 * \param band the band assigned to packets.
71 */
72 void SetBandForPriority(uint8_t prio, uint16_t band);
73
74 /**
75 * Get the band (class) assigned to packets with specified priority.
76 *
77 * \param prio the priority of packets (a value between 0 and 15).
78 * \returns the band assigned to packets.
79 */
80 uint16_t GetBandForPriority(uint8_t prio) const;
81
82 private:
83 bool DoEnqueue(Ptr<QueueDiscItem> item) override;
86 bool CheckConfig() override;
87 void InitializeParams() override;
88
89 Priomap m_prio2band; //!< Priority to band mapping
90};
91
92/**
93 * Serialize the priomap to the given ostream
94 *
95 * \param os
96 * \param priomap
97 *
98 * \return std::ostream
99 */
100std::ostream& operator<<(std::ostream& os, const Priomap& priomap);
101
102/**
103 * Serialize from the given istream to this priomap.
104 *
105 * \param is
106 * \param priomap
107 *
108 * \return std::istream
109 */
110std::istream& operator>>(std::istream& is, Priomap& priomap);
111
113
114} // namespace ns3
115
116#endif /* PRIO_QUEUE_DISC_H */
The Prio qdisc is a simple classful queueing discipline that contains an arbitrary number of classes ...
void SetBandForPriority(uint8_t prio, uint16_t band)
Set the band (class) assigned to packets with specified priority.
~PrioQueueDisc() override
Ptr< const QueueDiscItem > DoPeek() override
Return a copy of the next packet the queue disc will extract.
Ptr< QueueDiscItem > DoDequeue() override
This function actually extracts a packet from the queue disc.
uint16_t GetBandForPriority(uint8_t prio) const
Get the band (class) assigned to packets with specified priority.
bool CheckConfig() override
Check whether the current configuration is correct.
PrioQueueDisc()
PrioQueueDisc constructor.
Priomap m_prio2band
Priority to band mapping.
bool DoEnqueue(Ptr< QueueDiscItem > item) override
This function actually enqueues a packet into the queue disc.
static TypeId GetTypeId()
Get the type ID.
void InitializeParams() override
Initialize parameters (if any) before the first packet is enqueued.
Smart pointer class similar to boost::intrusive_ptr.
Definition: ptr.h:77
QueueDisc is an abstract base class providing the interface and implementing the operations common to...
Definition: queue-disc.h:184
a unique identifier for an interface.
Definition: type-id.h:59
#define ATTRIBUTE_HELPER_HEADER(type)
Declare the attribute value, accessor and checkers for class type
Every class exported by the ns3 library is enclosed in the ns3 namespace.
std::ostream & operator<<(std::ostream &os, const Angles &a)
Definition: angles.cc:159
std::istream & operator>>(std::istream &is, Angles &a)
Definition: angles.cc:183
std::array< uint16_t, 16 > Priomap
Priority map.