การทำ Traffic Control บนลินุกซ์
มีความรู้งูๆ ปลา ๆ แต่คิดว่าน่าจะเป็นประโยชน์กับคนอื่น เลยเอามาเผยแพร่ ถ้าผิดพลาดไม่ว่าจะเรื่องถภาษาหรือข้อมูลก็ต้องขออภัยด้วยครับ
ผู้ดูแลระบบคอมพิวเตอร์หลายๆท่าน คงจะประสพปัญหาเกี่ยวกับการจัดสรรแบนวิทให้เพียงพอต่อความต้องการของผู้ใช้อยู่เสมอ ๆ การทำ Traffic Control(TC) ก็เป็นวิธีการหนึ่งที่จะบริหารแบนวิทที่มีอยู่ให้เกิดประโยชน์สูงสุด
สมมติว่ามี lease line ความเร็ว 512 kbps มีการใช้ videoconference , IP Phone และ บริการ www/ftp ในบางครั้งบริการ www/ftp กินแบนวิทไปจน videoconference , IP Phone ใช้การไม่ได้หรือกระตุก จำเป็นต้องใช้ Traffic Control เข้ามาช่วย


เตรียมการ
- ทำ linux gateway 1 เครื่อง (จะไม่กล่าวถึงรายละเอียดนะครับ)
รายละเอียดเกี่ยวกับระบบที่ต้องการ
(ไม่แปลนะครับ)
|
The support for quality of service
is available from linux kernel versions 2.1.90. However, the support is
more comprehensive in the more recent ker- nels. This document is written with reference to the kernel version 2.2.1.
This kernel also has support for di_erentiated services in the form of a patch, that can be downloaded from
ftp://lrcftp.ep.ch/pub/linux/di_serv/patches/ds- 3.patch.gz. This patch needs to be applied
in order to exercise all the QoS 2 features supported in linux.
The latest linux kernels can be downloaded from http://www.kernelnotes.org/. 1. Apply the di_-serv
patch to the linux-2.2.1 source tree. 2. Do a 'make xcon_g'
or 'make menucon_g' or 'make make con_g' in the /usr/src/linux
directory. 3. Set the EXPERIMENTAL OPTIONS to
'y'. 4. Under networking options, say
'y' to the following kernel options: Ker- nel/User netlink
socket, Routing messages,TCP/IP networking and QoS and/or fair queueing.
After turning on the QoS and/or fair queu- ing option, enable the CBQ, CSZ,
PRIO, RED, SFQ, TEQL, TBF, GRED, DS MARK, 'tcindex' classi_er, Packer Classi_er API, U32 clas- si_ers and routing table based classi_er. 5. Do a 'make dep;
make clean; make bzilo' 6. Reboot the linux
box using the new kernel image. Having discussed the con_guration of the QoS support
in linux, let us now discuss the details involved in
the implementation of these features. The location of all the kernel related
_les referred to in the rest of this document are speci_ed
with respect to the /usr/src/linux directory. |
- ดาวน์โหลด cbqinit จาก http://sourceforge.net/projects/cbqinit จะได้ไฟล์ cbq.init-vx.y.z มา เป็น script ที่จะทำให้เราทำ traffic control ได้ง่ายขึ้น ( x.y.z เป็น เลขเวอร์ชั่น)
- Copy script ไปเป็น /usr/sbin/cbq.init แล้ว chmod ให้ execute ได้
เริ่มทำ TC
สคริป cbqinit
จะรับค่าข้อกำหนดเกี่ยวกับแบนวิทจากไฟล์(แต่ละไฟล์คือ
1 คลาส) ซึ่งจะต้องใส่ไว้ใน /etc/sysconfig/cbq/cbq-xxxx.something
xxxx = 0002 FFFF ในที่นี้จะตั้งชื่อว่า
-cbq-002.webftp
สำหรับกำหนดแบนวิทให้ www/ftp (port 80 /21)
-cbq-003.vdocon
สำหรับกำหนดแบนวิทให้
videoconference (port 1300)
การ config เบื้องต้น
DEVICE=<ifname>,<bandwidth>[,<weight>]
Ifname= interface name เช่น eth0
Bandwidth = แบนวิทของ interface นั้น สำหรับ fastethernet = 100 Mbit
Weight = bandwidth /
10
RATE=<speed>
Speed = ความเร็วที่ต้องการ สำหรับ class นี้
WEIGHT=<speed>
Speed = ความเร็วว่าจะให้ปรับขึ้นลงทีละเท่าไร่ส่วนมากใช้ rate
/ 10
PRIO=<1-8>
ค่า priority ของคลาส ตั้งเป็น 5
จะเหมาะสม
RULE= ระบุ client ที่ class จะส่งผลถึง
|
#cbq-002.webftp DEVICE=eth0,1Mbit,100Kbit RATE=256Kbit WEIGHT=20Kbit PRIO=4 RULE=,192.168.1.0/24:80 RULE=,192.168.1.0/24:21 |
|
#cbq-002.vdo DEVICE=eth0,1Mbit,100Kbit RATE=256Kbit WEIGHT=20Kbit PRIO=4 RULE=,192.168.1.0/24:1300 |
จากนั้น สั่ง
#cbq.init start
แล้วลองใช้ client
download file ผ่าน http
จากเครื่อง linux gateway
speed ที่ได้ควรไม่เกิน 256 kbps
ถ้าสำเร็จก็ให้ กำหนดscript นี้ให้เริ่มต้นตั้งแต่ boot เครื่องได้เลย
โดย
ธันว์ สุวรรณเดชา
(stan2kth@yahoo.com)
Pharmaceutical
Sciences Student PSU