[Click] Question about GapRate class

Christian Facchini c.facchini at studenti.unitn.it
Fri Nov 18 14:05:38 EST 2005


Hello list,
I am an undergraduate student who is working on "traffic shaping" in Click.
In particularly, I am studying the "GapRate" class (defined in
include/click/gaprate.hh), about which I have some doubts.
Talking about the function GapRate::need_update(), I don't understand the
following statement (line 73):
    _sec_count = ((now.tv_usec << UGAP_SHIFT) / _ugap) + 1;
Why should we shift to the left (for 12 bits) now.tv_usec, then divide it by
"_ugap" and finally add 1 to it?
The same statement (exception made for the "+ 1") is repeated a couple of line
below (then it's put into "unsigned need": line 84).

Second, I don't understand the statement that is executed if _sec_count is
greater than 0 (_sec_count -= _rate; at line 80). Why?

Furthermore what does the _ugap definition mean (line 53)?
Why put (MAX_RATE + 1) or (MAX_RATE / rate) in _ugap, depending on "rate"'s value?

I would be glad if someone could explain me these statements or redirect me to
specific documentation, as well: any help will be much appreciated.
Best regards and thank you all in advance.

--
Christian Facchini




More information about the click mailing list