Community discussions

MikroTik App
 
zhup
Frequent Visitor
Frequent Visitor
Topic Author
Posts: 82
Joined: Thu Dec 03, 2015 10:10 pm

How to prioritize traffic of one host?

Sun Aug 21, 2016 10:49 pm

Hello,

In my local network there is a server which provide a service on the one specific port (15555) for computers inside and outside my lan.
How to prioritize the traffic into and out of this server?

Thank you in advance.
zhup
 
nikc
Member Candidate
Member Candidate
Posts: 186
Joined: Wed Jul 13, 2016 6:05 pm

Re: How to prioritize traffic of one host?

Mon Aug 22, 2016 11:21 am

 
User avatar
reidavidinho
Frequent Visitor
Frequent Visitor
Posts: 81
Joined: Mon Jul 25, 2016 11:11 am
Location: Ibadan, Nigeria
Contact:

Re: How to prioritize traffic of one host?

Mon Aug 22, 2016 5:59 pm

I think Firewall filter will do, using the IP Address of the Server. You can reject every other service and Accept only that of your Server.
Mikrotik Certified Consultant
[ MTCNA , MTCRE ]
 
zhup
Frequent Visitor
Frequent Visitor
Topic Author
Posts: 82
Joined: Thu Dec 03, 2015 10:10 pm

Re: How to prioritize traffic of one host?

Mon Aug 22, 2016 7:29 pm

The question is: how to give the higher priority to the traffic of one host without guarantee the bandwidth?
zhup
 
User avatar
ZeroByte
Forum Guru
Forum Guru
Posts: 4051
Joined: Wed May 11, 2011 6:08 pm

Re: How to prioritize traffic of one host?

Tue Aug 23, 2016 4:05 am

The question is: how to give the higher priority to the traffic of one host without guarantee the bandwidth?
You really can't. Priority only comes into play between queues which have already been given their guaranteed minimum bandwidth.

I'd say do something basic like this -
create two simple queues
The first is the "priority queue" and its target is set to the IP address of the priority host.
Guarantee that host (limit-at=) about 50% of the available bandwidth and set the max-limit to the full bandwidth of the connection. Priority=1
Make a second queue with target=x.x.x.0/24 (your LAN IP range) and guarantee it roughly 45% of the bandwidth, and a max-limit=full bandwidth of the connection.
Set the priority of this queue to 8.

That should do what you want and allow the priority host to have up to 55% of the bandwidth no matter what. You can lower the limit-at value for the default queue if you want to guarantee more bandwidth for the priority host. Just don't guarantee 100% to the priority host, as it can basically starve the rest of the network.
When given a spoon,
you should not cling to your fork.
The soup will get cold.
 
zhup
Frequent Visitor
Frequent Visitor
Topic Author
Posts: 82
Joined: Thu Dec 03, 2015 10:10 pm

Re: How to prioritize traffic of one host?

Tue Aug 23, 2016 12:01 pm

The question is: how to give the higher priority to the traffic of one host without guarantee the bandwidth?
You really can't. Priority only comes into play between queues which have already been given their guaranteed minimum bandwidth.

I'd say do something basic like this -
create two simple queues
The first is the "priority queue" and its target is set to the IP address of the priority host.
Guarantee that host (limit-at=) about 50% of the available bandwidth and set the max-limit to the full bandwidth of the connection. Priority=1
Make a second queue with target=x.x.x.0/24 (your LAN IP range) and guarantee it roughly 45% of the bandwidth, and a max-limit=full bandwidth of the connection.
Set the priority of this queue to 8.

That should do what you want and allow the priority host to have up to 55% of the bandwidth no matter what. You can lower the limit-at value for the default queue if you want to guarantee more bandwidth for the priority host. Just don't guarantee 100% to the priority host, as it can basically starve the rest of the network.
My internet connection is 50/5M and based on my experience it is 45/4,5 in real.
I created the priority queue for priority host with limit-at=0,5M/5M and 4,5M/45M for max-limit. (priority 1)
The rest of network (192.168.88.0/24 and 192.168.89.0/24) got the rest of traffic with priority 8.
add limit-at=512k/5M max-limit=4608k/45M name="priority queue" priority=1/1 target=192.168.88.226/32
add limit-at=4M/40M max-limit=4608k/45M name=rest target=192.168.88.0/23
Will it be good solution?
zhup
 
