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 * SPDX-License-Identifier: GPL-2.0-only
5 *
6 * Authors: Stefano Avallone <stavallo@unina.it>
7 */
8
9#ifndef PRIO_QUEUE_DISC_H
10#define PRIO_QUEUE_DISC_H
11
12#include "queue-disc.h"
13
14#include <array>
15
16namespace ns3
17{
18
19/// Priority map
20typedef std::array<uint16_t, 16> Priomap;
21
22/**
23 * \ingroup traffic-control
24 *
25 * The Prio qdisc is a simple classful queueing discipline that contains an
26 * arbitrary number of classes of differing priority. The classes are dequeued
27 * in numerical descending order of priority. By default, three Fifo queue
28 * discs are created, unless the user provides (at least two) child queue
29 * discs.
30 *
31 * If no packet filter is installed or able to classify a packet, then the
32 * packet is assigned a priority band based on its priority (modulo 16), which
33 * is used as an index into an array called priomap. If a packet is classified
34 * by a packet filter and the returned value is non-negative and less than the
35 * number of priority bands, then the packet is assigned the priority band
36 * corresponding to the value returned by the packet filter. Otherwise, the
37 * packet is assigned the priority band specified by the first element of the
38 * priomap array.
39 */
41{
42 public:
43 /**
44 * \brief Get the type ID.
45 * \return the object TypeId
46 */
47 static TypeId GetTypeId();
48 /**
49 * \brief PrioQueueDisc constructor
50 */
52
53 ~PrioQueueDisc() override;
54
55 /**
56 * Set the band (class) assigned to packets with specified priority.
57 *
58 * \param prio the priority of packets (a value between 0 and 15).
59 * \param band the band assigned to packets.
60 */
61 void SetBandForPriority(uint8_t prio, uint16_t band);
62
63 /**
64 * Get the band (class) assigned to packets with specified priority.
65 *
66 * \param prio the priority of packets (a value between 0 and 15).
67 * \returns the band assigned to packets.
68 */
69 uint16_t GetBandForPriority(uint8_t prio) const;
70
71 private:
72 bool DoEnqueue(Ptr<QueueDiscItem> item) override;
75 bool CheckConfig() override;
76 void InitializeParams() override;
77
78 Priomap m_prio2band; //!< Priority to band mapping
79};
80
81/**
82 * Serialize the priomap to the given ostream
83 *
84 * \param os
85 * \param priomap
86 *
87 * \return std::ostream
88 */
89std::ostream& operator<<(std::ostream& os, const Priomap& priomap);
90
91/**
92 * Serialize from the given istream to this priomap.
93 *
94 * \param is
95 * \param priomap
96 *
97 * \return std::istream
98 */
99std::istream& operator>>(std::istream& is, Priomap& priomap);
100
102
103} // namespace ns3
104
105#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.
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.
QueueDisc is an abstract base class providing the interface and implementing the operations common to...
Definition queue-disc.h:173
a unique identifier for an interface.
Definition type-id.h:48
#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:148
std::istream & operator>>(std::istream &is, Angles &a)
Definition angles.cc:172
std::array< uint16_t, 16 > Priomap
Priority map.