DynagenでCCIEを目指す
Shaping Using MQC
最終更新:
it_certification
-
view
1. 目的
- shapingの設定について確認します。
2. 構成
2.1. 設定概要
- Host OS側でApacheを起動させます。
- Guest OS, R1間は10Mで接続する事で、わざと輻輳を発生させます。
- R1, R2はEIGRPでルーティングします。
2.2. 構成図

2.3. netファイル
model = 3620 [localhost] [[3620]] image = C:\Program Files\Dynamips\images\c3620-j1s3-mz.123-18.bin ram = 128 [[ROUTER R1]] f0/0 = NIO_gen_eth:\Device\NPF_{8B89D910-5ED3-4A43-9DE9-6A272A3D7592} e1/0 = R2 e1/0 [[ROUTER R2]] f0/0 = NIO_gen_eth:\Device\NPF_{5933302A-7AAA-475C-A8FE-A6B82B0C0F98}
2.4. 初期設定
- R1
! version 12.3 service timestamps debug datetime msec service timestamps log datetime msec no service password-encryption ! hostname R1 ! boot-start-marker boot-end-marker ! ! no aaa new-model ip subnet-zero ! ! ! ip cef ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! interface FastEthernet0/0 ip address 192.168.200.1 255.255.255.0 duplex auto speed auto ! interface Ethernet1/0 ip address 192.168.1.1 255.255.255.0 half-duplex ! interface Ethernet1/1 no ip address shutdown half-duplex ! interface Ethernet1/2 no ip address shutdown half-duplex ! interface Ethernet1/3 no ip address shutdown half-duplex ! router eigrp 1 passive-interface default no passive-interface Ethernet1/0 network 192.168.1.1 0.0.0.0 network 192.168.200.1 0.0.0.0 auto-summary ! ip http server ip classless ! ! ! ! ! ! ! ! line con 0 line aux 0 line vty 0 4 ! ! end
- R2
! version 12.3 service timestamps debug datetime msec service timestamps log datetime msec no service password-encryption ! hostname R2 ! boot-start-marker boot-end-marker ! ! no aaa new-model ip subnet-zero ! ! ! ip cef ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! interface FastEthernet0/0 ip address 192.168.201.2 255.255.255.0 duplex auto speed auto ! interface Ethernet1/0 ip address 192.168.1.2 255.255.255.0 half-duplex ! interface Ethernet1/1 no ip address shutdown half-duplex ! interface Ethernet1/2 no ip address shutdown half-duplex ! interface Ethernet1/3 no ip address shutdown half-duplex ! router eigrp 1 passive-interface default no passive-interface Ethernet1/0 network 192.168.1.2 0.0.0.0 network 192.168.201.2 0.0.0.0 auto-summary ! ip http server ip classless ! ! ! ! ! ! ! ! line con 0 line aux 0 line vty 0 4 ! ! end
2.5. Apache 設定
ホストOSにApacheをインストールし、ポートベースのバーチャルホストを定義します。構築方法はトップページ/手順書 サーバ系/Apache HTTP Server バーチャルホストの設定を参考にして下さい。
この検証例で実際に使用したhttpd.confの要所となる部分を以下に記載します。
この検証例で実際に使用したhttpd.confの要所となる部分を以下に記載します。
Listen 80 Listen 10881 Listen 10882 NameVirtualHost *:80 NameVirtualHost *:10881 NameVirtualHost *:10882 <VirtualHost *:80> DocumentRoot "C:/Program Files/Apache Software Foundation/Apache2.2/htdocs" </VirtualHost> <VirtualHost *:10881> DocumentRoot "C:/Program Files/Apache Software Foundation/Apache2.2/htdocs10881" </VirtualHost> <VirtualHost *:10882> DocumentRoot "C:/Program Files/Apache Software Foundation/Apache2.2/htdocs10882" </VirtualHost>
2.6. サーバ側 ルーティング設定
- Host OS
route add 192.168.201.0 mask 255.255.255.0 192.168.200.1
- Guest OS
route add -net 192.168.200.0/24 gw 192.168.201.2
3. [検証] 基本設定
3.1. 設定投入
以下の通りのshapingを実装します。
No | 条件 | bps |
1 | SSH | 8000 |
2 | URLがlarge.htmlを含む | 8000 |
3 | tcp80 or 10881 or 10882 | 12000 |
投入したconfigは以下の通りです。
R1(config)#ip access-list extended ACL_SSH R1(config-ext-nacl)#permit tcp any any eq 22 R1(config-ext-nacl)#exit R1(config)# R1(config)#ip access-list extended ACL_80 R1(config-ext-nacl)#permit tcp any eq 80 any R1(config-ext-nacl)#exit R1(config)# R1(config)#ip access-list extended ACL_10881 R1(config-ext-nacl)#permit tcp any eq 10881 any R1(config-ext-nacl)#exit R1(config)# R1(config)#ip access-list extended ACL_10882 R1(config-ext-nacl)#permit tcp any eq 10882 any R1(config-ext-nacl)#exit R1(config)# R1(config)#class-map CLASS_SSH R1(config-cmap)#match access-group name ACL_80 R1(config-cmap)#exit R1(config)#class-map CLASS_LARGE R1(config-cmap)#match protocol http url "*large.html*" R1(config-cmap)#exit R1(config)# R1(config)#class-map match-any CLASS_HTTP R1(config-cmap)#match access-group name ACL_80 R1(config-cmap)#match access-group name ACL_10881 R1(config-cmap)#match access-group name ACL_10882 R1(config-cmap)#exit R1(config)# R1(config)#policy-map POLICY_E10_OUT R1(config-pmap)#class CLASS_SSH R1(config-pmap-c)#shape average 8000 R1(config-pmap-c)#exit R1(config-pmap)#class CLASS_LARGE R1(config-pmap-c)#shape average 8000 R1(config-pmap-c)#exit R1(config-pmap)#class CLASS_HTTP R1(config-pmap-c)#shape average 12000 R1(config-pmap-c)#exit R1(config-pmap)#exit R1(config)# R1(config)#interface Ethernet 1/0 R1(config-if)#service-policy out POLICY_E10_OUT
showコマンドにより設定を確認します。
R1#show policy-map interface Ethernet 1/0 Ethernet1/0 Service-policy output: POLICY_E10_OUT Class-map: CLASS_SSH (match-all) 0 packets, 0 bytes 5 minute offered rate 0 bps, drop rate 0 bps Match: access-group name ACL_80 Traffic Shaping Target/Average Byte Sustain Excess Interval Increment Rate Limit bits/int bits/int (ms) (bytes) 8000/8000 2000 8000 8000 1000 1000 Adapt Queue Packets Bytes Packets Bytes Shaping Active Depth Delayed Delayed Active - 0 0 0 0 0 no Class-map: CLASS_LARGE (match-all) 0 packets, 0 bytes 5 minute offered rate 0 bps, drop rate 0 bps Match: protocol http url "*large.html*" Traffic Shaping Target/Average Byte Sustain Excess Interval Increment Rate Limit bits/int bits/int (ms) (bytes) 8000/8000 2000 8000 8000 1000 1000 Adapt Queue Packets Bytes Packets Bytes Shaping Active Depth Delayed Delayed Active - 0 0 0 0 0 no Class-map: CLASS_HTTP (match-any) 0 packets, 0 bytes 5 minute offered rate 0 bps, drop rate 0 bps Match: access-group name ACL_80 0 packets, 0 bytes 5 minute rate 0 bps Match: access-group name ACL_10881 0 packets, 0 bytes 5 minute rate 0 bps Match: access-group name ACL_10882 0 packets, 0 bytes 5 minute rate 0 bps Traffic Shaping Target/Average Byte Sustain Excess Interval Increment Rate Limit bits/int bits/int (ms) (bytes) 12000/12000 1998 7992 7992 666 999 Adapt Queue Packets Bytes Packets Bytes Shaping Active Depth Delayed Delayed Active - 0 0 0 0 0 no Class-map: class-default (match-any) 20 packets, 1679 bytes 5 minute offered rate 0 bps, drop rate 0 bps Match: any R1#
3.2. URLによるshaping
shaping未実装の時に比べて充分な受信速度が出ていない事からshapingが効いている事が分かります。(実際に設定した送信速度とwgetコマンドで確認できる速度に大きな差があります。送信速度に差があるのが、実機ではなくエミュレータを使用しているせいかもしれませんので、不問とします)
[root@localhost ~]# wget -O /dev/null http://192.168.200.100/large.html --2010-12-11 20:03:40-- http://192.168.200.100/large.html Connecting to 192.168.200.100:80... connected. HTTP request sent, awaiting response... 200 OK Length: 23016000 (22M) [text/html] Saving to: `/dev/null' 0% [ ] 63,753 857B/s eta 7h 5m
下記showコマンドでカウンタを確認します。CLASS_LARGEのカウンタが大きく増大するはずですが、カウンタはひとつも増加していません。showコマンドの表示上の不具合の可能性がありますので、深くは追求しない事にします。
R1#show policy-map interface Ethernet 1/0 Ethernet1/0 Service-policy output: POLICY_E10_OUT Class-map: CLASS_SSH (match-all) 185 packets, 111653 bytes 5 minute offered rate 7000 bps, drop rate 0 bps Match: access-group name ACL_80 Traffic Shaping Target/Average Byte Sustain Excess Interval Increment Rate Limit bits/int bits/int (ms) (bytes) 8000/8000 2000 8000 8000 1000 1000 Adapt Queue Packets Bytes Packets Bytes Shaping Active Depth Delayed Delayed Active - 12 173 104765 157 91389 yes Class-map: CLASS_LARGE (match-all) 0 packets, 0 bytes <- 本来ならばこのカウンタが増大するはずです。 5 minute offered rate 0 bps, drop rate 0 bps Match: protocol http url "*large.html*" Traffic Shaping Target/Average Byte Sustain Excess Interval Increment Rate Limit bits/int bits/int (ms) (bytes) 8000/8000 2000 8000 8000 1000 1000 Adapt Queue Packets Bytes Packets Bytes Shaping Active Depth Delayed Delayed Active - 0 0 0 0 0 no Class-map: CLASS_HTTP (match-any) 0 packets, 0 bytes 5 minute offered rate 0 bps, drop rate 0 bps Match: access-group name ACL_80 0 packets, 0 bytes 5 minute rate 0 bps Match: access-group name ACL_10881 0 packets, 0 bytes 5 minute rate 0 bps Match: access-group name ACL_10882 0 packets, 0 bytes 5 minute rate 0 bps Traffic Shaping Target/Average Byte Sustain Excess Interval Increment Rate Limit bits/int bits/int (ms) (bytes) 12000/12000 1998 7992 7992 666 999 Adapt Queue Packets Bytes Packets Bytes Shaping Active Depth Delayed Delayed Active - 0 0 0 0 0 no Class-map: class-default (match-any) 400 packets, 35461 bytes 5 minute offered rate 0 bps, drop rate 0 bps Match: any R1#
3.3. portによるshaping
tcp10881宛ての以下wgetを実施します。
「URLによるshaping」の時に比べて受信速度が大きい事が読み取れます。これは「match protocol http url "*large.html*"」に合致しない事を意味します。この結果から考えると、URLによるマッチが使えるのはtcp80番の場合のみで、ポート番号を変更するとURLによるマッチは使えない事が推測できます。
「URLによるshaping」の時に比べて受信速度が大きい事が読み取れます。これは「match protocol http url "*large.html*"」に合致しない事を意味します。この結果から考えると、URLによるマッチが使えるのはtcp80番の場合のみで、ポート番号を変更するとURLによるマッチは使えない事が推測できます。
[root@localhost ~]# wget -O /dev/null http://192.168.200.100:10881/large.html --2010-12-11 20:06:50-- http://192.168.200.100:10881/large.html Connecting to 192.168.200.100:10881... connected. HTTP request sent, awaiting response... 200 OK Length: 23016000 (22M) [text/html] Saving to: `/dev/null' 0% [ ] 186,940 1.27K/s eta 4h 44m
showコマンドでカウンタを確認します。CLASS_HTTPのみが増加している事から、tcp10881の場合はURLによるマッチングは働いていない事が分かります。
R1#show policy-map interface Ethernet 1/0 Ethernet1/0 Service-policy output: POLICY_E10_OUT Class-map: CLASS_SSH (match-all) 401 packets, 236501 bytes 5 minute offered rate 7000 bps, drop rate 0 bps Match: access-group name ACL_80 Traffic Shaping Target/Average Byte Sustain Excess Interval Increment Rate Limit bits/int bits/int (ms) (bytes) 8000/8000 2000 8000 8000 1000 1000 Adapt Queue Packets Bytes Packets Bytes Shaping Active Depth Delayed Delayed Active - 4 397 234237 381 220861 yes Class-map: CLASS_LARGE (match-all) 0 packets, 0 bytes 5 minute offered rate 0 bps, drop rate 0 bps Match: protocol http url "*large.html*" Traffic Shaping Target/Average Byte Sustain Excess Interval Increment Rate Limit bits/int bits/int (ms) (bytes) 8000/8000 2000 8000 8000 1000 1000 Adapt Queue Packets Bytes Packets Bytes Shaping Active Depth Delayed Delayed Active - 0 0 0 0 0 no Class-map: CLASS_HTTP (match-any) 104 packets, 65040 bytes <- カウンタの増加を確認します。 5 minute offered rate 6000 bps, drop rate 0 bps Match: access-group name ACL_80 0 packets, 0 bytes 5 minute rate 0 bps Match: access-group name ACL_10881 104 packets, 65040 bytes 5 minute rate 6000 bps Match: access-group name ACL_10882 0 packets, 0 bytes 5 minute rate 0 bps Traffic Shaping Target/Average Byte Sustain Excess Interval Increment Rate Limit bits/int bits/int (ms) (bytes) 12000/12000 1998 7992 7992 666 999 Adapt Queue Packets Bytes Packets Bytes Shaping Active Depth Delayed Delayed Active - 12 108 67400 91 53958 yes Class-map: class-default (match-any) 725 packets, 58675 bytes 5 minute offered rate 1000 bps, drop rate 0 bps Match: any R1#
4. [検証] ピークレートの設定
4.1. 設定投入
shape averageではなく、shape peakと指定すると、tc(Committed time interval)あたりに、bc + beのパケットを送信するようになります。この設定によりCIR以上のパケットを送信できるようになりますが、輻輳時はパケットがドロップされる可能性もあります。
設定例は以下の通りです。
設定例は以下の通りです。
R1(config)#policy-map POLICY_E10_OUT R1(config-pmap)#no class CLASS_LARGE R1(config-pmap)#class CLASS_HTTP R1(config-pmap-c)#no shape average R1(config-pmap-c)#shape peak 12000
R1#show policy-map interface Ethernet 1/0 Ethernet1/0 Service-policy output: POLICY_E10_OUT Class-map: CLASS_SSH (match-all) 1594 packets, 930778 bytes 5 minute offered rate 21000 bps, drop rate 0 bps Match: access-group name ACL_80 Class-map: CLASS_HTTP (match-any) 626 packets, 366039 bytes 5 minute offered rate 0 bps, drop rate 0 bps Match: access-group name ACL_80 0 packets, 0 bytes 5 minute rate 0 bps Match: access-group name ACL_10881 626 packets, 366039 bytes 5 minute rate 0 bps Match: access-group name ACL_10882 0 packets, 0 bytes 5 minute rate 0 bps Traffic Shaping Target/Average Byte Sustain Excess Interval Increment Rate Limit bits/int bits/int (ms) (bytes) 24000/12000 1998 7992 7992 666 1998 Adapt Queue Packets Bytes Packets Bytes Shaping Active Depth Delayed Delayed Active - 0 0 0 0 0 no Class-map: class-default (match-any) 1422 packets, 100676 bytes 5 minute offered rate 1000 bps, drop rate 0 bps Match: any R1#
4.2 wgetによる確認
Guest OS上で下記wgetコマンドを実行します。受信速度が先ほどの検証よりも速い事を確認します。
[root@localhost ~]# wget -O /dev/null http://192.168.200.100/large.html --2010-12-11 20:12:36-- http://192.168.200.100/large.html Connecting to 192.168.200.100:80... connected. HTTP request sent, awaiting response... 200 OK Length: 23016000 (22M) [text/html] Saving to: `/dev/null' 5% [=> ] 1,237,516 19.7K/s eta 20m 38s
5. [検証] 詳細なチューニング
5.1. 設定投入
bc, be, tc等のパラメータを明示的に指定する事もできます。
設定例は以下の通りですが、へプルに表示された通り非推奨の設定です。
設定例は以下の通りですが、へプルに表示された通り非推奨の設定です。
R1(config-pmap)#class CLASS_HTTP R1(config-pmap-c)#shape average 12000 ? <256-154400000> bits per interval, sustained. Needs to be multiple of 128. Recommend not to configure it, the algorithm will find out the best value <cr> R1(config-pmap-c)#shape average 12000 2048 1024
5.2. 設定確認
showコマンドで設定を確認します。
R1#show policy-map interface Ethernet 1/0 Ethernet1/0 Service-policy output: POLICY_E10_OUT Class-map: CLASS_SSH (match-all) 11827 packets, 6845368 bytes 5 minute offered rate 125000 bps, drop rate 0 bps Match: access-group name ACL_80 Class-map: CLASS_HTTP (match-any) 770 packets, 454506 bytes 5 minute offered rate 9000 bps, drop rate 0 bps Match: access-group name ACL_80 0 packets, 0 bytes 5 minute rate 0 bps Match: access-group name ACL_10881 770 packets, 454506 bytes 5 minute rate 9000 bps Match: access-group name ACL_10882 0 packets, 0 bytes 5 minute rate 0 bps Traffic Shaping Target/Average Byte Sustain Excess Interval Increment Rate Limit bits/int bits/int (ms) (bytes) 12000/12000 384 2048 1024 170 256 Adapt Queue Packets Bytes Packets Bytes Shaping Active Depth Delayed Delayed Active - 14 146 89647 133 79901 yes Class-map: class-default (match-any) 2301 packets, 151882 bytes 5 minute offered rate 1000 bps, drop rate 0 bps Match: any R1#
添付ファイル