User avatar
ZeroByte
Forum Guru
Forum Guru
Posts: 4051
Joined: Wed May 11, 2011 6:08 pm

Re: How to prioritize traffic of one host?

Tue Aug 23, 2016 4:50 pm

I strongly recommend a guaranteed minimum bandwidth for the "rest" queue.
You don't want the priority host to be able to completely starve out the entire network for its own use.

Give it limit-at=512K/1M
When given a spoon,
you should not cling to your fork.
The soup will get cold.
 
zhup
Frequent Visitor
Frequent Visitor
Topic Author
Posts: 82
Joined: Thu Dec 03, 2015 10:10 pm

Re: How to prioritize traffic of one host?

Tue Aug 23, 2016 10:06 pm

I strongly recommend a guaranteed minimum bandwidth for the "rest" queue.
You don't want the priority host to be able to completely starve out the entire network for its own use.

Give it limit-at=512K/1M
Which one is better in your opinion?
/queue simple
add limit-at=512k/1M max-limit=4710k/46M name="priority queue" priority=1/1 target=192.168.88.226/32
add limit-at=512k/1M max-limit=4710k/46M name=rest target=192.168.88.0/23
/queue simple
add limit-at=2355k/23M max-limit=4710k/46M name="priority queue" priority=1/1 target=192.168.88.226/32
add limit-at=2355k/23M max-limit=4710k/46M name=rest target=192.168.88.0/23
zhup
 
User avatar
ZeroByte
Forum Guru
Forum Guru
Posts: 4051
Joined: Wed May 11, 2011 6:08 pm

Re: How to prioritize traffic of one host?

Tue Aug 23, 2016 10:13 pm

The limit-at on the priority queue actually doesn't matter very much, just so long as it's set to be something non-zero so that it can get into the "above minimum" state.

I'd say base it on the smaller minimums 512K/1M and then raise the downstream guarantee of the "rest" queue to be 4m
That's only 10% of your bandwidth, but it's much more usable in today's world than a single megabit.

The priority queue is basically going to get all of the bandwidth except up to whatever minimum you reserved for the "rest" queue because the priority queue will either be:
a) below its guaranteed minimum, so it's going to get service no matter what in this case
b) above its guaranteed minimum:
- if the "rest" queue is below IT'S guarantee (4M) then "rest" will get up to that much, regardless of priority
- if the "rest" queue is also above IT'S guaranteed minimum, then priority queue gets the first bite at the apple.
When given a spoon,
you should not cling to your fork.
The soup will get cold.
 
zhup
Frequent Visitor
Frequent Visitor
Topic Author
Posts: 82
Joined: Thu Dec 03, 2015 10:10 pm

Re: How to prioritize traffic of one host?

Tue Aug 23, 2016 10:37 pm

...
The priority queue is basically going to get all of the bandwidth except up to whatever minimum you reserved for the "rest" queue because the priority queue will either be:
a) below its guaranteed minimum, so it's going to get service no matter what in this case
b) above its guaranteed minimum:
- if the "rest" queue is below IT'S guarantee (4M) then "rest" will get up to that much, regardless of priority
- if the "rest" queue is also above IT'S guaranteed minimum, then priority queue gets the first bite at the apple.
Could you please explain to me the above using some examples?
zhup
 
User avatar
ZeroByte
Forum Guru
Forum Guru
Posts: 4051
Joined: Wed May 11, 2011 6:08 pm

Re: How to prioritize traffic of one host?

Tue Aug 23, 2016 11:49 pm

Okay - if the priority host is idle, then the rest devices may use up to max-limit bandwidth.
If The priority host is downloading like there's no tomorrow - then the rest devices may use "limit-at" bandwidth.
The priority host will receive its max-limit bandwidth at all times except for whatever amount is guaranteed to the rest queue.

