MUM 2010
It is currently Tue Feb 09, 2010 5:12 am

All times are UTC + 2 hours [ DST ]




Post new topic Reply to topic  [ 37 posts ] 
Author Message
 Post subject: Burst for each TCP connection
PostPosted: Thu Dec 21, 2006 3:01 pm 
Offline
Staff
Staff
User avatar

Joined: Tue Feb 14, 2006 10:46 am
Posts: 2144
Location: Riga, Latvia
This is little how-to create manual burst using queue tree.

As it is bandwidth control using queue tree first we need to mangle traffic

first i mangle all connections, then i mark first 2Mbytes then i mark the rest of packets

Code:
/ip firewall mangle add chain=forward protocol=tcp action=mark-connection new-connection-mark=new_conn passthrough=yes comment="mark all new connections" disabled=no
/ip firewall mangle add chain=forward protocol=tcp  connection-mark=new_conn connection-bytes=0-2000000 action=mark-packet new-packet-mark=new_packet passthrough=no comment="mark packets" disabled=no
/ip firewall mangle add chain=forward protocol=tcp connection-mark=new_conn action=mark-packet new-packet-mark=old_packets passthrough=no comment="marking old packets" disabled=no


now, when packets has been marked i need queue types that allows me limit traffic per-user basis, so i have to create 2 queue types.

Code:
/queue type add name="PCQ_Upload" kind=pcq pcq-rate=0 pcq-limit=50 pcq-classifier=src-address pcq-total-limit=2000
/queue type add name="PCQ_Download" kind=pcq pcq-rate=0 pcq-limit=50 pcq-classifier=dst-address pcq-total-limit=2000


now i have to limit all the rates using queue tree, i will limit it that way - that first 2Mbits (as in mangle) will have higher priority over rest of traffic where connection bytes exceed 2Mbits.

i assume that connection that is available have 5Mbits full-duplex

Code:
/queue tree add name="Main_Upload" parent=Public packet-mark="" limit-at=0 queue=default priority=8 max-limit=5000000 burst-limit=0 burst-threshold=0 burst-time=0s disabled=no

/ queue tree add name="Up First 2Mbyte" parent=Main_Upload packet-mark=new_packet limit-at=4000000 queue=PCQ_Upload priority=1 max-limit=5000000 burst-limit=0 burst-threshold=0 burst-time=0s disabled=no

/ queue tree add name="Up Rest Mbytes" parent=Main_Upload packet-mark=old_packets limit-at=1000000 queue=PCQ_Upload priority=8 max-limit=5000000 burst-limit=0 burst-threshold=0 burst-time=0s disabled=no

/ queue tree add name="Main_Download" parent=Local packet-mark="" limit-at=0 queue=default priority=8 max-limit=5000000 burst-limit=0 burst-threshold=0 burst-time=0s disabled=no

/ queue tree add name="Down First 2Mbyte" parent=Main_Download packet-mark=new_packet limit-at=4000000 queue=PCQ_Download priority=1 max-limit=5000000 burst-limit=0 burst-threshold=0 burst-time=0s disabled=no

/ queue tree add name="Down Rest Mbytes" parent=Main_Download packet-mark=old_packets limit-at=1000000 queue=PCQ_Download priority=8 max-limit=5000000 burst-limit=0 burst-threshold=0 burst-time=0s disabled=no


any suggestions? comments?


Last edited by janisk on Tue Feb 06, 2007 3:14 pm, edited 3 times in total.

Top
 Profile  
 
 Post subject:
PostPosted: Thu Dec 21, 2006 4:25 pm 
Offline
Long time Member
Long time Member
User avatar

Joined: Wed May 18, 2005 5:57 pm
Posts: 671
Location: Moscow
I was 1day from doing the same thing (make some configuration and paste it in here) - Good work Janis

And what about UDP??? 8) 8) :wink:

_________________
I know what i don't know, do you?


Top
 Profile  
 
 Post subject:
