/* -*- Mode:C++; c-basic-offset:8; tab-width:8; indent-tabs-mode:t -*- */ /* * Copyright (c) 1990-1997 Regents of the University of California. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * This product includes software developed by the Computer Systems * Engineering Group at Lawrence Berkeley Laboratory. * 4. Neither the name of the University nor of the Laboratory may be used * to endorse or promote products derived from this software without * specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * * Here is one set of parameters from one of my simulations: * * ed [ q_weight=0.002 thresh=5 linterm=30 maxthresh=15 * mean_pktsize=500 dropmech=random-drop queue-size=60 * plot-file=none bytes=false doubleq=false dqthresh=50 * wait=true ] * * 1/"linterm" is the max probability of dropping a packet. * There are different options that make the code * more messy that it would otherwise be. For example, * "doubleq" and "dqthresh" are for a queue that gives priority to * small (control) packets, * "bytes" indicates whether the queue should be measured in bytes * or in packets, * "dropmech" indicates whether the drop function should be random-drop * or drop-tail when/if the queue overflows, and * the commented-out Holt-Winters method for computing the average queue * size can be ignored. * "wait" indicates whether the gateway should wait between dropping * packets. * * @(#) $Header: /nfs/jade/vint/CVSROOT/ns-2/red.h,v 1.23 2000/07/20 04:56:29 ratul Exp $ (LBL) */ /* * SRED: Stabilized RED * Author: Srinivas R. Avasarala (Computer Science, Purdue University) * * Note that this code is written based on the paper, T. J. Ott, T. V. Lakshman, * and L. H. Wong, "SRED: Stabilized RED," in Proceedings of IEEE INFOCOM, March 1999. */ #ifndef ns_sred_h #define ns_sred_h #include "queue.h" #include "trace.h" class LinkDelay; struct zombie { int fid; /* flow identifier */ int count; /* count of pkts of this flow in this zombie */ double timestamp; // xombie() : fid(0), count(0), timestamp(0.0) { } }; #define M 1000 class SREDQueue : public Queue { public: SREDQueue(const char * = "Drop"); protected: int command(int argc, const char*const* argv); void reset(); Packet* deque(); double calc_psred(); double calc_simple_pzap(double prob_sred); double calc_full_pzap(double prob_sred, int hit); void enque(Packet* pkt); void trace(TracedVar* v); /* routine to write trace records */ int full_sred_; /* boolean, TRUE:= full SRED, FALSE:= simple SRED */ struct zombie zombielist[M]; int listsize_; double p_overwrite_; double p_t_; /* hit frequency */ double p_max_; /* maximum drop probability */ double alpha_; /* alpha = p/M = p_overwrite/M */ LinkDelay* link_; /* outgoing link */ PacketQueue *q_; /* underlying (usually) FIFO queue */ int bcount_; /* byte count */ int qib_; /* bool: queue measured in bytes? */ NsObject* drop_tgt_; /* drop target */ NsObject* drop_trace_; //early drop trace char traceType[20]; //the preferred type for early droptrace //better be less than 19 chars long int which_; Tcl_Channel tchan_; /* place to write trace records */ TracedInt curq_; /* current qlen seen by arrivals */ }; #endif