Community discussions

MikroTik App
 
WirelessRudy
Forum Guru
Forum Guru
Topic Author
Posts: 3119
Joined: Tue Aug 08, 2006 5:54 pm
Location: Spain

download speed limit per connection after some time

Tue Aug 07, 2012 2:35 pm

Client should be able to browse at high speed (for example 6Mb) but when he starts a download, even with several connections (download agent, p2p) I want this download stream to drop to 2Mb after 30 secs but the 4Mb surplus of the 'pipe' still be available for browsing.
This to avoid down-loaders to cloak my network with endless running downloads but still providing high speed browsing.

I have a wireless network where client limitation takes place with simple queues in central unit connected to internet
With simple queues don't seem to find an easy way of doing it.
I don't want to make complicated scripts.

Maybe I should make a queue tree for such group of clients?
Or use a special pcq in the download target for the simple queue?

Any examples or advices?
 
n21roadie
Forum Guru
Forum Guru
Posts: 1949
Joined: Fri Aug 07, 2009 10:36 pm
Location: Limerick,Ireland

Re: download speed limit per connection after some time

Tue Aug 07, 2012 5:06 pm

Client should be able to browse at high speed (for example 6Mb) but when he starts a download, even with several connections (download agent, p2p) I want this download stream to drop to 2Mb after 30 secs but the 4Mb surplus of the 'pipe' still be available for browsing.
As we are discovering p2p, torrent, etc. are becoming very difficult to detect, how will you identify each IP packet and what it is really for and what about incorrect packet analysis also consider the extra CPU load just doing that task. I have taken a different approach, regardless of what is being downloaded, I want to allow a customer to quickly browse and download most updates within say 15mins @7Mb and at 30mins it reduces to 1Mb, At present I use simple queues on the AP’s max limit 3M/384k and use burst setting to give 7Mb for 900sec (15mins) threshold 64kb and then setting a simple queue on the client CPE to compliment the AP queue of max limit 1M/128k and use burst setting to give 3Mb for 1800sec (30mins) threshold 64kb will give me the target bandwidths I want for troublesome clients.
 
WirelessRudy
Forum Guru
Forum Guru
Topic Author
Posts: 3119
Joined: Tue Aug 08, 2006 5:54 pm
Location: Spain

Re: download speed limit per connection after some time

Tue Aug 07, 2012 5:47 pm

Ok, my wordings might not have been clear but basically I want to do exactly the same as you.

ANY src IP/port-dst.IP/port connection can start at the full speed. This to allow every task a client performs to be fast. To stop lengthy downloads occupying my bandwidth for prolonged times each connection should drop to a much lower speed after a chosen threshold. (This will only happen to downloads since almost any other connection already is gone...)
If during a running slow speed download connection a client opens a new connection (browsing for instance) this new connection(s) should start with all the speed the mayor limit still allows him to use.

Thus 8Mb max. available for each or all connection(s) which each connection still alive after 10 mins builds down to 2Mb for instance.
If a new connection is started while a 2Mb connection still runs this new connection still has 8-2=6Mb to use.

(To prevent a download manager to open several connection and still consuming all the bandwidth I also need something that stops such programs to open more than one connection. So, after 10mins srce.IP/port-dst.IP connections should not contain any more than only 1 (or 2) connections to same dst. address)

My problem is that I am presently using simple queues only and I don't want to put any extra rules-scripts-queues on the client CPE's since I still have a lot of older boards that already have problems to run NV2 on the latest ros versions.

So I am looking for a solution that can be made in my main controller unit.
 
User avatar
greencomputing
Frequent Visitor
Frequent Visitor
Posts: 95
Joined: Wed Jun 23, 2010 1:12 pm
Location: Italy

Re: download speed limit per connection after some time

Wed Aug 08, 2012 1:28 pm

Hi there
instead of using a time treshold what about using a volume of bytes already downloaded treshold?

The idea is : currently a client downloaded 12 Mbytes of data. As soon as the client will reach the treshold of 15 Mbytes it will loose the current priority 1 and classified as priority 2 until it reach the new treshold of 30 Mbytes where, again, it will be de-classified as less priority 3 client until it reach the worst class (queue ) that will be with priority 8 where it will remain until the connection will be completed and closed. Of course, new connection will be marked in independet way so new connection coming from the same client will start with super fast and brilliant priority 1.

You can define 1,2 N queues partioning the current status of each client in centralized way, giving each client a specific dynmaic priority based on the "history of his consumed bytes on the current connection" (/ip firewall mangle connection-bytes is used on purpose) .

Here an overview of a possible config procedure:

(the example is related to download , almost analogous process take place on up direction):

1) create queues : Q1,Q2,Q3 ...QN:
/queue tree
add disabled=no limit-at=0 max-limit=80M name=GLOBAL_DOWN parent=global-in priority=1
add disabled=no limit-at=1k max-limit=80M name=QoS1_DOWN packet-mark=QoS1 parent=GLOBAL_DOWN priority=1 queue=pcq-download

add disabled=no limit-at=1k max-limit=80M name=QoS2_DOWN packet-mark=QoS2 parent=GLOBAL_DOWN priority=2 queue=pcq-download

...



2) Classify the subscribers dynamically according to the nymber of bytes exchanged on the connection (accomplished trough connection-bytes)

