00001 /* 00002 * Copyright (c) 2000 Nortel Networks 00003 * All rights reserved. 00004 * 00005 * Redistribution and use in source and binary forms, with or without 00006 * modification, are permitted provided that the following conditions 00007 * are met: 00008 * 1. Redistributions of source code must retain the above copyright 00009 * notice, this list of conditions and the following disclaimer. 00010 * 2. Redistributions in binary form must reproduce the above copyright 00011 * notice, this list of conditions and the following disclaimer in the 00012 * documentation and/or other materials provided with the distribution. 00013 * 3. All advertising materials mentioning features or use of this software 00014 * must display the following acknowledgement: 00015 * This product includes software developed by Nortel Networks. 00016 * 4. The name of the Nortel Networks may not be used 00017 * to endorse or promote products derived from this software without 00018 * specific prior written permission. 00019 * 00020 * THIS SOFTWARE IS PROVIDED BY NORTEL AND CONTRIBUTORS ``AS IS'' AND 00021 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 00022 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 00023 * ARE DISCLAIMED. IN NO EVENT SHALL NORTEL OR CONTRIBUTORS BE LIABLE 00024 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 00025 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 00026 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 00027 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 00028 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 00029 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 00030 * SUCH DAMAGE. 00031 * 00032 * Developed by: Farhan Shallwani, Jeremy Ethridge 00033 * Peter Pieda, and Mandeep Baines 00034 * Maintainer: Peter Pieda <ppieda@nortelnetworks.com> 00035 */ 00036 00037 #ifndef dsredq_h 00038 #define dsredq_h 00039 00040 //#include "dsred.h" 00041 // maximum number of virtual RED queues in one physical queue 00042 #define MAX_PREC 3 00043 00044 enum mredModeType {rio_c, rio_d, wred, dropTail}; 00045 00046 // struct qParam 00047 // This structure specifies the parameters needed to be maintained for 00048 // each RED queue. 00049 struct qParam { 00050 edp edp_; // early drop parameters (see red.h) 00051 edv edv_; // early drop variables (see red.h) 00052 int qlen; // actual (not weighted) queue length in packets 00053 double idletime_; // needed to calculate avg queue 00054 bool idle_; // needed to calculate avg queue 00055 }; 00056 00057 // class redQueue 00058 // This class provides specs for one physical queue. 00059 class redQueue { 00060 public: 00061 int numPrec; // the current number of precedence levels (or virtual queues) 00062 int qlim; 00063 mredModeType mredMode; 00064 redQueue(); 00065 // configures one virtual RED queue 00066 void config(int prec, int argc, const char*const* argv); 00067 00068 void initREDStateVar(void); // initializes RED state variables 00069 // Updates a virtual queue's length after dequeueing 00070 void updateVREDLen(int); 00071 //sets idle_ flag to 0 00072 // Patch contributed by Thilo Wagner <wagner@panasonic.de> 00073 void updateIdleFlag(int); 00074 00075 // updates RED variables after enqueueing/dequing a packet 00076 void updateREDStateVar(int prec); 00077 // enques packets into a physical queue 00078 int enque(Packet *pkt, int prec, int ecn); 00079 Packet* deque(void); // deques packets 00080 double getWeightedLength(); 00081 int getRealLength(void); // queries length of a physical queue 00082 // sets packet time constant values 00083 //(needed for calc. avgQSize) for each virtual queue 00084 00085 // queries average length of a virtual queue 00086 double getWeightedLength_v(int prec); 00087 // queries length of a virtual queue 00088 int getRealLength_v(int prec); 00089 00090 void setPTC(double outLinkBW); 00091 // sets mean packet size (needed to calculate avg. queue size) 00092 void setMPS(int mps); 00093 00094 private: 00095 // underlying FIFO queue 00096 PacketQueue *q_; 00097 // used to maintain parameters for each of the virtual queues 00098 qParam qParam_[MAX_PREC]; 00099 // to calculate avg. queue size of a virtual queue 00100 void calcAvg(int prec, int m); 00101 00102 }; 00103 #endif 00104