red-pd.h

Go to the documentation of this file.
00001 /* -*-  Mode:C++; c-basic-offset:8; tab-width:8; indent-tabs-mode:t -*- */
00002 /*
00003  * Copyright (c) 2000  International Computer Science Institute
00004  * All rights reserved.
00005  *
00006  * Redistribution and use in source and binary forms, with or without
00007  * modification, are permitted provided that the following conditions
00008  * are met:
00009  * 1. Redistributions of source code must retain the above copyright
00010  *    notice, this list of conditions and the following disclaimer.
00011  * 2. Redistributions in binary form must reproduce the above copyright
00012  *    notice, this list of conditions and the following disclaimer in the
00013  *    documentation and/or other materials provided with the distribution.
00014  * 3. All advertising materials mentioning features or use of this software
00015  *    must display the following acknowledgement:
00016  *  This product includes software developed by ACIRI, the AT&T 
00017  *      Center for Internet Research at ICSI (the International Computer
00018  *      Science Institute).
00019  * 4. Neither the name of ACIRI nor of ICSI may be used
00020  *    to endorse or promote products derived from this software without
00021  *    specific prior written permission.
00022  *
00023  * THIS SOFTWARE IS PROVIDED BY ICSI AND CONTRIBUTORS ``AS IS'' AND
00024  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00025  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
00026  * ARE DISCLAIMED.  IN NO EVENT SHALL ICSI OR CONTRIBUTORS BE LIABLE
00027  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
00028  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
00029  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
00030  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
00031  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
00032  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
00033  * SUCH DAMAGE.
00034  *
00035  * @(#) $Header: /nfs/jade/vint/CVSROOT/ns-2/queue/red-pd.h,v 1.4 2001/01/10 23:30:14 sfloyd Exp $ (ACIRI)
00036  */
00037 
00038 
00039 #ifndef ns_red_pd_h
00040 #define ns_red_pd_h
00041 
00042 #include "red.h"
00043 #include "flowmon.h"
00044 
00045 class REDQueue;
00046 class RedPDFlow;
00047 
00048 class RedPDQueue : public REDQueue {
00049  public:    
00050     RedPDQueue (const char * = "Drop", const char * = "Drop");
00051 
00052     int auto_;              // boolean to decide if automatic updates to rate estimates 
00053                                              // are required
00054     int global_target_;     // boolean to decide if we have the same targetBW_ 
00055                                              // for all the monitored flows
00056     double targetBW_;       // the global targetBW_ in bps
00057     int noMonitored_;       // number of monitored flows
00058     double unresponsive_penalty_;  //multiplicative penalty factor for flows marked unresponsive
00059                                    // they get dropped with probability $prob*unresponsive_penalty_
00060     
00061     double P_testFRp_;      // to test the FRP thing
00062     int noidle_;        // boolean to decide if unresponsive flows
00063                 //   should be dropped when queue is idle
00064  
00065     void setFlowMon(FlowMon * flowMon) {
00066         flowMonitor_ = flowMon;
00067     }
00068 
00069 protected:
00070     int command(int argc, const char*const* argv);
00071     void reset();
00072     void enque(Packet* pkt);
00073 
00074     int off_ip_;
00075 
00076     FlowMon* flowMonitor_;        // the flowMonitor_ associated with the queue
00077     char medTraceType[20];        //the type of trace object for mon early drops
00078     NsObject * MEDTrace;          //the trace object for mon early drops
00079 
00080     double getP_monFlow(double current, double target) {
00081         if (current <= 0 || current < target) 
00082             return 0; //means don't drop
00083         // the surviving probability is target/current
00084         return 1 - (target/current);
00085     }       
00086 };
00087  
00088 class RedPDFlow : public Flow {
00089 
00090 public:
00091     //default values - no drops
00092     double targetBW_;                  // the target BW of this flow in bps
00093     double currentBW_;                 // the current BW of the flow  in bps
00094     int monitored_;                    // boolean: whether this flow is being monitored
00095     int unresponsive_;                 // boolean: whether this flow is responsive
00096     
00097     double monitorStartTime_;          // time when we started monitoring this flow
00098     double unresponsiveStartTime_;     // time when we declared this flow as unresponsive 
00099     double lastDropTime_;              // time when the last packet from this flow was dropped 
00100                                        // actually the time when the currentBW_ exceeded targetBW_
00101 
00102     int count;                         // number of packets since last drop
00103     int auto_;                         // boolean: if rate estmation is going on
00104 
00105     RedPDFlow() : targetBW_(0), currentBW_(0),  
00106         monitored_(0), unresponsive_(0),
00107         monitorStartTime_(0), unresponsiveStartTime_(0), lastDropTime_(0), 
00108         count(0), auto_(0) {
00109         
00110         bind_bw("currentBW_", &currentBW_);
00111         bind_bw("targetBW_", &targetBW_);
00112 
00113         bind_bool("monitored_", &monitored_);
00114         bind_bool("unresponsive_", &unresponsive_);
00115 
00116         bind("lastDropTime_", &lastDropTime_);
00117         bind("monitorStartTime_", &monitorStartTime_);
00118         bind("unresponsiveStartTime_", &unresponsiveStartTime_);
00119 
00120         bind_bool("auto_", &auto_);
00121     }
00122 
00123     int monitored() {return monitored_; };
00124     int unresponsive() {return unresponsive_; };
00125     
00126     RedPDFlow(double target, double current) {
00127         targetBW_ = target;
00128         currentBW_ = current;
00129     };
00130 
00131     void set(double target, double current) {
00132         targetBW_ = target;
00133         currentBW_ = current;
00134         monitored_ = 1;
00135     };
00136     
00137     double getP_monFLow() {
00138         if (currentBW_ <= 0 || currentBW_ < targetBW_) 
00139             return 0; //means don't drop
00140         
00141         // the surviving probability is target/current
00142         return 1 - (targetBW_/currentBW_);
00143     };
00144 
00145 };
00146 
00147 
00148 #endif

Generated on Tue Mar 6 16:47:49 2007 for ns2 Network Simulator 2.29 by  doxygen 1.4.6