Date: Thu, 8 May 2014 18:29:18 +0200 From: Luigi Rizzo <rizzo@iet.unipi.it> To: bycn82 <bycn82@gmail.com> Cc: "freebsd-ipfw@freebsd.org" <freebsd-ipfw@freebsd.org>, Freddie Cash <fjwcash@gmail.com> Subject: Re: feature of `packet per second` Message-ID: <20140508162918.GA68254@onelab2.iet.unipi.it> In-Reply-To: <536BACA4.7010702@gmail.com> References: <53611738.8010103@gmail.com> <CAOjFWZ4zRUmcjG-r--OqoGEWcSZoWhtTykgAAHzCjoEWsMVS9g@mail.gmail.com> <53611EB1.4000406@gmail.com> <CA%2BhQ2%2BhjjS=AXVdnaEdFOKY1DqiLuX9iP0gy3wo6FbwnEdq_Qw@mail.gmail.com> <5364E097.9020106@gmail.com> <CA%2BhQ2%2BgXC9uNdtH1VCGa%2Bs1dPNWjErC9qfgXmEnfQ4SQ6Rnz_g@mail.gmail.com> <536AD13B.6080907@gmail.com> <536AD941.9090102@gmail.com> <20140508073816.GB64368@onelab2.iet.unipi.it> <536BACA4.7010702@gmail.com>
next in thread | previous in thread | raw e-mail | index | archive | help
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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20140508162918.GA68254>