I´ve the following setup:

ISP-ROUTER+-------+ My-ROUTER +-------+ ...

The available bandwidth between ISP-Router and MY-ROUTER is 50Mbps. The Physical link is 1000Mpbs. All above 50Mbps result in additional costs.

The plan is to limit the traffic. With the following config the upload traffic is shaped and limited to 50Mbps.

policy-map QOS_TO_ISP class class-default shape average 50000000 ! interface GigabitEthernet0/0 [...] service-policy output QOS_TO_ISP !

I tested it and it worked. But how i can limit the download traffic? Sure, i could police the traffic in input direction so all traffic above the limit will be dropped from MY-ROUTER, but nevertheless this will not prevent the ISP Router to sent traffic above 50Mbps which will result in additional cost, is this correct?

  • By the time you see the traffic in order to use QoS on it, it has already used your bandwidth. Incoming traffic can be policed (dropped) after you receive it. If it is TCP, you can slow it down that way, but it will not be precise the way your shaping is. Other traffic, e.g. UDP, cannot be slowed down, only dropped after your bandwidth has already been used.
    – Ron Maupin
    Aug 30 '17 at 11:19

Most of Internet traffic is TCP.

TCP has a mechanism to prevent congestion, the sliding window.

So if you drop exceeding inbound traffic on the router, the receiving host in your network will tell the emitter to reduce it's sending rate and the effective incoming bandwidth usage will be reduced.

This is off course not true for non-TCP traffic (mostly UDP).

In such cases, there's usually a percentile rule.

In my company, we do have the same setup, with 10Gbs physical links and we pay for only 1Gbs, with a 95% percentile rule.

I.E. we can burst traffic to 10Gbs, it it happens less than 5% of the time we don't pay for this traffic.
The additional fee only occur if we use more than 1gbs for more than 5% of the time.

Additionally if you shape the traffic to something a little bit smaller than 50Mbps you leave more room for incoming UDP traffic.

In my case, with the traffic shaping put in place on our routers, we never had additional fee in 3 years, but admittedly, it is far easier to go over 50Mbs second than 1gbs, so this is much more likely to happen in your case.

You need to verify with your ISP if you have such a percentile rule in place. If not, you need to ask them to shape the traffic their side.

  • Thx for this answer. Ok, understood. I will get in touch with the ISP as there is obviously no "100%" way to achieve the goal for the incomming traffic on my site. Police the traffic might do the job by triggering the TCP specific behavior but as this do not cover UDP it´s not a clean solution for me.
    – Jack
    Aug 30 '17 at 11:43
  • Note that I did not insist on it, but UDP is usually a tiny fraction of the traffic, so in most the fact that it is kind of unshapped should not be an issue. It depends of course of the kind of traffic you use. For example,, an OpenVPN or IPSEC tunnel ( that use UDP) could have an impact..
    – JFL
    Aug 30 '17 at 11:48

I came across this when looking for an answer to the same question. The OS and interface limits are already addressed in an earlier answer, so here is a way to set up application specific limits. Use an application called trickle. So do sudo apt-get install trickle. You can limit upload/download for a specific app by running

trickle -u (upload limit in KB/s) -d (download limit in KB/s) application

This will launch the application with the specified limits. You can also specify "smoothing" time, so that trickle samples over the desired time period in case your application has bursts of bandwidth consumption and you'd like the bursts to be allowed so long as the average is within your specifications.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.