/ip firewall mangle
add action=mark-packet chain=prerouting connection-bytes=1-15000000 disabled=no in-interface=ether2 new-packet-mark=Qos1 passthrough=no protocol=tcp
add action=mark-packet chain=prerouting connection-bytes=15000001-30000000 disabled=no in-interface=ether2 new-packet-mark=Qos2 passthrough=no protocol=tcp
...
add action=mark-packet chain=prerouting connection-bytes=1-15000000 disabled=no in-interface=ether2 new-packet-mark=Qos1 passthrough=no protocol=udp
add action=mark-packet chain=prerouting connection-bytes=15000001-30000000 disabled=no in-interface=ether2 new-packet-mark=Qos2 passthrough=no protocol=udp
...
/queue type 
add kind=pcq name=pcq-download pcq-classifier=dst-address pcq-dst-address-mask=32 pcq-dst-address6-mask=128 \
    pcq-limit=100 pcq-rate=0 pcq-src-address-mask=32 pcq-src-address6-mask=128 pcq-total-limit=20000

The suggested queue type to see is pcq classifed on dst address.

Hoping this will help you.
Have a nice day
 
n21roadie
Forum Guru
Forum Guru
Posts: 1949
Joined: Fri Aug 07, 2009 10:36 pm
Location: Limerick,Ireland

Re: download speed limit per connection after some time

Wed Aug 08, 2012 6:00 pm

instead of using a time treshold what about using a volume of bytes already downloaded treshold?
I can only speak for my own network and assume client usage it is very similar to other WISP’s where approx. 80% of my customers are low to medium bandwidth used monthly, 15% medium to high, 5% high usage, I don’t want to penalize or introduce possible bottlenecks into my network for centeralized traffic shaping or the extra financial cost in doing it correctly which will effect 100% of my customers for the usage of 20%, I want just to penalize the 5% and caution the 15% high usage clients, my policy is simple where I contact the bill payer and inform them of the situation and this very effective, with using volume of bytes already downloaded how do you separate normal updates from downloading a hidden torrent (and remember not all torrents are bad?) + download managers also used for program updates,
I want to introduce higher speed for clients but the high usage users will just soak up more bandwidth without a clearly defined fair usage policy, and local traffic shaping on the AP + Client CPE, while I don’t want to block torrents I would like to suspend them during peak usage hours (5 to 10pm daily) and resume after those hours and by setting higher speeds they will download quicker and when they reach a trigger download of 75% their connection slows down and slower at 90%, 95% to 100% of the monthly allowance it is reduced to a crawl, they can find another ISP provider if they want and will soon find the downloading which some haven’t grasped that streaming is downloading will cost more money.
 
capital
just joined
Posts: 8
Joined: Sat May 22, 2010 5:19 am

Re: download speed limit per connection after some time

Thu Nov 15, 2012 12:40 pm

Hi there
instead of using a time treshold what about using a volume of bytes already downloaded treshold?

The idea is : currently a client downloaded 12 Mbytes of data. As soon as the client will reach the treshold of 15 Mbytes it will loose the current priority 1 and classified as priority 2 until it reach the new treshold of 30 Mbytes where, again, it will be de-classified as less priority 3 client until it reach the worst class (queue ) that will be with priority 8 where it will remain until the connection will be completed and closed. Of course, new connection will be marked in independet way so new connection coming from the same client will start with super fast and brilliant priority 1.

You can define 1,2 N queues partioning the current status of each client in centralized way, giving each client a specific dynmaic priority based on the "history of his consumed bytes on the current connection" (/ip firewall mangle connection-bytes is used on purpose) .

Here an overview of a possible config procedure:

(the example is related to download , almost analogous process take place on up direction):

1) create queues : Q1,Q2,Q3 ...QN:
/queue tree
add disabled=no limit-at=0 max-limit=80M name=GLOBAL_DOWN parent=global-in priority=1
add disabled=no limit-at=1k max-limit=80M name=QoS1_DOWN packet-mark=QoS1 parent=GLOBAL_DOWN priority=1 queue=pcq-download

add disabled=no limit-at=1k max-limit=80M name=QoS2_DOWN packet-mark=QoS2 parent=GLOBAL_DOWN priority=2 queue=pcq-download

...



2) Classify the subscribers dynamically according to the nymber of bytes exchanged on the connection (accomplished trough connection-bytes)

/ip firewall mangle
add action=mark-packet chain=prerouting connection-bytes=1-15000000 disabled=no in-interface=ether2 new-packet-mark=Qos1 passthrough=no protocol=tcp
add action=mark-packet chain=prerouting connection-bytes=15000001-30000000 disabled=no in-interface=ether2 new-packet-mark=Qos2 passthrough=no protocol=tcp
...
add action=mark-packet chain=prerouting connection-bytes=1-15000000 disabled=no in-interface=ether2 new-packet-mark=Qos1 passthrough=no protocol=udp
add action=mark-packet chain=prerouting connection-bytes=15000001-30000000 disabled=no in-interface=ether2 new-packet-mark=Qos2 passthrough=no protocol=udp
...
/queue type 
add kind=pcq name=pcq-download pcq-classifier=dst-address pcq-dst-address-mask=32 pcq-dst-address6-mask=128 \
    pcq-limit=100 pcq-rate=0 pcq-src-address-mask=32 pcq-src-address6-mask=128 pcq-total-limit=20000

The suggested queue type to see is pcq classifed on dst address.

Hoping this will help you.
Have a nice day
Hi Greencomputing,

would like to implement this on my network. Any chance of having your assistance via consultation / contact details.

Capital
 
PackElend
Member Candidate
Member Candidate
Posts: 269
Joined: Tue Sep 29, 2020 6:05 pm

Re: download speed limit per connection after some time

Sun Jul 11, 2021 11:08 pm

I want to allow a customer to quickly browse and download most updates within say 15mins @7Mb and at 30mins it reduces to 1Mb
have you ever solved this without using burst?
I want to allow max bandwidth for 1 minute afterwards it shall reduce to 512 kB. It is for wireless testing I don't want the user to use the wireless at normal usage.
That is the only way to ensure, that the pipe remains widely open :), isn't it?

Who is online

Users browsing this forum: apitsos, CGGXANNX, seriosha and 74 guests