PostPosted: Thu Dec 21, 2006 4:36 pm 
Offline
Staff
Staff
User avatar

Joined: Tue Feb 14, 2006 10:46 am
Posts: 2144
Location: Riga, Latvia
maybe someone could do that?


Last edited by janisk on Fri Dec 22, 2006 11:54 am, edited 1 time in total.

Top
 Profile  
 
 Post subject:
PostPosted: Thu Dec 21, 2006 4:56 pm 
Offline
just joined

Joined: Thu Dec 21, 2006 1:07 pm
Posts: 12
hi,

i'm also very interesting in this advances QoS. It will be gret to find a right solution and to put it like an example in one of manual.

I'll try also to post some scripts


Top
 Profile  
 
 Post subject:
PostPosted: Thu Dec 21, 2006 5:42 pm 
Offline
Frequent Visitor
Frequent Visitor
User avatar

Joined: Thu Jul 14, 2005 10:21 am
Posts: 55
Location: Latvia, Riga
mmx wrote:
hi,

i'm also very interesting in this advances QoS. It will be gret to find a right solution and to put it like an example in one of manual.

I'll try also to post some scripts


WIKIPEDIA is for examples. If you make some good example script, better place it here: http://wiki.mikrotik.com/wiki/Main_Page


Top
 Profile  
 
 Post subject:
PostPosted: Mon Feb 05, 2007 7:31 pm 
Offline
just joined

Joined: Mon Aug 28, 2006 5:38 pm
Posts: 5
this is very useful and powerful procedure.....thank u janisk....i applied it to my MT and it works fine :lol:


Top
 Profile  
 
 Post subject:
PostPosted: Mon Feb 05, 2007 7:56 pm 
Offline
Long time Member
Long time Member
User avatar

Joined: Sat Nov 26, 2005 11:52 pm
Posts: 613
does the marking rules mark the PROXY packets ??
i think it doesnt ..


Top
 Profile  
 
 Post subject:
PostPosted: Mon Feb 05, 2007 10:58 pm 
Offline
Long time Member
Long time Member
User avatar

Joined: Sat Nov 26, 2005 11:52 pm
Posts: 613
very important :

from the manual :

Quote:
connection-bytes=2000000-0 means that the rule matches if more than 2MB has been transfered through the relevant connection

2000000 is 2MByte not 2Mbit...


Top
 Profile  
 
 Post subject:
PostPosted: Tue Feb 06, 2007 11:28 am 
Offline
Staff
Staff
User avatar

Joined: Tue Feb 14, 2006 10:46 am
Posts: 2144
Location: Riga, Latvia
samsoft08 wrote:
very important :

from the manual :

Quote:
connection-bytes=2000000-0 means that the rule matches if more than 2MB has been transfered through the relevant connection

2000000 is 2MByte not 2Mbit...


in that field you enter value of - how many bits to count.

byte is 8 bits

kbyte is 1024 bytes and 8192 bits

so do the math how much 2000000 bits are in Bytes or MBytes


Top
 Profile  
 
 Post subject:
PostPosted: Tue Feb 06, 2007 2:22 pm 
Offline
Long time Member
Long time Member
User avatar

Joined: Sat Nov 26, 2005 11:52 pm
Posts: 613
thats right .. but in your post you said 2Mbits which is wrong ..
its 2Mbytes according to the manual..


Top
 Profile  
 
 Post subject:
PostPosted: Tue Feb 06, 2007 3:15 pm 
Offline
Staff
Staff
User avatar

Joined: Tue Feb 14, 2006 10:46 am
Posts: 2144
Location: Riga, Latvia
corrected error in my post, thx for pointing that out.

these really are bytes not bits

then do not mess with M is for 1000000 not 1024*1024 (like in hard-drives)


Top
 Profile  
 
 Post subject: Re: Burst for each TCP connection
PostPosted: Tue Jun 19, 2007 3:02 am 
Offline
just joined

