OLD | NEW |
(Empty) | |
| 1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
| 2 /* |
| 3 * Copyright (c) 2016 NITK Surathkal |
| 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 * Authors: Vivek Jain <jain.vivek.anand@gmail.com> |
| 19 * Mohit P. Tahiliani <tahiliani@nitk.edu.in> |
| 20 */ |
| 21 |
| 22 #ifndef BLUE_QUEUE_DISC_H |
| 23 #define BLUE_QUEUE_DISC_H |
| 24 |
| 25 #include "ns3/queue-disc.h" |
| 26 #include "ns3/nstime.h" |
| 27 #include "ns3/boolean.h" |
| 28 #include "ns3/data-rate.h" |
| 29 #include "ns3/timer.h" |
| 30 #include "ns3/event-id.h" |
| 31 #include "ns3/random-variable-stream.h" |
| 32 |
| 33 namespace ns3 { |
| 34 |
| 35 class UniformRandomVariable; |
| 36 |
| 37 class BlueQueueDisc : public QueueDisc |
| 38 { |
| 39 public: |
| 40 /** |
| 41 * \brief Get the type ID. |
| 42 * \return the object TypeId |
| 43 */ |
| 44 static TypeId GetTypeId (void); |
| 45 |
| 46 /** |
| 47 * \brief BlueQueueDisc Constructor |
| 48 */ |
| 49 BlueQueueDisc (); |
| 50 |
| 51 /** |
| 52 * \brief BlueQueueDisc Destructor |
| 53 */ |
| 54 virtual ~BlueQueueDisc (); |
| 55 |
| 56 /** |
| 57 * \brief Stats |
| 58 */ |
| 59 typedef struct |
| 60 { |
| 61 uint32_t unforcedDrop; //!< Early probability drops: proactive |
| 62 uint32_t forcedDrop; //!< Drops due to queue limit: reactive |
| 63 } Stats; |
| 64 |
| 65 /** |
| 66 * \brief Enumeration of the modes supported in the class. |
| 67 * |
| 68 */ |
| 69 enum QueueDiscMode |
| 70 { |
| 71 QUEUE_DISC_MODE_PACKETS, /**< Use number of packets for maximum queue di
sc size */ |
| 72 QUEUE_DISC_MODE_BYTES, /**< Use number of bytes for maximum queue disc
size */ |
| 73 }; |
| 74 |
| 75 /** |
| 76 * \brief Set the operating mode of this queue disc. |
| 77 * |
| 78 * \param mode The operating mode of this queue disc. |
| 79 */ |
| 80 void SetMode (QueueDiscMode mode); |
| 81 |
| 82 /** |
| 83 * \brief Get the operating mode of this queue disc. |
| 84 * |
| 85 * \returns The operating mode of this queue disc. |
| 86 */ |
| 87 QueueDiscMode GetMode (void); |
| 88 |
| 89 /** |
| 90 * \brief Get the current value of the queue in bytes or packets. |
| 91 * |
| 92 * \returns The queue size in bytes or packets. |
| 93 */ |
| 94 uint32_t GetQueueSize (void); |
| 95 |
| 96 /** |
| 97 * \brief Set the limit of the queue in bytes or packets. |
| 98 * |
| 99 * \param lim The limit in bytes or packets. |
| 100 */ |
| 101 void SetQueueLimit (uint32_t lim); |
| 102 |
| 103 /** |
| 104 * \brief Get BLUE statistics after running. |
| 105 * |
| 106 * \returns The drop statistics. |
| 107 */ |
| 108 Stats GetStats (); |
| 109 |
| 110 /** |
| 111 * Assign a fixed random variable stream number to the random variables |
| 112 * used by this model. Return the number of streams (possibly zero) that |
| 113 * have been assigned. |
| 114 * |
| 115 * \param stream first stream index to use |
| 116 * \return the number of stream indices assigned by this model |
| 117 */ |
| 118 int64_t AssignStreams (int64_t stream); |
| 119 |
| 120 protected: |
| 121 /** |
| 122 * \brief Dispose of the object |
| 123 */ |
| 124 virtual void DoDispose (void); |
| 125 |
| 126 private: |
| 127 virtual bool DoEnqueue (Ptr<QueueDiscItem> item); |
| 128 virtual Ptr<QueueDiscItem> DoDequeue (void); |
| 129 virtual Ptr<const QueueDiscItem> DoPeek (void) const; |
| 130 virtual bool CheckConfig (void); |
| 131 |
| 132 /** |
| 133 * \brief Initialize the queue parameters. |
| 134 */ |
| 135 virtual void InitializeParams (void); |
| 136 |
| 137 /** |
| 138 * \brief Check if a packet needs to be dropped due to probability drop |
| 139 * \returns false for no drop, true for drop |
| 140 */ |
| 141 virtual bool DropEarly (void); |
| 142 |
| 143 /** |
| 144 * \brief Increment the value of marking probability |
| 145 */ |
| 146 virtual void IncrementPmark (void); |
| 147 |
| 148 /** |
| 149 * \brief Decrement the value of marking probability |
| 150 */ |
| 151 virtual void DecrementPmark (void); |
| 152 |
| 153 Stats m_stats; //!< BLUE statistics |
| 154 |
| 155 // ** Variables supplied by user |
| 156 QueueDiscMode m_mode; //!< Mode (bytes or packets) |
| 157 uint32_t m_queueLimit; //!< Queue limit in bytes / pack
ets |
| 158 double m_Pmark; //!< Marking Probability |
| 159 uint32_t m_meanPktSize; //!< Average Packet Size |
| 160 double m_increment; //!< increment value for marking
probability |
| 161 double m_decrement; //!< decrement value for marking
probability |
| 162 Time m_freezeTime; //!< Time interval during which
Pmark cannot be updated |
| 163 |
| 164 // ** Variables maintained by BLUE |
| 165 Time m_lastUpdateTime; //!< last time at which Pmark wa
s updated |
| 166 Time m_idleStartTime; //!< Time when BLUE Queue Disc e
ntered the idle period |
| 167 bool m_isIdle; //!< True if queue is Idle |
| 168 Ptr<UniformRandomVariable> m_uv; //!< Rng stream |
| 169 }; |
| 170 |
| 171 } // namespace ns3 |
| 172 |
| 173 #endif // BLUE_QUEUE_DISC_H |
OLD | NEW |