Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes for 64-bit rates #402

Merged
merged 2 commits into from
Oct 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions elements/standard/bandwidthmeter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ BandwidthMeter::configure(Vector<String> &conf, ErrorHandler *errh)
else if (ba.status == NumArg::status_unitless)
errh->warning("no units for bandwidth argument %d, assuming Bps", i+1);

unsigned max_value = 0xFFFFFFFF >> _rate.scale();
uint64_t max_value = UINT64_MAX >> _rate.scale();
for (int i = 0; i < conf.size(); i++) {
if (vals[i] > max_value)
return errh->error("rate %d too large (max %u)", i+1, max_value);
Expand All @@ -78,7 +78,7 @@ BandwidthMeter::push(int, Packet *p)
{
_rate.update(p->length());

unsigned r = _rate.scaled_average();
uint64_t r = _rate.scaled_average();
if (_nmeters < 2) {
int n = (r >= _meter1);
output(n).push(p);
Expand Down
2 changes: 1 addition & 1 deletion elements/standard/bandwidthmeter.hh
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ class BandwidthMeter : public Element { protected:
const char *port_count() const override { return "1/2-"; }
const char *processing() const override { return PUSH; }

unsigned scaled_rate() const { return _rate.scaled_average(); }
uint64_t scaled_rate() const { return _rate.scaled_average(); }
unsigned rate_scale() const { return _rate.scale(); }
unsigned rate_freq() const { return _rate.epoch_frequency(); }

Expand Down
2 changes: 1 addition & 1 deletion elements/standard/ratedsource.cc
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ RatedSource::configure(Vector<String> &conf, ErrorHandler *errh)
rate = bandwidth / (_datasize < 0 ? _data.length() : _datasize);
}

int burst = rate < 200 ? 2 : rate / 100;
uint64_t burst = rate < 200 ? 2 : rate / 100;
if (bandwidth > 0 && burst < 2 * datasize) {
burst = 2 * datasize;
}
Expand Down
6 changes: 3 additions & 3 deletions elements/standard/ratedunqueue.cc
Original file line number Diff line number Diff line change
Expand Up @@ -70,12 +70,12 @@ RatedUnqueue::configure_helper(TokenBucket *tb, bool is_bandwidth, Element *elt,
bigint::limb_type res[2];
bigint::multiply(res[1], res[0], r, dur_msec);
bigint::divide(res, res, 2, 1000);
tokens = res[1] ? UINT_MAX : res[0];
tokens = res[1] ? UINT64_MAX : res[0];
}

if (is_bandwidth) {
unsigned new_tokens = tokens + tb_bandwidth_thresh;
tokens = (tokens < new_tokens ? new_tokens : UINT_MAX);
uint64_t new_tokens = tokens + tb_bandwidth_thresh;
tokens = (tokens < new_tokens ? new_tokens : UINT64_MAX);
}

tb->assign(r, tokens ? tokens : 1);
Expand Down
4 changes: 2 additions & 2 deletions include/click/ewma.hh
Original file line number Diff line number Diff line change
Expand Up @@ -490,9 +490,9 @@ class RateEWMAXParameters : public FixedEWMAXParameters<STABILITY, SCALE, T, U>
};

/** @brief A RateEWMAX with stability shift 4 (alpha 1/16), scaling factor 10
* (10 bits of fraction), one rate, and underlying type <code>unsigned</code>
* (10 bits of fraction), one rate, and underlying type <code>uint64_t</code>
* that measures epochs in jiffies. */
typedef RateEWMAX<RateEWMAXParameters<4, 10> > RateEWMA;
typedef RateEWMAX<RateEWMAXParameters<4, 10, uint64_t, int64_t> > RateEWMA;


template <typename P>
Expand Down
Loading