Graphic Web Design, Computer Network, Balinese Culture

Loading...
5 comments

Combine Queue Simple and Queue Tree in Traffic Congestion

Traffic Congestion must be the case that we are ready to deal with it before it happens, so that the client does not feel mutually interfere with each other in the use of internet connection. Actually, every method in the management of bandwidth depending on the conditions of internet network that you have. However, to deal with clients with different characters, Here is a bandwidth management by combining simple queue for browsing as a bandwidth on each clients that totally covers the download and streaming bandwidth.

In this case actually I want to control especially against download and streaming bandwidth speed, as well as excessive browsing. Excessive browsing can also cause traffic Congestion, because many websites use popup windows that forces us accidentally client to open many windows with a lot of picture so could lead to traffic congestion.

For Example:
Situation  and Condition of my Internet Network
I have Bandwidth totally = up to 2 Mbps, and shared to 8 clients
Simple Queues :
Client Billing    : 192.168.1.11, Max-limit = 256k, Burst-limit=720k, Burst Threshold=192k
Client 1        : 192.168.1.17, Max-limit = 256k, Burst-limit=720k, Burst Threshold=192k
Client 2        : 192.168.1.16, Max-limit = 256k, Burst-limit=720k, Burst Threshold=192k
Client 3        : 192.168.1.15, Max-limit = 256k, Burst-limit=720k, Burst Threshold=192k
Client 4        : 192.168.1.14, Max-limit = 256k, Burst-limit=720k, Burst Threshold=192k
Client 5        : 192.168.1.20, Max-limit = 256k, Burst-limit=720k, Burst Threshold=192k
Client 6        : 192.168.1.21, Max-limit = 256k, Burst-limit=720k, Burst Threshold=192k
Client Master    : 192.168.1.8 Max-limit = 256k, Burst-limit=720k, Burst Threshold=192k

About how to create the simple queue for each client and the setup of bursts limit, please see on the articles previously. And if you already know, we will be able to continue it.

Simple Queues above will we functioned as a total bandwidth per client, where the Max-Limit, Burst Limit, and Burst Threshold to make a dynamics bandwidth speed, to prevent the tendency download and streaming domination. From here I want to make another download and streaming speed limits that  completely under control. For that we will make the queue tree for each client who download and streaming. Before you make the queue tree, we will define download and streaming at layer 7 protocol, defining the address list for each client, then marking it in the mangle rule of the firewall finally will be limited with bursts in queue tree.

1. Marking Download and Streaming on Firewall Layer 7 protocol

/ip firewall layer7-protocol
add comment="" name=download regexp="^.*get.+\\.(exe|rar|iso|zip|7zip|flv|mkv|avi|mp4|3gp|rmvb|mp3|img|dat|mov).*\$"
add comment="" name=streaming regexp="^.*get.+\\.(c.youtube.com|cdn.dailymotion.com|metacafe.com|mccont.com).*\$"

You can perform additional script above if you feel necessary. If you okay, let you copy the script above to the new terminal window of Winbox then paste it there! the result is as shown below!

2. Using the Address List to Separate the Mangle Rule every Clients

/ip firewall address-list
add list=Billing address=192.168.1.11 comment="" disabled=no
add list=Client1 address=192.168.1.17 comment="" disabled=no
add list=Client2 address=192.168.1.16 comment="" disabled=no
add list=Client3 address=192.168.1.15 comment="" disabled=no
add list=Client4 address=192.168.1.14 comment="" disabled=no
add list=Client5 address=192.168.1.20 comment="" disabled=no
add list=Client6 address=192.168.1.21 comment="" disabled=no
add list=Master address=192.168.1.8 comment="" disabled=no

Clients and Address List according the name of clients and the IP address of Client Unit as you defined on simple queues previously! Copy script above, and paste to the new terminal windows.  the result as you can see on the picture below.


3. Marking Download and Streaming per Clients on Mangle Rules

Mangle Rule for Download File

/ip firewall mangle 
add comment="BillingDown" chain=prerouting layer7-protocol=download action=mark-packet new-packet-mark=BillingDown-pkt src-address-list=Billing passthrough=no
add comment="Client1Down" chain=prerouting layer7-protocol=download action=mark-packet new-packet-mark=Client1Down-pkt src-address-list=Client1 passthrough=no
add comment="Client2Down" chain=prerouting layer7-protocol=download action=mark-packet new-packet-mark=Client2Down-pkt src-address-list=Client2 passthrough=no
add comment="Client3Down" chain=prerouting layer7-protocol=download action=mark-packet new-packet-mark=Client3Down-pkt src-address-list=Client3 passthrough=no
add comment="Client4Down" chain=prerouting layer7-protocol=download action=mark-packet new-packet-mark=Client4Down-pkt src-address-list=Client4 passthrough=no
add comment="Client5Down" chain=prerouting layer7-protocol=download action=mark-packet new-packet-mark=Client5Down-pkt src-address-list=Client5 passthrough=no
add comment="Client6Down" chain=prerouting layer7-protocol=download action=mark-packet new-packet-mark=Client6Down-pkt src-address-list=Client6 passthrough=no
add comment="MasterDown" chain=prerouting layer7-protocol=download action=mark-packet new-packet-mark=MasterDown-pkt src-address-list=Master passthrough=no

