- http://sourceforge.net/projects/cbqinit/
- http://archive.linux.or.jp/JF/JFdocs/traffic-control.txt
- http://www.aconus.com/~oyaji/tips/cbq_init.htm
- http://www.miraclelinux.com/support/?q=node/354
cbq(Class Based Queueing) linuxã®iproute 㨠tc (traffic control) ã§åºæ¥ãããããtcã®ã³ãã³ãããããã¨è¤éãªã®ã§ãcbq.init ã¨ããherlper script ã使ãã¨ç°¡åã§è¯ãã®ã§ç´ æ´ããã便å©ã
cbq.init
redhat/centos ãªã iproute package ã«cbqã³ãã³ããå ¥ã£ã¦ããã®ã§
# yum install iproute
ã¨ããããããã㯠http://sourceforge.net/projects/cbqinit/ ããã¨ã£ã¦ã㦠é©å½ãªå ´æã«ç½®ãã
debian ã¯shaper packageã«å
¥ã£ã¦ããã¨ãã話ãèãããã© debian 6.0 squeeze ã«ã¯shaper packageããªãã£ãã®ã§ãâã®sourceforge ããåã£ã¦ãã¦å°ãä¿®æ£ããã(è¨å®ãã¡ã¤ã«ãä¿åãããã£ã¬ã¯ããªã redhat系㮠/etc/sysconfig/cbq ã«ãªã£ã¦ããã®ã§/etc/default/cbq ã/etc/cbq çã«ä¿®æ£)
HOW DOES IT WORK?
HOW DOES IT WORK?
Every traffic class must be described by a file in the $CBQ_PATH directory
(/etc/sysconfig/cbq by default) - one file per class.The config file names must obey mandatory format: cbq-
. where
is two-byte hexadecimal number in range <0002-FFFF> (which in fact
is a CBQ class ID) andis the name of the class -- anything to help
you distinguish the configuration files. For small amount of classes it is
often possible (and convenient) to letresemble bandwidth of the
class.Example of valid config name:
cbq-1280.My_first_shaper
è¨å®ãã¡ã¤ã«
cbq.init ã§è¨å®ãããã£ã¬ã¯ããªã«ç½®ããredhatãªã /etc/sysconfig/cbq 以ä¸ã«ããã¡ã¤ã«å "cbq-[id].[name]"ã¨ããruleãããã®ã§æ³¨æã
- id
- ä»ã®ãã¡ã¤ã«ã¨éè¤ããªãid (16é²æ°ã§0002 ~ FFFF)
- name
- ä½ã§ãããã®ã§è¨å®ããããªã·ã¼ãããããããªãã®ã«ãã
æ¸å¼
cbq.init ã®ã³ã¡ã³ãã«èª¬æãæ¸ãã¦ããã¨ããããå¿ é ãªãã®
DEVICE=<ifname>,<bandwidth>,[weight] RATE=<speed> WEIGHT=<speed> RULE=[[saddr[/prefix]][:port[/mask]],][daddr[/prefix]][:port[/mask]]
DEVICE
- ifname: interfaceå (ex: eth0)
- bandwidth: interfaceã®ç©ççãªå¸¯åå¹ (ex: 1000Mbit)
- weight: "As a rule of thumb:
= / 10" ãªã®ã§bandwidthã®1/10ã«ãã¨ã (ex: 100Mbit)
RATE
ãã®å¤ã«æ¸ãããé度ã§å¸¯åå¶éããããã (ex: 10Mbit)
WEIGHT
"As a rule of thumb, use WEIGHT ~= RATE / 10." (ex: 1Mbit)
RULE
å¶éãããã"éä¿¡å IP:ãã¼ã,å®å IP:ãã¼ã"ã®æ¡ä»¶ãæ¸ãã
- ex1) ftp,http ãµã¼ããåããã¦ãã¦ããã¦ã³ãã¼ãããã帯åãå¶éãããã¨ã
éä¿¡å ã¯èªåã§ãå®å ã¯ä»»æãªã®ã§
# ftp server RULE=:21,
# http RULE=:80,
ãªã©ã«ãéä¿¡å
IP/portãæå®ããã®ã§æå¾ã®ã³ã³ããå¿ããã«ã
- ex2) ä»ã®ãµã¼ãã¸ã®å¸¯åãå¶éãããã
ä¾ãã°DB使ã£ã¦ãwebã¢ããªã«å¤§éã«ã¢ã¯ã»ã¹ãæ¥ãå ´åã®å¯¾çã§ãDBãµã¼ãã¸ã®trafficãæãããã¨ãã¨ãã (webãµã¼ãããdbãµã¼ãã¸ã®traffic = SQLã®ãªã¯ã¨ã¹ãçã§å¤§ãããã±ãããæµããªãããä¾ã«ããã®ã¯ééãã ã£ãããã)
RULE=ip.address.to.server:8080
éä¿¡å
ã¯æå®ããã«ãå®å
ã®IP,ãã¼ãã ãæ¸ãã°è¯ãã
- ex3) å ¨ã¦ã®outboundãå¶éãã
RULEã空(ã³ã³ãã ã)ã ã£ãããã¡ã ã£ãã®ã§ã
portãæå®ãããèªåã®IPãã³ã³ãã®å·¦å´ã«æ¸ãã¦ããã°ãã
networkã§ãå¥ã«åé¡ãªãã®ã§è¨å®ãã³ãããããªã/24ã¨ãã®ã»ãã便å©ãã
RULE=192.168.0.0/24,
è¨å®åæ
# /etc/init.d/cbq.init start
è¨å®å¤ããå¤§å¹ ã«ã¹ã«ã¼ããããè½ã¡ãå ´å
NICã«ãã£ã¦ã¯tso(TCP Segumentation Offload)*1ãæå¹ãªå ´åã«ãcbqã§å¸¯åå¶éãæããã¨è¨å®å¤ããå¤§å¹ ã«ã¹ã«ã¼ããããè½ã¡ãããã ã(家ã®ãã½ã³ã³ã§ããªã£ãï¼ï¼)
1Gbitã®NICã§RATEã10Mbitã«è¨å®ããã®ã«ãå®éã®é度ã¯150kbpsããåºãªãã¨ãã
tso ã®ç¢ºèª/è¨å®å¤æ´
## ç¢ºèª # ethtool -k eth0 | grep tcp tcp segmentation offload: on # tso ãæå¹ ## ç¡å¹ã«ãã # ethtool -K eth0 tso off
tso ãç¡å¹ã«ããã®ã ããããããã¯ã¼ã¯ã®ç¶æ³ã«ãã£ã¦ã¯å ¨ä½çãªã¹ã«ã¼ããããè½ã¡ãããCPUè² è·ãä¸ãããããããªãã®ã§è¨å®ããå ´åã¯æ³¨æããã»ããè¯ããã?
*1:TCP/IPã®å¦çãCPUã§è¡ããã«ãNICã§è¡ãã¹ã«ã¼ããããä¸ããæ©è½ãæè¿ã®NICã«ã¯ã ãããã¤ãã¦ãï¼