The first priority of queues is to serve the guaranteed minimum (CIR) bandwidth to every queue.
Any queue which is below its guaranteed minimum amount will get serviced before any queues which have already consumed at or above their minimums.
So if your priority host is the only thing on the network, and it's downloading at 100% of the available bandwidth, then it's free to do so.
However, if another host starts receiving traffic as well, then the "rest" queue will be at 0 utilization, which is below the guaranteed minimum. Therefore, the rest queue will start pushing away some of the priority host's consumption, because a guarantee is a guarantee.... limit-at = a guarantee. The only way to satisfy the guarantee is to take bandwidth away from the 100% utilization of the priority queue.

Then when the "rest" queue reaches the guaranteed minimum of service, both queues' guarantees will then have been met. Further service will be given based on priorities. The priority host will then have the ability to use 100% of whatever remains after "rest" gets its contract fulfilled. So the priority host will slow down by the "rest" queue's "limit-at" amount. If "rest" stops using the line again, then "priority" will go to 100% again.

Conversely, suppose the rest hosts are all combining for 100% utilization.
Priority host comes alive and starts downloading as well. At first, the priority queue will get service simply because it is below its guaranteed minimum. The rest hosts will be slowed down to make room for this second queue's requests for guaranteed bandwidth. The priority doesn't even come into play at that point.
Then as the priority host's throughput increases, it will exceed the minimum guarantee, at which point the priority will come into play. Being higher priority, the priority queue will continue to speed up at the expense of the rest queue, which will slow down at the same time, until the rest queue gets down to its guaranteed minimum bandwidth, at which point the priority queue cannot take any more bandwidth away from the rest queue.

Does this make sense now?
When given a spoon,
you should not cling to your fork.
The soup will get cold.
 
zhup
Frequent Visitor
Frequent Visitor
Topic Author
Posts: 82
Joined: Thu Dec 03, 2015 10:10 pm

Re: How to prioritize traffic of one host?

Wed Aug 24, 2016 11:09 pm

...
Does this make sense now?
It makes sense. Almost clear. Thank you.

But, I have one more question: how to dynamic share the bandwidth the among users? e.g. for 5 computers connected to 45M/4M.
zhup
 
User avatar
ZeroByte
Forum Guru
Forum Guru
Posts: 4051
Joined: Wed May 11, 2011 6:08 pm

Re: How to prioritize traffic of one host?

Thu Aug 25, 2016 12:05 am

Read the Wiki/Docs on PCQ.

Basically, you want to implement a basic upload/download PCQ type which doesn't specify any limitations on the "subqueues" - just leave it alone so it will just "evenly" divide the bandwidth by the number of streams that it sees. You still use the limit-at / max-limit values on the main queue itself the same way as always. PCQ just "shares it fairly."
When given a spoon,
you should not cling to your fork.
The soup will get cold.
 
zhup
Frequent Visitor
Frequent Visitor
Topic Author
Posts: 82
Joined: Thu Dec 03, 2015 10:10 pm

Re: How to prioritize traffic of one host?

Thu Aug 25, 2016 8:53 am

Read the Wiki/Docs on PCQ.

Basically, you want to implement a basic upload/download PCQ type which doesn't specify any limitations on the "subqueues" - just leave it alone so it will just "evenly" divide the bandwidth by the number of streams that it sees. You still use the limit-at / max-limit values on the main queue itself the same way as always. PCQ just "shares it fairly."
What does it means "shares it fairly"?
  • shares it just equally ?
or
  • shares it dynamically according to needs, but taking into account the others and the whole connection bandwidth?
zhup
 
User avatar
ZeroByte
Forum Guru
Forum Guru
Posts: 4051
Joined: Wed May 11, 2011 6:08 pm

Re: How to prioritize traffic of one host?

Thu Aug 25, 2016 4:26 pm

Both statements are true - because "equally" is a dynamic concept.
When you set the pcq-classifier, you can configure it to consider each stream to be a sub-queue (specifying address and port number in the hashing function).
When given a spoon,
you should not cling to your fork.
The soup will get cold.
 
zhup
Frequent Visitor
Frequent Visitor
Topic Author
Posts: 82
Joined: Thu Dec 03, 2015 10:10 pm

Re: How to prioritize traffic of one host?

Thu Aug 25, 2016 4:28 pm