Joined: Tue Jun 05, 2007 10:28 pm
Posts: 10
janisk wrote:
This is little how-to create manual burst using queue tree.

As it is bandwidth control using queue tree first we need to mangle traffic

first i mangle all connections, then i mark first 2Mbytes then i mark the rest of packets

Code:
/ip firewall mangle add chain=forward protocol=tcp action=mark-connection new-connection-mark=new_conn passthrough=yes comment="mark all new connections" disabled=no
/ip firewall mangle add chain=forward protocol=tcp  connection-mark=new_conn connection-bytes=0-2000000 action=mark-packet new-packet-mark=new_packet passthrough=no comment="mark packets" disabled=no
/ip firewall mangle add chain=forward protocol=tcp connection-mark=new_conn action=mark-packet new-packet-mark=old_packets passthrough=no comment="marking old packets" disabled=no


any suggestions? comments?



Hi Janisk,


Thanks for this good configuration, it's so cool.

But how to target those mangle markings above to some IP addresses or some Group of IP addresses?? Hopefully you won't mind to teach a newbie like me.


Thks n Rgds,

Men Fung


Top
 Profile  
 
 Post subject: Re: Burst for each TCP connection
PostPosted: Tue Jun 19, 2007 12:20 pm 
Offline
just joined

Joined: Tue Jun 05, 2007 10:28 pm
Posts: 10
Hi Janisk,

I did it well... I was confous before, I shared the internet connection to 2 networks, LAN and WLAN, but everything is OK now, I also solve my client's http download problem that caused all the other clients can not browse. Your configuration is really good... once more thks..

And if I have another problem in future, pls give a hand.


Thks n Rgds,

Men Fung


Top
 Profile  
 
 Post subject: Re: Burst for each TCP connection
PostPosted: Tue Sep 25, 2007 2:39 pm 
Offline
Member Candidate
Member Candidate

Joined: Thu May 17, 2007 4:25 pm
Posts: 165
menfung wrote:
Hi Janisk,

I did it well... I was confous before, I shared the internet connection to 2 networks, LAN and WLAN, but everything is OK now, I also solve my client's http download problem that caused all the other clients can not browse. Your configuration is really good... once more thks..

And if I have another problem in future, pls give a hand.


Thks n Rgds,

Men Fung


what mean pubblic in configuration of queue tree


Top
 Profile  
 
 Post subject: Re: Burst for each TCP connection
PostPosted: Mon Jan 21, 2008 8:16 pm 
Offline
Frequent Visitor
Frequent Visitor

Joined: Mon Jun 26, 2006 9:46 am
Posts: 70
what should be in parent if we use PPPOE client instead? because after that we would limit the user in simple queue.


Top
 Profile  
 
 Post subject: Re: Burst for each TCP connection
PostPosted: Tue Jan 22, 2008 7:42 pm 
Offline
just joined

Joined: Fri May 25, 2007 3:10 pm
Posts: 10
i have the same problem... probably the default config. All simple is in this.


Top
 Profile  
 
 Post subject: Re: Burst for each TCP connection
PostPosted: Tue Jan 22, 2008 9:12 pm 
Offline
just joined

Joined: Tue Jun 05, 2007 10:28 pm
Posts: 10
trottolino1970 wrote:
what mean pubblic in configuration of queue tree


Sorry.. just read this message...

Public is the name I gave to the interface that connected to the ISP.


thks,


Top
 Profile  
 
 Post subject: Re: Burst for each TCP connection
PostPosted: Mon Feb 04, 2008 1:30 pm 
Offline
Frequent Visitor
Frequent Visitor

Joined: Sun Dec 18, 2005 5:23 pm
Posts: 76
Why is on Parent Upload and Download queue queue type set to default and not to PCQ_UP/PCQ_DL?


Top
 Profile  
 
 Post subject: Re: Burst for each TCP connection
PostPosted: Tue Feb 12, 2008 11:18 am 
Offline
Frequent Visitor
Frequent Visitor

