On Fri, May 09, 2014 at 12:11:16AM +0800, bycn82 wrote: > On 5/8/14 15:38, Luigi Rizzo wrote: ... > >>>>> If i were to implement the feature i would add two parameters > >>>>> (burst, I_max) with reasonable defaults and compute the internal > >>>>> interval and max_count as follows > >>>>> if (burst> max_pps * I_max) > >>>>> burst = max_pps * I_max; // make sure it is not too large > >>>>> else if (burst< max_pps / HZ) > >>>>> burst = max_pps * HZ; // nor too small > >>>>> max_count = max_pps / burst; > >>>>> interval = HZ * burst / max_pps; > >>>>> count = 0; // actual counter > >>>>> > >>>>> then add { max_count, interval, timestamp, count } to the rule > >>>>> descriptor. > >>>>> On incoming packets: > >>>>> > >>>>> if (ticks>= r->interval + r->timestamp) { > >>>>> r->timestamp = r->ticks; > >>>>> r->count = 1; > >>>>> return ACCEPT; > >>>>> } > >>>>> if (r->count> r->max_count) > >>>>> return DENY; > >>>>> r->count++; > >>>>> return ACCEPT; > >>>>> > >>>>> cheers > >>>>> luigi > >>>>> > >>>> Hi Luigi, > >>>> You are right, it will be more generic if provide two parameters > >>>> as you described, > >>>> But this PPS feature should not be used to control the traffic > >>>> rate, the dummynet you provided is the correct way. > >>>> So I am thinking in what kind of scenario, people need this PPS > >>>> feature? > >>>> in my opinion, people will use PPS only when they want to limit > >>>> the connections/transactions numbers. ( already have limit > >>>> command to limit the connections) > >>>> So I think provide a simple PPS feature is good enough, and we > >>>> can improve it if someone complaint on this. ... > Man page patch for PPS > > .It Cm pps Ar limit duration > Rule with the > .Cm pps > keyword will allow the first > .Ar limit > packets in each > .Ar duration > milliseconds. > > and it will be like blow > pps _limit duration_ > Rule with the pps keyword will allow the first _limit > _packets in > each _duration _milliseconds. > > is that OK?
looks good to me. Just remember that the value of HZ may be quite low (e.g. HZ=100 or less in some cases) so internally the code should round up the intervals as needed. cheers luigi _______________________________________________ freebsd-ipfw@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-ipfw To unsubscribe, send any mail to "freebsd-ipfw-unsubscr...@freebsd.org"