• Main Page
  • Classes
  • Files
  • File List

/Users/yzchen/ns/ns-allinone-2.33/ns-2.33/queue/rio.h

00001 /* -*-  Mode:C++; c-basic-offset:8; tab-width:8; indent-tabs-mode:t -*- */
00002 /*
00003  * Copyright (c) 1990-1997 Regents of the University of California.
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 the Computer Systems
00017  *      Engineering Group at Lawrence Berkeley Laboratory.
00018  * 4. Neither the name of the University nor of the Laboratory may be used
00019  *    to endorse or promote products derived from this software without
00020  *    specific prior written permission.
00021  *
00022  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
00023  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00024  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
00025  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
00026  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
00027  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
00028  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
00029  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
00030  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
00031  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
00032  * SUCH DAMAGE.
00033  *
00034  *
00035  * @(#) $Header: /cvsroot/nsnam/ns-2/queue/rio.h,v 1.5 2000/07/04 01:59:31 sfloyd Exp $ (LBL)
00036  */
00037 
00038 #ifndef ns_rio_h
00039 #define ns_rio_h
00040 
00041 #include "tclcl.h"
00042 #include "packet.h"
00043 #include "random.h"
00044 #include "flags.h"
00045 #include "delay.h"
00046 #include "template.h"
00047 #include "red.h"
00048 
00049 /*
00050  * Early drop parameters, supplied by user, for a subqueue.
00051  */
00052 struct edp_rio {
00053         /*
00054          * User supplied.
00055          */
00056         int gentle;             /* when ave queue exceeds maxthresh. */
00057         double th_min;  /* minimum threshold of average queue size */
00058         double th_max;  /* maximum threshold of average queue size */
00059         double max_p_inv;       /* 1/max_p, for max_p = maximum prob.  */
00060 };
00061 
00062 /*
00063  * Early drop variables, maintained by RIO, for a subqueue.
00064  */
00065 struct edv_rio {
00066         /* added by Wenjia modified by Yun: a new set In packets */
00067         double v_ave;         /* average In queue size */
00068         double v_prob1; /* prob. of packet drop before "count". */
00069         double v_slope;       /* used in computing average queue size */
00070         double v_r;
00071         double v_prob;        /* prob. of packet drop */
00072         double v_a;           /* v_prob = v_a * v_ave + v_b */
00073         double v_b;
00074         double v_c;
00075         double v_d;
00076         int count;           /* # of packets since last drop */
00077         int count_bytes;     /* # of bytes since last drop */
00078         int old;             /* 0 when average queue first exceeds thresh */
00079         struct dlist* drops;
00080 
00081         edv_rio() : v_ave(0.0), v_prob1(0.0), v_slope(0.0), v_prob(0.0),
00082                 v_a(0.0), v_b(0.0), count(0), count_bytes(0), old(0) { }
00083 };
00084 
00085 class REDQueue;
00086 
00087 class RIOQueue : public virtual REDQueue {
00088  public:        
00089         RIOQueue();
00090  protected:
00091         void enque(Packet* pkt);
00092         Packet* deque();
00093         void reset();
00094 
00095         void run_out_estimator(int out, int total, int m);
00096 
00097         // int drop_early(Packet* pkt);
00098         int drop_in_early(Packet* pkt);
00099         int drop_out_early(Packet* pkt);
00100 
00101         /* added by Yun: In packets byte count */
00102         int in_len_;    /* In Packets count */
00103         int in_bcount_; /* In packets byte count */
00104 
00105         void trace(TracedVar*); /* routine to write trace records */
00106 
00107         /*
00108          * Static state.
00109          */
00110         int priority_method_;   /* 0 to leave priority field in header, */
00111                                 /*  1 to use flowid as priority.  */
00112 
00113         edp_rio edp_in_;        /* early-drop params for IN traffic */
00114         edp_rio edp_out_;        /* early-drop params for OUT traffic */
00115 
00116         /*
00117          * Dynamic state.
00118          */
00119         /* added by Wenjia noticed by Yun: to trace the idle */
00120         int in_idle_;
00121         double in_idletime_;
00122 
00123         edv_rio edv_in_;        /* early-drop variables for IN traffic */
00124         edv_rio edv_out_;        /* early-drop variables for OUT traffic */ 
00125 
00126         void print_edp();       // for debugging
00127         void print_edv();       // for debugging
00128 };
00129 
00130 #endif

Generated on Tue Aug 10 2010 16:16:08 for ns-2.33 by  doxygen 1.7.1