tswtcl.c revision 1a5e258f5471356ca102c7176637cdce45bac147
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance
* with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2005 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#include <netinet/in_systm.h>
/*
* Module : Time Sliding Window meter - tswtclmtr
* Description
* This module implements the metering part of RFC 2859. It accepts the
* committed rate, peak rate and the window for a flow and determines
* next action.
* The meter provides an estimate of the running average bandwidth for the
* flow over the specified window. It uses probability to benefit TCP flows
* as it reduces the likelihood of dropping multiple packets within a TCP
* window without adversely effecting UDP flows.
*/
int tswtcl_debug = 0;
/*
* Given a packet and the tswtcl_data it belongs to, this routine meters the
* ToS or DSCP for IPv4 and IPv6 resp. with the values configured for
* the tswtcl_data.
*/
/* ARGSUSED */
int
{
tswtcl0dbg(("tswtcl_process: null mp!\n"));
return (EINVAL);
}
} else {
tswtcl0dbg(("tswtcl_process: no data\n"));
return (EINVAL);
}
}
tswtcl0dbg(("tswtcl_process: pullup error\n"));
return (EINVAL);
}
}
} else {
}
/* Convert into bits */
pkt_len <<= 3;
/* Get current time */
/* Update the avg_rate and win_front tswtcl_data */
1000) + pkt_len;
/*
* Compute the probability:
*
* p0 = (avg_rate - committed_rate) / avg_rate
*
* Yellow with probability p0
* Green with probability (1 - p0)
*
*/
/* Get a random no. betweeen 0 and avg_rate */
sizeof (additive));
} else {
}
} else {
/*
* Compute the probability:
*
* p1 = (avg_rate - peak_rate) / avg_rate
* p2 = (peak_rate - committed_rate) / avg_rate
*
* Red with probability p1
* Yellow with probability p2
* Green with probability (1 - (p1 + p2))
*
*/
/* Get a random no. betweeen 0 and avg_rate */
sizeof (additive));
} else {
}
}
/* Update Stats */
} else {
}
return (0);
}