Hi,

The software switch implements a token bucket to perform rate limiting
http://en.wikipedia.org/wiki/Token_bucket

Basically it add tokens to the meter band at every second and consumes a
determined number of them when a packet arrives.
To limit by packets per second, 1000 tokens are consumed by packet, while
to limit by Kb/s the code removes a token quantity equals to the packet
size.

If the bucket doesn't have sufficient tokens for a packet, then it will be
dropped or have the dscp remarked, according to your band type.

Regards,
Eder.


On 19 June 2013 08:29, Purnima Mohan <purnimamoha...@gmail.com> wrote:

> Hi all,
>
> Can anybody explain me the logic how the meter drops packet in a software
> switch? I am not able to understand the below code snippet. Please help.
>
> static bool
> consume_tokens(struct ofl_meter_band_stats *band, uint16_t meter_flag,
> struct packet *pkt){
>
>     if(meter_flag & OFPMF_KBPS){
>         uint32_t pkt_size = (pkt->buffer->size*8)/1024;
>         if (band->tokens >= pkt_size) {
>             band->tokens -= pkt_size;
>             return true;
>         } else {
>             return false;
>         }
>
>     }
>     else if(meter_flag & OFPMF_PKTPS) {
>         if (band->tokens >= 1000) {
>             band->tokens -= 1000;
>             return true;
>         } else {
>             return false;
>         }
>     }
>     return false;
> }
>
> -> What are band->tokens? I am not able to find them in the code.
> -> What is the significance of 1000?
>
>
> --
> *Regards,*
> *Purnima*
>
>
> _______________________________________________
> openflow-discuss mailing list
> openflow-discuss@lists.stanford.edu
> https://mailman.stanford.edu/mailman/listinfo/openflow-discuss
>
>


-- 
Eder Leão Fernandes

Bacharelado em Ciências de Computação
Instituto de Ciências Matemáticas e de Computação
Universidade de São Paulo
_______________________________________________
openflow-discuss mailing list
openflow-discuss@lists.stanford.edu
https://mailman.stanford.edu/mailman/listinfo/openflow-discuss

Reply via email to