(ÇöÀç ±â´É¿¡ ÇÑÇÔ)³×Æ®¿öÅ© Æ®·¡ÇÈ ¼ÎÀÌÇÎÀÇ »ç¿ë ¸ñÀûÀº ³×Æ®¿öÅ© ȯ°æÀÌ ÁÁÁö ¾ÊÀº °÷¿¡¼³ª °ü¸®ÀÚÀÇ Á¤Ã¥¿¡ µû¶ó dvrÀÇ ³×Æ®¿öÅ© ¾÷·Îµå ´ë¿ªÆøÀ» Á¶ÀýÇϹǷΠ°úµµÇÑ ³×Æ®¿öÅ© Á¡À¯¸¦ ÇÇÇϵµ·Ï ±¸ÇöÇϴµ¥ ÀÖ´Ù.
Æ®·¡ÇÈ ¼ÎÀÌÇÎÀ̶õ?
Æ®·¡ÇÈ ¼ÎÀÌÇÎ(Traffic Shaping)Àº ¼º´ÉÀ̳ª ºü¸¥ ÀÀ´ä½Ã°£ µîÀ» º¸ÀåÇÏ°í ÃÖÀûÈÇϱâ À§ÇØ ³×Æ®¿öÅ© ¼ÒÅë·®(traffic)À» Á¦¾îÇÏ´Â °ÍÀ» ¸»ÇÑ´Ù. P2P ÇÁ·Î±×·¥À» »ç¿ëÇغ» »ç¶÷Àº °æÇèÇØ º¸¾ÒµíÀÌ, º¸Åë downloadÀÇ Àü¼Û·üÀº Á¦ÇÑÀ» µÎÁö ¾Ê°í, uploadÀÇ Àü¼Û·üÀ» Á¦ÇÑÇÏ°í´Â Çϴµ¥, ½±°Ô ¸»Çϸé ÀÌ·± °ÍÀ» Æ®·¡ÇÈ ¼ÎÀÌÇÎÀ̶ó°í ÇÑ´Ù.
Æ®·¡ÇÈ ¼ÎÀÌÇÎÀ» ÀÌ¿ëÇÏ¸é ´Ü¼øÈ÷ ´ë¿©ÆøÀ» Á¦¾îÇÏ´Â °Í »Ó ¾Æ´Ï¶ó, Àü¼Û·ü(rate)À» Á¶ÀýÇÏ¿© ÆÐŶ ²÷±è(jitter), ÆÐŶ ¼Õ½Ç(loss), ¹ÝÀÀ½Ã°£(low latency) µîÀ» ÃÖÀûÈÇÒ ¼ö ÀÖ´Ù. ¿¹¸¦ µé¾î Æ®·¡ÇÈ ¼ÎÀÌÇÎÀ» Çϱâ Àü°ú ÈÄÀÇ ÆÐŶ Àü¼Û µ¿ÀÛÀ» ÃÊ´ÜÀ§·Î Ç¥ÇöÇÏ¸é ´ÙÀ½°ú °°´Ù.
Æ®·¡ÇÈ ¼ÎÀÌÇÎ ÀÌÀü
10 0 10 0 10 0 10 0 10 0
Æ®·¡ÇÈ ¼ÎÀÌÇÎ ÀÌÈÄ
5 5 5 5 5 5 5 5 5 5
³×Æ®¿öÅ© ¿¬°áº°·Î ¿ì¼± ¼øÀ§°¡ ÇÊ¿äÇÑ °æ¿ìµµ Á¤Ã¥(policy)À» ÅëÇØ Á¶ÀýÇÒ ¼ö ÀÖ´Ù. ¿¹¸¦ µé¾î FTP µ¥ÀÌÅÍ Àü¼Û°ú SSH Á¢¼ÓÀ» µ¿½Ã¿¡ ÁøÇàÇÒ °æ¿ì ´ë·®ÀÇ FTP µ¥ÀÌÅÍ Àü¼ÛÀ¸·Î SSH Å͹̳Π¿¬°áÀÌ Áö¿¬µÇ´Â Çö»óÀÌ ¹ß»ýÇϴµ¥, ÀÌ·± °æ¿ì ¼ÎÀÌÇÎ ±â´ÉÀ» ÀÌ¿ëÇϸé SSH ¿¬°áÀÇ ¿ì¼±¼øÀ§¸¦ ³ô¿© ¼ÒÅëÀ» ¿øÈ°ÇÏ°Ô ÇÒ ¼ö ÀÖ´Ù.
Æ®·¡ÇÈ ¼ÎÀÌÇο¡ »ç¿ëµÇ´Â °³³ä ¹× ¹æ¹ý
Classification, Queueing, Scheduling
HTB (Hierarchical Token Bucket)
HTB´Â ´ë¿ªÆøÀ» °¢°¢ÀÇ queue¿¡ ³ª´©¾îÁÖ´Â ½Ã½ºÅÛÀÌ´Ù. ´ë¿ªÆøÀº º¸ÀåÇÏÁö¸¸ interactive´Â º¸ÀåÇÏÁö ¾Ê´Â´Ù. ¿Ö³ÄÇϸé ÆÐŶ °¹¼ö¸¦ ¼¼Áö¾Ê°í, ¹ÙÀÌÆ® ¼ö¸¦ ¼¼±â¶§¹®ÀÌ´Ù.
qdisc¶ó´Â °ÍÀÌ »ç¿ëµÇ´Âµ¥ °¢ ¿ì¼±¼øÀ§ ¸¶´Ù ºÎ¿©µÇ´Â queue¸¦ ¸»ÇÑ´Ù.
root qdisc´Â ÇϳªÀÇ Å¬·¡½º¸¦ °¡Áú ¼ö ÀÖ´Ù. ¹°·Ð ¿©·¯°³ÀÇ Å¬·¡½º¸¦ °¡Áú ¼öµµ ÀÖ´Ù. ÀÌ ÇϳªÀÇ HTB Ŭ·¡½º´Â rate¿Í ceil µÎ°³ÀÇ Àμö·Î ¼³Á¤ÀÌ µÈ´Ù. ÀÌ °ªµéÀº ÃÖ»óÀ§ Å©·¡½º¸¦ À§ÇÑ °ÍÀ̶ó°í ÇÒ ¼ö ÀÖÀ¸¸ç ¸µÅ©¿¡ ´ëÇÑ ÃÖ´ë °¡´ÉÇÑ ´ë¿ªÆøÀ» ³ªÅ¸³½´Ù.
HTB¿¡¼ rate´Â Ŭ·¡½º¸¦ À§ÇÑ ´ë¿ªÆøÀ» º¸ÀåÇÏ´Â °ªÀ̸ç ceilÀº ceilingÀÇ ÁÙÀÓ¸»·Î Ŭ·¡½º°¡ ÃÖ´ë·Î »ç¿ëÇÒ ¼ö ÀÖ´Â ´ë¿ªÆøÀ» ÀǹÌÇÑ´Ù. µû¶ó¼ ÃÖ»óÀ§ ·¹º§¿¡¼´Â ÀÌ µÎ°¡Áö´Â °°Àº ÀǹÌÀÌ´Ù.
ÀÚ½Ä Å¬·¡½ºÀÇ ¼ö´Â ÀÌ Å¬·¡½º ¹ØÀ¸·Î »ý¼ºÇÒ ¼ö Àִµ¥, ÀÌ Å¬·¡½ºµéÀº ºÎ¸ð Ŭ·¡½º·Î ºÎÅÍ °¡´ÉÇÑ ´ë¿ªÆøÀ» ÇÒ´ç¹Þ´Â´Ù. ÀÚ½Ä Å¬·¡½º¿¡¼ ºÎÅÍ´Â rate¿Í ceilÀº ´õÀÌ»ó °°Àº °ªÀº ¾Æ´Ï¸ç ƯÁ¤ÇÑ ´ë¿ªÆøÀ» ¿¹¾àÇÏ°í °¡´ÉÇÑ ´ë¿ªÆøÀÇ ºÐ¹èÀ²À» °è»êÇؼ Ŭ·¡½ºµé¿¡ Çã¿ëÇÑ´Ù.
HTB(Hierarchical Token Bucket)´Â »ç¿ëÀÚ·Î ÇÏ¿©±Ý Àý´ëÀûÀÎ ´ë¿ªÆøÀ» Á¶ÀýÇÏ°í ¿©ºÐÀÇ ´ë¿ªÆø¿¡ ´ëÇØ Á¤ÇØÁø ºñÀ²·Î °è»êÇÏ¿© ¿ì¼±¼øÀ§¿¡ µû¶ó °¢ Ŭ·¡½º¿¡ ÇÒ´çÇÑ´Ù.
CBQ (Class based Queueing)
³×Æ®¿öÅ© Æ®·¡ÇÈÀ» ¼ºñ½º ŸÀÔ(FTP, SMTP or HTTP)À̳ª ¸ñÀûÁö¿¡ µû¶ó Ŭ·¡½ºµé·Î ³ª´«´Ù. °¢°¢ÀÇ Å¬·¡½ºµéÀº FIFO ±â¹ÝÀÇ Å¥¿¡ ÇÒ´çµÇ¸ç °¢°¢ÀÇ Å¥µé¿¡°Ô´Â Ŭ·¡½º¿¡ Á¤ÀÇµÈ Æ¯Á¤ÇÑ ´ë¿ªÆøÀÌ ÇÒ´çµÈ´Ù. CBQ¿Í HTBÀÇ °¡Àå Å« Â÷ÀÌ´Â ceiling ±â´ÉÀÇ À¯¹«ÀÌ´Ù. CBQ´Â ´ë¿ªÆøÀÌ ¿©À¯°¡ »ý±â´õ¶óµµ ÇØ´ç Ŭ·¡½º¿¡ Á¤ÇسõÀº ´ë¿ªÆø ÀÌ»óÀº Àý´ë »ç¿ëÇÒ ¼ö ¾ø´Ù.
SFQ (Stochastic Fairness Queueing)
ÁöÁ¤ÇÑ Å¥·Î µé¾î¿À´Â ¸ðµç Æ®·¡ÇÈ¿¡ ´ëÇÏ¿© Å« queue¸¦ »ç¿ëÇÏ¿© °øÆòÇÏ°Ô ´Ù·é´Ù. Æ®·¡ÇÈÀÌ fullÀÏ °æ¿ì¿¡ Àû¿ëµÈ´Ù.
³×Æ®¿öÅ© ¼ÎÀÌÇÎ ¹æ¹ý
¼ÎÀÌÇÎÀ» Çϱâ À§ÇÑ ¸î°¡Áö ¹æ¹ýÀ» ¼Ò°³ÇÏ¸é ´ÙÀ½°ú °°´Ù.
P2P ÇÁ·Î±×·¥ÀÌ »ç¿ëÇÏ´Â portÀÇ ¿ì¼±¼øÀ§¸¦ ³·Ãâ ¼ö ÀÖÁö¸¸ »ç¿ëÀÚ°¡ ´Ù½Ã P2PÇÁ·Î±×·¥ÀÇ Æ÷Æ®¸¦ ¹Ù²Ù¸é ¼Ò¿ëÀÌ ¾ø´Ù.
ÆÐŶ Å©±â¸¦ ÀÌ¿ëÇÏ¿© Å« ÆÐŶÀÇ ¿ì¼±¼øÀ§¸¦ ³·Ãâ ¼ö ÀÖ´Ù. ÇÏÁö¸¸ »ç¿ëÀÚ°¡ MTU(Àü¼ÛµÉ ¼ö ÀÖ´Â ÃÖ´ëÅ©±âÀÇ ÆÐŶ)¸¦ Á¶Á¤Çϸé ÀÛÀº ÆÐŶÀ» ³»º¸³½´Ù.
³×Æ®¿öÅ© Æ®·¡ÇÈ ¼ÎÀÌÇÎÀÇ ¿¹
¸¸¾à µÎ°³ÀÇ ÀÎÅÍÆäÀ̽º¸¦ °¡Áø ¸®´ª½º ¸Ó½ÅÀÌ ÀÖ´Ù°í ÇÏÀÚ.
DSL-modem - ip: 192.168.2.1
Linux box ip - eth0: 192.168.1.1, eth1: 192.168.0.2.2 and gateway: 192.168.2.1
clients - ip: 192.168.1.16, 192.168.1.17, 192.168.1.18 and gateway: 192.168.1.1
1. ÆÐŶÀÌ Å¬¶óÀ̾ðÆ® 192.168.1.16À» ¶°³´Ù.
2. ÆÐŶÀÌ gateway eth0 (192.168.1.1)¿¡ µµÂøÇÑ´Ù.
3. gateway´Â output queue¸¦ ÅëÇØ ÆÐŶÀ» º¸³½´Ù.
4. ÆÐŶÀÌ gateway eth1 (192.168.2.2)¿¡¼ ¶°³´Ù.
5. ÆÐŶÀÌ DSL-modem (192.168.2.1)¿¡ µµÂøÇÑ´Ù.
6. ÆÐŶÀÌ DSL-modemÀÇ output queue¿¡ µé¾î°£´Ù.
7. ÆÐŶÀÌ DSL-modemÀ» ¶°³´Ù.
DSL-modemÀÇ °æ¿ì upload ¼Óµµ´Â 128kbitÀÌ´Ù. ÀÌ°ÍÀº ¸®´ª½º ¹Ú½º°¡ DSL-modemÀ» ÅëÇؼ´Â µ¥ÀÌŸ¸¦ º¸³¾ ¼ö ¾ø´Ù´Â ¸»ÀÌ´Ù. DSL-modemº¸´Ù ºü¸¥ °ÍÀº upload ÇÒ ¼ö ÀÖ´Ù. ±×·¸´Ù°í DSL-modemÀÇ µ¿ÀÛÀ» Á÷Á¢ ÄÁÆ®·Ñ ÇÒ ¹æ¹ýÀÌ ¾ø±â¶§¹®¿¡, DSL-modemÀÇ output queue¸¦ ¸®´ª½º ¹Ú½º·Î ¿Å°Ü¿Í¾ß ÇÑ´Ù. ÀÌ°ÍÀÌ Æ®·¡ÇÈ ¼ÎÀÌÇÎÀ» Àû¿ëÇÏ´Â °ÍÀÌ´Ù. ÀÌ°ÍÀº DSL-modemÀ¸·Î ³»º¸³»´Â eth1ÀÇ Ãâ·Â ¼Óµµ¸¦ DSL-modemÀÇ upload ¼Óµµº¸´Ù ³·ÃãÀ¸·Î °¡´ÉÇÏ´Ù. Áï queue°¡ ¿Å°ÜÁö´Â °ÍÀÌ´Ù.
±¸Çö
tc ¶ó´Â ÇÁ·Î±×·¥À» »ç¿ëÇÏ¿© °£´ÜÇÏ°Ô ³×Æ®¿öÅ© Æ®·¡ÇÈ ¼ÎÀÌÇÎÀ» ½ÃµµÇÑ´Ù.
- ¿ì¼±¼øÀ§ µîÀÇ °í·Á¸¦ Á¦¿ÜÇÏ°í Àüü ´ë¿ªÆø¸¸ ´Ù·çµµ·Ï ÇÑ´Ù. Ŭ·¡½º¸¦ Çϳª¸¸ »ý¼ºÇÔ.
- eth0, eth1 µî ³×Æ®¿öÅ© ÀÎÅÍÆäÀ̽º º°·Î ÃÖ´ë Àü¼Û·üÀ» ¼³Á¤ÇÒ ¼ö ÀÖ´Â UI¸¦ ±¸ÇöÇÑ´Ù.
- Ãß°¡µÉ Ä¿³Î ¿É¼ÇÀº ¹«¾ùÀΰ¡?
- ´ÙÀ½°ú °°Àº Ä¿³Î ¿É¼ÇÀ» Àû¿ëÇÏ¿© Å×½ºÆ® ÁßÀÌ´Ù.
Networking --> Networking options
[*] Network packet filtering
QoS and/or fair queueing -->
<M> HTB packet scheduler
<M> SFQ queue
[*] Packet classifier API
<M> Firewall based classifier
<M> U32 Classifier
[*] Traffic policing
Å×½ºÆ® ÇÒ ½ºÅ©¸³Æ®´Â ´ÙÀ½°ú °°´Ù. wondershaper¶ó´Â ½ºÅ©¸³Æ®¸¦ ÀÀ¿ëÇÏ¿´´Ù.
#!/bin/sh
if [ $# == 0 ]; then
echo Please read the man page for the wondershaper and
echo the file /usr/share/doc/wondershaper/README.Debian
exit
fi
if [ $# == 1 ]; then
tc -s qdisc ls dev $1
tc -s class ls dev $1
exit
fi
if [ "$2" == "del" ]; then
tc qdisc del dev $1 root 2> /dev/null > /dev/null
echo Wondershaper queues have been cleared.
exit
fi
# please read the README before filling out these values
#
# Set the following values to somewhat less than your actual download
# and uplink speed. In kilobits. Also set the device that is to be shaped.
UPLINK=$2
DEV=$1
#########################################################
# clean existing down- and uplink qdiscs, hide errors
tc qdisc del dev $DEV root 2> /dev/null > /dev/null
###### uplink
# install root HTB
tc qdisc add dev $DEV root handle 1:0 htb default 15
# main class
tc class add dev $DEV parent 1:0 classid 1:1 htb rate ${UPLINK}kbit
# high prio class 1:5
tc class add dev $DEV parent 1:1 classid 1:5 htb rate $(($UPLINK/2))kbit \
ceil ${UPLINK}kbit prio 2
# bulk and default class 1:10 - gets slightly less traffic,
# and a lower priority:
tc class add dev $DEV parent 1:1 classid 1:10 htb rate $(($UPLINK/2))kbit \
ceil ${UPLINK}kbit prio 6
# 'traffic we hate'
tc class add dev $DEV parent 1:1 classid 1:15 htb rate $(($UPLINK/2))kbit \
ceil ${UPLINK}kbit prio 10
# all get Stochastic Fairness:
tc qdisc add dev $DEV parent 1:5 handle 5: sfq perturb 10
tc qdisc add dev $DEV parent 1:10 handle 10: sfq perturb 10
tc qdisc add dev $DEV parent 1:15 handle 15: sfq perturb 10
HTB¸¦ »ç¿ëÇÒ °ÍÀÎÁö CBQ¸¦ »ç¿ëÇÒ °ÍÀÎÁö, fairÁ¤Ã¥À» »ç¿ëÇÒ °ÍÀΰ¡?
CBQ´Â HTBº¸´Ù ¼³Á¤ÀÌ º¹ÀâÇÏ´Ù. ±»ÀÌ CBQ¸¦ »ç¿ëÇÒ ÀÌÀ¯´Â ¾ø´Ù. fair Á¤Ã¥Àº Ŭ·¡½º°¡ ¿©·¯°³À϶§ ÇÊ¿äÇÏ´Ù. Ŭ·¡½º¸¦ ÇÑ°³¸¸ »ç¿ëÇÒ °ÍÀ̹ǷΠ¹«ÀǹÌÇÒ °Í À¸·Î º¸ÀδÙ.
Å×½ºÆ®
ÃÖÁ¾ÀûÀ¸·Î »ç¿ëÇÑ ¸í·É¾î´Â ´ÙÀ½°ú °°´Ù. ÃÖ»óÀ§ Ŭ·¡½º ¸¸ »ý¼ºÇÏ¿© ´ë¿ªÆøÀ» Á¦ÇÑÇغ¸¾Ò´Ù. (DEV - eth0, eth1...)
tc qdisc add dev $DEV root handle 1:0 htb default 1
tc class add dev $DEV parent 1:0 classid 1:1 htb rate ${UPLINK}kbit
ù¹ø° ¸í·É¾î¿¡¼ 1:0Àº Ä¿³Î ·¹º§ÀÇ qdisc¸¦ ÀǹÌÇÑ´Ù. ±× qdisc¿¡ root Ŭ·¡½º¸¦ Çϳª »ý¼ºÇÏ¿© UPLINK¶ó´Â Àμö¸¦ ¹Þ¾Æ ´ë¿ªÆø Á¦ÇÑ ¸í·ÉÀ» ÇÑ´Ù.
./test_script eth0 512
Ä¿³ÎÀº À§¿¡¼ Á¦½ÃÇÑ ¿É¼ÇÀ» Àû¿ëÇÏ¿´À¸¸ç À§ ¸í·ÉÀ» ½ÇÇà½Ã sch_htb ¶ó´Â ¸ðµâÀÌ ¿Ã¶ó°£´Ù.
[root@sentry24 root]# lsmod | grep htb
sch_htb 15360 1
´ë¿ªÆøÀ» 512kbps ÀÌÇÏ·Î Àû¿ëÇÑ °á°úÀÌ´Ù.
[root@sentry24 root]# ./test_script eth0
qdisc htb 1: r2q 10 default 1 direct_packets_stat 0
Sent 15319 bytes 123 pkt (dropped 0, overlimits 0 requeues 0)
backlog 0b 0p requeues 0
class htb 1:1 root prio 0 rate 512000bit ceil 512000bit burst 2239b cburst 2239b
Sent 15789 bytes 126 pkt (dropped 0, overlimits 0 requeues 0)
rate 2880bit 3pps backlog 0b 0p requeues 0
lended: 126 borrowed: 0 giants: 0
tokens: 33794 ctokens: 33794
Æ®·¡ÇÈ ¼ÎÀÌÇÎÀ» ÇØÁ¦ÇÏ·Á°í ÇÒ ¶§´Â ´ÙÀ½°ú °°ÀÌ ¸í·ÉÇÑ´Ù.
> tc qdisc del dev eth0 root