Joined: Sun Dec 18, 2005 5:23 pm
Posts: 76
Anyone...?


Top
 Profile  
 
 Post subject: Re: Burst for each TCP connection
PostPosted: Thu Feb 14, 2008 3:54 am 
Offline
Forum Guru
Forum Guru
User avatar

Joined: Mon Jun 19, 2006 11:15 pm
Posts: 4008
Location: Home Network Ltd., Minsk, Belarus
pospanko wrote:
Why is on Parent Upload and Download queue queue type set to default and not to PCQ_UP/PCQ_DL?

because PCQ do not affect child queues, so it really makes no matter, what type you set for parent: parent is just to see total traffic

_________________
For every complex problem, there is a solution that is simple, neat, and wrong.

¡ɹǝ|SOɹǝʇnoɹ ʞıʇoɹʞıW ɯ‚|


Top
 Profile  
 
 Post subject: Re: Burst for each TCP connection
PostPosted: Thu Feb 14, 2008 2:01 pm 
Offline
Frequent Visitor
Frequent Visitor

Joined: Sun Dec 18, 2005 5:23 pm
Posts: 76
Ok. Thx mate!


Top
 Profile  
 
 Post subject: Re: Burst for each TCP connection
PostPosted: Thu Feb 28, 2008 10:56 am 
Offline
just joined

Joined: Fri Dec 08, 2006 12:40 pm
Posts: 7
cool code dude....

but if i had 3 different client group in my office.... each group the ip listed in adrress list.
ie:
ip1 192.168.1.1
ip1 192.168.1.5
ip1 192.168.1.7
ip2 192.168.1.4
ip2 192.168.1.12
ip2 192.168.1.2
ip3 192.168.1.10
ip3 192.168.1.11
group 1 limit traffic by 96 kbps download 96 kbps upload
group 2 limit traffic by 128 kbps download 64 upload
group 3 limit traffic by 200 kbps download 128 upload

each group using PCQ Equal Share with mangle and queue tree writen in wiki
how to implemented those script to my script?

so i must write 2 connection mark? and 2 queue tree for different group, is that right?

another question.
i had idea to traffic prioritizing in each group, which email traffic (pop3)to be higher priority than http traffic. how to implemented like these to PCQ Equal Share in wiki???


Top
 Profile  
 
 Post subject: Re: Burst for each TCP connection
PostPosted: Thu Feb 28, 2008 9:34 pm 
Offline
Frequent Visitor
Frequent Visitor

Joined: Mon Jun 26, 2006 9:46 am
Posts: 70
Dear Friends,

I have tested in my network and there is a nice problem ;) that may be reason you to dont use this code or you may find the way to solve this problem.

In my situation which i have set the 1024kbps for first 500k and then fall down to 512kbps for special users when a user download a big file after 2 or 3 MB fall down to 512kbps BUT if that person use software like IDM (Internet Download Manager) each time he/she click on STOP and then again START he/she will get 1024kbps speed :D
ofcouse no one call me to tell me because i didnt use this code generally just for test only and I found this :shock:

Please tell me your opinion about this. it wil be nice if we could find the way to block this kind of trick which users may (actually) will use.


Top
 Profile  
 
 Post subject: Re: Burst for each TCP connection
PostPosted: Thu Feb 28, 2008 11:05 pm 
Offline
Member Candidate
Member Candidate
User avatar

Joined: Mon Sep 03, 2007 7:19 pm
Posts: 223
Location: Uttara, Dhaka, Bangladesh
Dear friend Antixx,

Yes there is a problem with download managers, cause if clients stops and starts his/her download after every 1mb then it's starts as a freash (1st rule) rate ratio. and with download manager there has few options like 5 connections for a file download that's why the download bandwidth fluctuate very time between 1st and 2nd pcq rule. you can close per IP connection limites with firewall.

Hope you understand that

Thanks

_________________
Don't worry, be happy :) .......


Top
 Profile  
 
 Post subject: Re: Burst for each TCP connection