Both statements are true - because "equally" is a dynamic concept.
When you set the pcq-classifier, you can configure it to consider each stream to be a sub-queue (specifying address and port number in the hashing function).
What do you think about the rules below? Is this solution functional?
/ip firewall mangle add chain=forward src-address=192.168.88.0/23 action=mark-connection new-connection-mark=users-con
/ip firewall mangle add connection-mark=users-con action=mark-packet new-packet-mark=users chain=forward

/queue type add name=pcq-download kind=pcq pcq-classifier=dst-address
/queue type add name=pcq-upload kind=pcq pcq-classifier=src-address

/queue tree add name=Download parent=ether1 max-limit=50M
/queue tree add parent=Download queue=pcq-download packet-mark=users

/queue tree add name=Upload parent=pppoe-out1 max-limit=5M
/queue tree add parent=Upload queue=pcq-upload packet-mark=users
zhup
 
User avatar
ZeroByte
Forum Guru
Forum Guru
Posts: 4051
Joined: Wed May 11, 2011 6:08 pm

Re: How to prioritize traffic of one host?

Thu Aug 25, 2016 4:42 pm

I think this solution would have a problem with the upload because by the time the packet is going out the pppoe interface, it will have been modified by srcnat, right? So you're not going to get any "fair queue" behavior with your configuration because every packet is going to have the same src IP, meaning that there is only going to be one sub queue.

You could fix this by making the classifier use dst address on the pppoe interface's queue - this would "share" bandwidth based on destination host, or use src port number, which would essentially create a sub queue for each outbound connection (regardless of which user made it).

I'd probably go for the second of those options.

Or - probably better, just use a simple queue instead of queue trees. The simple queue will see the traffic before it gets masqueraded by the NAT table, so you can use the src-address as the classifier in the upload queue (as your example does).
When given a spoon,
you should not cling to your fork.
The soup will get cold.
 
zhup
Frequent Visitor
Frequent Visitor
Topic Author
Posts: 82
Joined: Thu Dec 03, 2015 10:10 pm

Re: How to prioritize traffic of one host?

Thu Aug 25, 2016 9:56 pm

...
Or - probably better, just use a simple queue instead of queue trees. The simple queue will see the traffic before it gets masqueraded by the NAT table, so you can use the src-address as the classifier in the upload queue (as your example does).
Sorry, I have no idea how to do it.
zhup
 
StefanM
newbie
Posts: 49
Joined: Sun Dec 13, 2015 1:49 am

Re: How to prioritize traffic of one host?

Thu Aug 25, 2016 10:01 pm

I believe PCQ queues would work good for what you want to achieve, and priority 1 when creating queues for specific host
http://wiki.mikrotik.com/wiki/Manual:Queue
MTCNA
MTCRE
 
zhup
Frequent Visitor
Frequent Visitor
Topic Author
Posts: 82
Joined: Thu Dec 03, 2015 10:10 pm

Re: How to prioritize traffic of one host?

Fri Aug 26, 2016 11:54 am

I believe PCQ queues would work good for what you want to achieve, and priority 1 when creating queues for specific host
http://wiki.mikrotik.com/wiki/Manual:Queue
How to prioritize the traffic of one host is now for me almost clear. Now I would like to know more about the dynamic share the bandwidth the among users. But I will make new topic for it.
zhup
 
zhup
Frequent Visitor
Frequent Visitor
Topic Author
Posts: 82
Joined: Thu Dec 03, 2015 10:10 pm

Re: How to prioritize traffic of one host?

Fri Aug 26, 2016 9:38 pm

...
Or - probably better, just use a simple queue instead of queue trees. The simple queue will see the traffic before it gets masqueraded by the NAT table, so you can use the src-address as the classifier in the upload queue (as your example does).
Is this it?
/queue type
add kind=pcq name=pcq_download pcq-classifier=dst-address pcq-dst-address6-mask=64 pcq-rate=45M pcq-src-address6-mask=64
add kind=pcq name=pcq_upload pcq-classifier=src-address pcq-dst-address6-mask=64 pcq-rate=4500k pcq-src-address6-mask=64
/queue simple
add name=dynamic queue=pcq_upload/pcq_download target=192.168.88.0/23
zhup
 
User avatar
ZeroByte
Forum Guru
Forum Guru
Posts: 4051
Joined: Wed May 11, 2011 6:08 pm