Mangle Rule for Video Streaming:

/ip firewall mangle 
add comment="BillingStream" chain=prerouting layer7-protocol=streaming action=mark-packet new-packet-mark=BillingStream-pkt src-address-list=Billing passthrough=no
add comment="Client1Stream" chain=prerouting layer7-protocol=streaming action=mark-packet new-packet-mark=Client1Stream-pkt src-address-list=Client1 passthrough=no
add comment="Client2Stream" chain=prerouting layer7-protocol=streaming action=mark-packet new-packet-mark=Client2Stream-pkt src-address-list=Client2 passthrough=no
add comment="Client3Stream" chain=prerouting layer7-protocol=streaming action=mark-packet new-packet-mark=Client3Stream-pkt src-address-list=Client3 passthrough=no
add comment="Client4Stream" chain=prerouting layer7-protocol=streaming action=mark-packet new-packet-mark=Client4Stream-pkt src-address-list=Client4 passthrough=no
add comment="Client5Stream" chain=prerouting layer7-protocol=streaming action=mark-packet new-packet-mark=Client5Stream-pkt src-address-list=Client5 passthrough=no
add comment="Client6Stream" chain=prerouting layer7-protocol=streaming action=mark-packet new-packet-mark=Client6Stream-pkt src-address-list=Client6 passthrough=no
add comment="MasterStream" chain=prerouting layer7-protocol=streaming action=mark-packet new-packet-mark=MasterStream-pkt src-address-list=Master passthrough=no

Marking mangle rule like based on address list that you defined yet by adding “src-address-list=ClientName” on the script of mangle rule above. Copy the script mangle rule of download and streaming, and paste on the new terminal window winbox. The result as you can see as the picture below!

  

4. Queue Tree to Capture Connection Packet on the mangle rules

Queue tree will take the packet-mark that was created on the firewall mangle. Give the speed limit value of each packet-mark.

Queue Tree for Download Files per clients :

/queue tree
add name="BillingDown" parent=global-out packet-mark=BillingDown-pkt limit-at=2200 queue=default priority=8 max-limit=2200 burst-limit=2560 burst-threshold=1650 burst-time=2s
add name="Client1Down" parent=global-out packet-mark=Client1Down-pkt limit-at=2200 queue=default priority=8 max-limit=2200 burst-limit=2560 burst-threshold=1650 burst-time=2s
add name="Client2Down" parent=global-out packet-mark=Client2Down-pkt limit-at=2200 queue=default priority=8 max-limit=2200 burst-limit=2560 burst-threshold=1650 burst-time=2s
add name="Client3Down" parent=global-out packet-mark=Client3Down-pkt limit-at=2200 queue=default priority=8 max-limit=2200 burst-limit=2560 burst-threshold=1650 burst-time=2s
add name="Client4Down" parent=global-out packet-mark=Client4Down-pkt limit-at=2200 queue=default priority=8 max-limit=2200 burst-limit=2560 burst-threshold=1650 burst-time=2s
add name="Client5Down" parent=global-out packet-mark=Client5Down-pkt limit-at=2200 queue=default priority=8 max-limit=2200 burst-limit=2560 burst-threshold=1650 burst-time=2s
add name="Client6Down" parent=global-out packet-mark=Client6Down-pkt limit-at=2200 queue=default priority=8 max-limit=2200 burst-limit=2560 burst-threshold=1650 burst-time=2s
add name="MasterDown" parent=global-out packet-mark=MasterDown-pkt limit-at=2200 queue=default priority=8 max-limit=2200 burst-limit=2560 burst-threshold=1650 burst-time=2s

Note :  If you give the value of bandwidth : 2200, every clients will get around 22 Kb/s of download file speed. Usually I give the value 220k, Rather different the setup limitation value here, I don’t know why? but as I wish, I just use the value 2200 to give the speed of each client around 22 Kb/s of download speed.

Queue Tree for Video Streaming per Clients :