PostPosted: Fri Feb 29, 2008 6:05 pm 
Offline
Frequent Visitor
Frequent Visitor

Joined: Mon Jun 26, 2006 9:46 am
Posts: 70
hulk-bd wrote:
Dear friend Antixx,

Yes there is a problem with download managers, cause if clients stops and starts his/her download after every 1mb then it's starts as a freash (1st rule) rate ratio. and with download manager there has few options like 5 connections for a file download that's why the download bandwidth fluctuate very time between 1st and 2nd pcq rule. you can close per IP connection limites with firewall.

Hope you understand that

Thanks


I think i understand the problem and the reason. but in my view if i limit the connected to each dst ip to 5 connection this problem will occure again? isnt it?


Top
 Profile  
 
 Post subject: Re: Burst for each TCP connection
PostPosted: Sun Mar 09, 2008 10:37 pm 
Offline
Member
Member

Joined: Mon Oct 17, 2005 11:43 am
Posts: 315
Location: Titel Serbia
if there is wackos to stop start download every minute or so, then let them do that . . .


Top
 Profile  
 
 Post subject: Re: Burst for each TCP connection
PostPosted: Mon Mar 10, 2008 2:14 am 
Offline
newbie

Joined: Tue May 30, 2006 11:30 pm
Posts: 27
Please how can this be applied on a mt with load balancing?
Thanks


Top
 Profile  
 
 Post subject: Re: Burst for each TCP connection
PostPosted: Mon Mar 10, 2008 1:01 pm 
Offline
Staff
Staff
User avatar

Joined: Tue Feb 14, 2006 10:46 am
Posts: 2144
Location: Riga, Latvia
first i would see that user that stops download after each X Mbit you have set in a download.

please read manual about simple queues and queue tree. if you have several groups, then just add tree nodes to the queue tree and set up configuration for them, so, they function properly, you will have to mark connections and then packets for each type of users, you just add dst-address-list for download and src-address-list for upload for each group.

after that you simple follow the example


Top
 Profile  
 
 Post subject: Re: Burst for each TCP connection
PostPosted: Fri Mar 14, 2008 1:51 pm 
Offline
Frequent Visitor
Frequent Visitor

Joined: Mon Jun 26, 2006 9:46 am
Posts: 70
i think it is misunderstanding, with this setup usercan achive more bandwidth by doing stop and start the download manager software, anyway to solve this problem?

it will be great doing this...

Thank you very much in did/
janisk wrote:
first i would see that user that stops download after each X Mbit you have set in a download.

please read manual about simple queues and queue tree. if you have several groups, then just add tree nodes to the queue tree and set up configuration for them, so, they function properly, you will have to mark connections and then packets for each type of users, you just add dst-address-list for download and src-address-list for upload for each group.

after that you simple follow the example


Top
 Profile  
 
 Post subject: Re: Burst for each TCP connection
PostPosted: Mon Mar 31, 2008 3:34 pm 
Offline
just joined

Joined: Sun May 28, 2006 11:56 am
Posts: 16
Hi to all. I've tested this configuration on my MT 2.9.51 at work. And i must say is wonderful.But the problem is if i start to download with flashget, configured to download with only 1 connections, this setup is perfect.Sow when i configured flashget to download with 5-10 connections, the download speed vary from 1st rule to the 2nd rule after 1 min and after 3 min vary from 2nd rule to the 1st, and so on.So my opinion is to limit at firewall filter to 1/32 connections for the specific packet_mark old.At this point i see another problem, at firwall filter we can drop only syn connections with packet_mark old, what about those with estabilished type, cause if i start to download with flashget with configuration of 10 connections, at this moment in connections tab of MT is see 10 connections estabilished. How can i close 9 of these?
P.s. sorry for my bad english. my configuration is excast as descripted in this thread.
Best regards to all from Albania.


Top
 Profile  
 
 Post subject: Re: Burst for each TCP connection
