Logo Search packages:      
Sourcecode: libnl version File versions  Download package

int rtnl_qdisc_tbf_set_limit_by_latency ( struct rtnl_qdisc *  qdisc,
int  latency 

Set limit of TBF qdisc by latency.

  • qdisc TBF qdisc to be modified.
  • latency Latency in micro seconds.
Calculates and sets the limit based on the desired latency and the configured rate and peak rate. In order for this operation to succeed, the rate and if required the peak rate must have been set in advance.

\[ limit_n = \frac{{rate_n} \times {latency}}{10^6}+{bucketsize}_n \]

\[ limit = min(limit_{rate},limit_{peak}) \]

0 on success or a negative error code.

Definition at line 266 of file tbf.c.

References rtnl_qdisc_tbf_set_limit().

      struct rtnl_tbf *tbf;
      double limit, limit2;

      tbf = tbf_alloc(qdisc);
      if (!tbf)
            return nl_errno(ENOMEM);

      if (!(tbf->qt_mask & TBF_ATTR_RATE))
            return nl_error(EINVAL, "The rate must be specified before "
                        "limit can be calculated based on latency.");

      limit = calc_limit(&tbf->qt_rate, latency, tbf->qt_rate_bucket);

      if (tbf->qt_mask & TBF_ATTR_PEAKRATE) {
            limit2 = calc_limit(&tbf->qt_peakrate, latency,

            if (limit2 < limit)
                  limit = limit2;

      return rtnl_qdisc_tbf_set_limit(qdisc, (int) limit);

Generated by  Doxygen 1.6.0   Back to index