/queue tree
add name="BillingStream" parent=global-out packet-mark=BillingStream-pkt limit-at=2200 queue=default priority=7 max-limit=2200 burst-limit=2560 burst-threshold=1650 burst-time=2s
add name="Client1Stream" parent=global-out packet-mark=Client1Stream-pkt limit-at=2200 queue=default priority=7 max-limit=2200 burst-limit=2560 burst-threshold=1650 burst-time=2s
add name="Client2Stream" parent=global-out packet-mark=Client2Stream-pkt limit-at=2200 queue=default priority=7 max-limit=2200 burst-limit=2560 burst-threshold=1650 burst-time=2s
add name="Client3Stream" parent=global-out packet-mark=Client3Stream-pkt limit-at=2200 queue=default priority=7 max-limit=2200 burst-limit=2560 burst-threshold=1650 burst-time=2s
add name="Client4Stream" parent=global-out packet-mark=Client4Stream-pkt limit-at=2200 queue=default priority=7 max-limit=2200 burst-limit=2560 burst-threshold=1650 burst-time=2s
add name="Client5Stream" parent=global-out packet-mark=Client5Stream-pkt limit-at=2200 queue=default priority=7 max-limit=2200 burst-limit=2560 burst-threshold=1650 burst-time=2s
add name="Client6Stream" parent=global-out packet-mark=Client6Stream-pkt limit-at=2200 queue=default priority=7 max-limit=2200 burst-limit=2560 burst-threshold=1650 burst-time=2s
add name="MasterStream" parent=global-out packet-mark=MasterStream-pkt limit-at=2200 queue=default priority=7 max-limit=2200 burst-limit=2560 burst-threshold=1650 burst-time=2s

Copy the script queue tree for download and streaming above, and paste to the new terminal window. The result as you can see like the picture below!


For more clearly how to make the fourth steps above, let’s see the following video!


After implementing all things above on my internet network, I have two things to tell you, something that I have found during applying the above method in my experience.
  • Browsing and Download are work as I expected,  current within the limit values that was given on each clients.
  • Video Streams is running so slowly then I expected, If I give a higher value video streams running so fast, it means video stream bandwidth so difficult controlled per clients.
Can you give the reason or the best way to control Bandwidth Video Streams on each clients, because of this, I just make 1 mangle rule and queue tree as a whole bandwidth video stream, and give the limit value  as I expected.

5. Remove Video Streams of Mangle Rule and Queue Tree Each Clients

I am going to control video streams to be unified using 1 mangle rule and queue tree

/ip firewall mangle 
add comment="Video Streams" chain=prerouting layer7-protocol=streaming action=mark-packet new-packet-mark=streaming-pkt passthrough=no
/queue tree
add name="Video Stream" parent=global-out packet-mark=streaming-pkt limit-at=220k queue=default priority=7 max-limit=220k burst-limit=256k burst-threshold=165k burst-time=2s

After removing mangle rule and queue tree for streaming on each clients, copy two script of the single video stream limitation above, and paste to the new terminal window winbox. The result as you can see like the pictures below!

 
In this way all things is work as I expected. Browsing, Download on each clients, and Streaming as totally have controlled as well and traffic congestion has been resolved. For some other reason, if you want the download packets to be one or just single queue tree rule, the scripts will be like this!

/ip firewall mangle
add comment=All-Download chain=prerouting layer7-protocol=download action=mark-packet new-packet-mark=download-pkt passthrough=no
/queue tree
add name=All-Download parent=global-out packet-mark=download-pkt limit-at=220k queue=default priority=7 max-limit=220k burst-limit=256k burst-threshold=165k burst-time=2s

That was all, if you any question, opinion, experience and suggestion! Let you leave the comments here!

Share This Article :
Related Articles

5 comments :

  1. mas ketut.. thanks ilmunya, saya banyak ambil setting dr blog mas untuk dijadikan pelajaran.. sekali lg thank's for share

    ReplyDelete
    Replies
    1. Sama-sama mas Husnul, terima kasih juga atas kunjungannya dan semoga bisa bermanfaat...!

      Delete
  2. mas agus,, gmn klo kondisinya... ada 8 client, tp 1 client aj yg aktif,,,
    bisakah bandwith di loss kan...????
    kan syg kalau cuma 1 orang tetap di limit...

    adakah posting seperti kondisi di atas. termikash

    ReplyDelete
  3. hello my friend iwant reset Tx/Rx bytes(Reset countres) in my interfaces every 1min
    please help me

    ReplyDelete
  4. Sir, im planning to buy hex-lite, do you have tutorial for 2 ISP or Multi Wan that also implemented bandwith management, prioritization, separation of browsing(1 ISP) and online games(2 ISP)..Much appreciated if you can share ...

    ReplyDelete

Back to Top