REDQueue.hh
Go to the documentation of this file.
1 //
2 // Copyright (c) 2020 Fraunhofer Institute for Applied Information Technology (FIT)
3 // Network Research Group (NET)
4 // Schloss Birlinghoven, 53754 Sankt Augustin, GERMANY
5 // Contact: support@wiback.org
6 //
7 // This file is part of the SENF code tree.
8 // It is licensed under the 3-clause BSD License (aka New BSD License).
9 // See LICENSE.txt in the top level directory for details or visit
10 // https://opensource.org/licenses/BSD-3-Clause
11 //
12 
13 
17 #ifndef HH_SENF_Ext_NetEmu_Modules_REDQueue_
18 #define HH_SENF_Ext_NetEmu_Modules_REDQueue_ 1
19 
20 // Custom includes
21 #include <queue>
23 
25 
26 namespace senf {
27 namespace emu {
28 
29  class REDQueue
30  : public ppi::QueueingAlgorithm
31  {
32  public:
34 
35 
36  typedef std::pair<std::uint32_t,std::uint8_t> limit_t;
37 
38  REDQueue(std::uint32_t _limit = 16384, std::uint8_t lowThreshPrecentage = 25);
39 
40  void limit(std::uint32_t bytes, std::uint8_t lowThreshPrecentage = 25);
41  limit_t limit() const;
42 
43  std::uint32_t dropped() const;
44  void incrDropped();
45  void resetDropped();
46 
47  private:
48  unsigned v_peek(unsigned maxSize) const;
49  senf::Packet const & v_front() const;
50 
51  void v_pop();
52  senf::Packet v_dequeue();
53  bool v_enqueue(senf::Packet const & packet, bool force);
54  unsigned v_size() const;
55  void v_clear();
56  bool v_empty() const;
57 
58  std::queue<senf::Packet> queue_;
59  std::uint32_t queueLimit_;
60  std::uint32_t lowThresh_;
61  std::uint8_t lowThreshPrecentage_;
62  std::uint32_t queueSize_;
63  mutable std::uint32_t frontPktSize_;
64  std::uint32_t packetsDroppedTotal_;
65  std::uint32_t packetsDroppedLast_;
66  };
67 
68 }}
70 #include "REDQueue.cci"
71 //#include "REDQueue.ct"
72 //#include "REDQueue.cti"
73 #endif
std::pair< std::uint32_t, std::uint8_t > limit_t
Definition: REDQueue.hh:36
std::uint32_t dropped() const
Definition: REDQueue.cc:89
REDQueue(std::uint32_t _limit=16384, std::uint8_t lowThreshPrecentage=25)
Definition: REDQueue.cc:33
PacketParserBase::size_type bytes(Parser const &p)
std::unique_ptr< QueueingAlgorithm > ptr
limit_t limit() const
Definition: REDQueue.cc:83
static ppi::QueueingAlgorithm::ptr create()
Definition: REDQueue.cc:28