/* * PIE - Proportional Integral controller Enhanced AQM algorithm. * * Copyright (C) 2016 Centre for Advanced Internet Architectures, * Swinburne University of Technology, Melbourne, Australia. * Portions of this code were made possible in part by a gift from * The Comcast Innovation Fund. * Implemented by Rasool Al-Saadi * * 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. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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. */ #ifndef _IP_DN_AQM_PIE_H #define _IP_DN_AQM_PIE_H #define DN_AQM_PIE 2 #define PIE_DQ_THRESHOLD_BITS 14 /* 2^14 =16KB */ #define PIE_DQ_THRESHOLD (1L << PIE_DQ_THRESHOLD_BITS) #define MEAN_PKTSIZE 800 /* 31-bits because random() generates range from 0->(2**31)-1 */ #define PIE_PROB_BITS 31 #define PIE_MAX_PROB ((1LL<parms; /* queue is not congested */ if ((pst->qdelay_old < (pprms->qdelay_ref >> 1) && pst->drop_prob < PIE_MAX_PROB / 5 ) || qlen <= 2 * MEAN_PKTSIZE) return ENQUE; if (pst->drop_prob == 0) pst->accu_prob = 0; /* increment accu_prob */ if (pprms->flags & PIE_DERAND_ENABLED) pst->accu_prob += pst->drop_prob; /* De-randomize option * if accu_prob < 0.85 -> enqueue * if accu_prob>8.5 ->drop * between 0.85 and 8.5 || !De-randomize --> drop on prob * * (0.85 = 17/20 ,8.5 = 17/2) */ if (pprms->flags & PIE_DERAND_ENABLED) { if(pst->accu_prob < (uint64_t) (PIE_MAX_PROB * 17 / 20)) return ENQUE; if( pst->accu_prob >= (uint64_t) (PIE_MAX_PROB * 17 / 2)) return DROP; } if (random() < pst->drop_prob) { pst->accu_prob = 0; return DROP; } return ENQUE; } #endif