PostPosted: Fri Apr 11, 2008 1:23 pm 
Offline
just joined

Joined: Sun May 28, 2006 11:56 am
Posts: 16
No one can help at this point?


Top
 Profile  
 
 Post subject: Re: Burst for each TCP connection
PostPosted: Wed May 14, 2008 2:59 am 
Offline
Member
Member

Joined: Mon Oct 17, 2005 11:43 am
Posts: 315
Location: Titel Serbia
Where have all posts gone??!!


Top
 Profile  
 
 Post subject: Re: Burst for each TCP connection
PostPosted: Wed Aug 13, 2008 8:34 am 
Online
Long time Member
Long time Member

Joined: Thu Jul 27, 2006 5:01 am
Posts: 510
Bump.

I've been using this, works great, however, does TCP have to be identified in the mangle rules?

I'm having a hard time shaping other traffic separately. If I try to use mangle to prioritize port 80 and give other ports a 256k limit, PCQ just stops.

In order to shape P2P, I have to use another RB. I've been doing it on the client side, works well as I only have two problem clients, but I'd like to have a blanket rule so some new customer that discovers P2P won't go completely nuts on the network.

edit: tinkering with my 2nd AP in line, first doing this as the primary, it appears that choosing the TCP protocol is not required. Any input from those more experienced would be greatly appreciated.


Top
 Profile  
 
 Post subject: Re: Burst for each TCP connection
PostPosted: Sun Oct 11, 2009 10:22 pm 
Offline
Frequent Visitor
Frequent Visitor
User avatar

Joined: Fri Jan 23, 2009 10:51 am
Posts: 87
What of for hotspot users.

I have 3 interfaces,
ether1 = wan- isp
ether2 = hotspot ip range: 172.16.0.0/24
ether3 = local users = ip range : 192.168.20.0/24

How do i go about it


Top
 Profile  
 
 Post subject: Re: Burst for each TCP connection
PostPosted: Fri Jan 15, 2010 8:27 am 
Offline
newbie

Joined: Mon Jun 16, 2008 2:12 am
Posts: 46
0ldman wrote:
Bump.

I've been using this, works great, however, does TCP have to be identified in the mangle rules?

I'm having a hard time shaping other traffic separately. If I try to use mangle to prioritize port 80 and give other ports a 256k limit, PCQ just stops.

In order to shape P2P, I have to use another RB. I've been doing it on the client side, works well as I only have two problem clients, but I'd like to have a blanket rule so some new customer that discovers P2P won't go completely nuts on the network.

edit: tinkering with my 2nd AP in line, first doing this as the primary, it appears that choosing the TCP protocol is not required. Any input from those more experienced would be greatly appreciated.


I have the same problem, i make a lot of rules to mark, ssh,p2p, pop, etc. and make a queue for prioritize it, then mark it in postrouting and prerouting, works perfect, but when i setup this or the Janis mangle example from the mum that marks connections in forward the apply PCQ, the pcq simply doesnt work.. somebody can help us? thanks


Top
 Profile  
 
 Post subject: Re: Burst for each TCP connection
PostPosted: Fri Jan 15, 2010 8:42 pm 
Offline
Member Candidate
Member Candidate

Joined: Mon Mar 09, 2009 12:00 am
Posts: 234
Maybe you are overwriting forward chain marks with postrouting marks?


Top
 Profile  
 
 Post subject: Re: Burst for each TCP connection
PostPosted: Sat Jan 16, 2010 12:11 am 
Offline
newbie

Joined: Mon Jun 16, 2008 2:12 am
Posts: 46
well, the forward chain marks connection based on src-adress-list but the prerouting chains marks packets based on src and dst ports. alos mark some connection to use the connection-bytes but its marked also by src port 80.. any idea?


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 37 posts ] 

All times are UTC + 2 hours [ DST ]


Who is online

Users browsing this forum: 0ldman, MSNbot Media and 3 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
MUM Poland and MUM China free REGISTRATION OPEN