Skip to main content

Traffic Shaping - Bagian 3

Bagian ini adalah bagian terakhir dari penjelasan traffic shaping. Kita akan mendiskusikan sedikit mengenai ingress qdisc. Traffic shaping yang kita bicarakan pada dua tulisan sebelumnya merupakan implementasi egress qdisc, dimana kita men-shape traffic yang meninggalkan eth1 (trafik upload). Untuk trafik yang menuju eth1 (trafik incoming) kita menerapkan ingress qdisc (lihat diagram dari jengelh untuk mendapatkan gambaran mengenai ingress dan egress). Untuk trafik incoming kita tidak dapat melakukan shaping, tetapi yang kita lakukan adalah membuat policy, implementasi di tc adalah police. Yang akan kita lakukan adalah membuat policy untuk melambatkan trafik yang masuk agar tidak terjadi kongesti di server kita.

Perhatikan bagian:

# attach ingress policer;
# ngelambatin download sedikit
tc qdisc add dev eth1 handle ffff: ingress
# lambatin semua paket yang datang terlalu cepat
tc filter add dev eth1 parent ffff: protocol ip prio 50 u32 match ip src \
0.0.0.0/0 police rate ${DOWNLINK}kbit burst 10k drop flowid :1

Arti dari baris tc qdisc add dev eth1 handle ffff: ingress adalah meng-attach ingress qdisc pada eth 1 dengan nama handle ffff: . Hal ini sama halnya dengan ketika mengattach egress qdisc dan membuat root class untuk trafik upload, hanya ingress qdisc berfungsi untuk klasifikasi trafik download.

Selanjutnya pada baris berikutnya ada u32 classifier, yang merupakan salah satu filter classifier yang sangat powerful dalam implementasi tc. u32 akan memfilter paket berdasarkan field dari paket ip (source ip address) yang dianalisa adalah 32 bit header dari paket. Apabila ada kondisi yang sesuai (match) dengan selector maka suatu tindakan (action) akan dilakukan. u32 selector berisi definisi yang akan ditemui pada suatu paket yang sedang diproses berupa informasi bit mana yang harus match di dalam header paket. Metode sederhana ini ternyata sangat powerful.


Dalam script di atas ada juga hal baru yang ditemui yaitu police dan burst. Police merupakan filter yang membatasi rate bandwidth sampai kecepatan tertentu. Burst atau buffer adalah ukuran dari bucket (HTB = hierarchical tocken bucket, atau kadang-kadang disebut juga TBF = tocken bucket filter) dalam byte (1 byte = 8 bit), sebagai patokan untuk kecepatan 10mbit/s dibutuhkan setidaknya ukuran buffer 10 kbyte.

Maksud dari baris
tc filter add dev eth1 parent ffff: protocol ip prio 50 u32 match ip src \
0.0.0.0/0 police rate ${DOWNLINK}kbit burst 10k drop flowid :1

adalah membuat class ingress dari class ffff: untuk protokol ip dengan prioritas 50 dengan source ip dari internet dengan membatasi  kecepatan paket sebesar kecepatan DOWNLINK kbit/s dengan buffer sebesar 10 kbytes, paket yang kecepatannya lebih dari DOWNLINK akan di drop.

Beberapa Contoh Lain

Kombinasi iptables, ip, tc dapat digunakan untuk beberapa hal lain yang sangat menarik, di bawah ini beberapa contohnya.
Anda mempunyai beberapa koneksi internet ke beberapa ISP. Anda menginginkan agar trafik smtp melalui jalur salah satu ISP saja. Anda dapat mengkombinasi iptables dengan ip. Buat perintah untuk script iptables seperti dibawah ini

# iptables -A PREROUTING -i eth0 -t mangle -p tcp –dport 25 \
-j MARK –set-mark 1
# echo 201 mail.out >> /etc/iproute2/rt_tables
# ip rule add fwmark 1 table mail.out
# ip rule ls
0: from all lookup local
32764: from all fwmark          1 lookup mail.out
32766: from all lookup main
32767: from all lookup default

Lalu kita jalankan perintah:
#/sbin/ip route add default via 202.172.43.171 dev eth0 table mail.out
Maka semua email trafik akan melalui eth0 di mesin router kita menuju ISP tertentu.
Contoh lain adalah untuk selector u32 classifier, misalnya kita ingin agar trafik ICMP masuk ke qdisc tertentu kita dapat membuat misalnya:
# tc filter add dev eth0 parent 10:0 protocol ip prio 100 u32 match ip protocol 1 0xFF flowid 10:100

Mudah-mudahan penjelasan singkat ini bisa dipahami, dan jangan takut untuk mencoba-coba sendiri. Apa yang saya coba share di sini memang masih kurang lengkap tapi setidaknya bisa menjadi awal bagi anda yang tertarik network dan quality of service di linux.

Have a lot of fun.

Comments

Popular posts from this blog

Prejudice and Privilege

Notes : It is not about Linux or other geeky stuff nor it is a political writing.  It was a day in the end of March 2007. I was just landed at the Franz Josef Strauss Munich Airport  around 10 AM in the morning. I had 5 days free time from my work in Astrium. At that time I was contracted by EADS Astrium  (now become Airbus Defense and Space) to work with them in Toulouse . I worked for one of their project. I flew from Toulouse where I worked to visit my brother family in Munich. Just after I picked up my luggage from the conveyor, three guys without uniform approaching me and asked me in English what i'm doing in Munich. I asked them if I did anything wrong. One of them told me that it was a random checked.     "Who are you guys? Sorry sir if it is a random check, why do you choose me instead of other?" I reply to their answer.  One of them said they're from the Munich immigration, and at the same time showing a gun behind his jacket. For my itinerary Munich was not

Asterisk 1.6.1 on openSUSE 11.1 (Part 2)

In this second part I will explain step-by-step configuration to use our appliance to build an Asterisk PABX server. Without further ado, here is the list: Install the Digium card on the PCI slot Install our appliance. You can also use any linux distribution, download asterisk from its website and install it. There are several softwares I forget when I made the appliance, it is not the mandatory (dependencies) but they are useful when we want to use asterisk optimally. They are: mpg123, sox, libmad, and festival. The easiest way to install it in openSUSE is using zypper. Check it first where they reside in repositories and add the repositories accordingly. mpg123 and sox are in the packman repositoriy, libmad in OBS (please check with webpin) and festival in oss. Then as root run: "zypper install mpg123 sox libmad0 festival". It is always useful to update your installation to update repository, to make sure that all the security update is up to date. Download the

In Search of Manohara

Notes: I always write note in my laptop and put it somewhere either on disk or cloud when I think there is an interesting experience. I found this 7 years old note when I try to clear some space in my disk, and before I wipe it out from my disk I think it is an interesting story to share with you. This happened in 2011, at that time I was working to build Linux based computer labs for 500 elementary and junior high schools in Yogyakarta Indonesia. No it is not about computer and other geeky stuff. So here it is.  Well, it is very out of topic everyone, you've already been warned 😁 During my busy weeks in implementing openSUSE Li-f-e for schools in Yogyakarta Indonesia (see the pictures below), me and one of my colleague use our free time in a Sunday afternoon to visit Borobudur , the biggest Buddhist temple in the world. One of the World Heritage preserve by Unesco. 85% of Indonesia population are Moslem and this make Indonesia the biggest Moslem country in the world. We