Re: How to prioritize traffic of one host?

Mon Aug 29, 2016 5:19 pm

/queue type
add kind=pcq name=pcq_download pcq-classifier=dst-address pcq-dst-address6-mask=64 pcq-rate=45M pcq-src-address6-mask=64
add kind=pcq name=pcq_upload pcq-classifier=src-address pcq-dst-address6-mask=64 pcq-rate=4500k pcq-src-address6-mask=64
/queue simple
add name=dynamic queue=pcq_upload/pcq_download target=192.168.88.0/23 max-limit=4500k/45m
Remove the red.
Add the green.
When given a spoon,
you should not cling to your fork.
The soup will get cold.
 
User avatar
Nixlog
just joined
Posts: 13
Joined: Wed Apr 06, 2016 9:09 am

Re: How to prioritize traffic of one host?

Tue Aug 30, 2016 5:24 pm

ZeroByte, thank you for your explanation. There is some unclear points for me.
Let's say we have the following configuration ROS v6.36.x:
internal net external net
bridge1-local ether10-internet
10.0.0.1/24 xxx.xxx.xxx.xxx
I want to implement the following setup scheme with simple queues:
GlobalQueue 5MB in/5MB out
|-----child HighPriorityTraffic priority=1 min=512k
|-----child OtherTraffic priority=8 min=512k

I want that all child queue will have guaranteed 512k bandwidth
If HighPriorityTraffic need all bandwidth it may take up to 4500K
All child queues must not exceed total(parent) 5M/5M limit - let's say this is our internet connection limit.

We mark our "priority traffic", let's say it will be ssh traffic:
/ip firewall mangle
add action=mark-connection chain=prerouting new-connection-mark=conn_prio \
    passthrough=yes port=22 protocol=tcp
add action=mark-packet chain=prerouting connection-mark=conn_prio \
    new-packet-mark=pack_prio passthrough=no
Next we create our queues:
/queue simple
add max-limit=5M/5M name=GlobalQueue queue=pcq-upload-default/pcq-download-default \
    target=bridge1-local
add limit-at=512k/512k max-limit=1000M/1000M name=OtherTraffic packet-marks=no-mark parent=\
    GlobalQueue queue=pcq-upload-default/pcq-download-default target=bridge1-local
add limit-at=512k/512k max-limit=1000M/1000M name=HighPriorityTraffic packet-marks=\
    pack_prio parent=GlobalQueue priority=1/1 queue=\
    pcq-upload-default/pcq-download-default target=bridge1-local
My questions are:
What is packet-marks="" mean?All marked and unmarked packets?All packets with any mark set?
I can't set limit-at without setting max-limit on child queue even with its parent queue max-limit is set. With this setup i can change all child queues bandwidth with one click - just change GlobalQueue max-limit.
Will my "dirty hack" with parent-child limits work as expected?
If all child queues with equal priority will use full bandwidth - it will be shared equally?
 
User avatar
ZeroByte
Forum Guru
Forum Guru
Posts: 4051
Joined: Wed May 11, 2011 6:08 pm

Re: How to prioritize traffic of one host?

Tue Aug 30, 2016 8:14 pm

My questions are:
What is packet-marks="" mean?All marked and unmarked packets?All packets with any mark set?
I can't set limit-at without setting max-limit on child queue even with its parent queue max-limit is set. With this setup i can change all child queues bandwidth with one click - just change GlobalQueue max-limit.
Will my "dirty hack" with parent-child limits work as expected?
If all child queues with equal priority will use full bandwidth - it will be shared equally?
I'm not an expert with queues, so some of this could be wrong: (especially #1)
1 - I think that just means that packet marks are not considered at all.
2 - this is normal behavior. Just set max-limit to something huge if you never want to touch it again. A sub-queue cannot exceed the max-limit of its parent.
3 - I'm not sure how tree-like behavior works with simple queues. I've seen others on the forums post about such configurations, so I assume that it will work as you expect.
4 - no - the root queue will not behave as a PCQ, even if that is the queue type. Root queues are only considered as "budget" sources.
When given a spoon,
you should not cling to your fork.
The soup will get cold.

Who is online

Users browsing this forum: Baidu [Spider] and 109 guests