今回はOSPFのCostの自動算出方法を解説します。
座学
Auto Cost Reference Bandwidth
前回の記事で、OSPFにおいて、インタフェースのコストの算出方法は2種類存在することを触れました。
- ip ospf cost <cost>コマンドにより静的に割り当て
- Reference Bandwidthと呼ばれる値をインタフェースの帯域幅で割って算出
今回は、以下の計算式でインタフェースのコストを求める後者の方法を見ていきます。
実機での動作確認
検証内容
R1、R2でOSPF Area 0を有効にし、ルート情報を交換します。
R1、R2のNetwork TypeにはPoint-to-Pointを使用します。
R1のReference Bandwidthを変更した際に、R1の10.2.2.0/24のコストがどのように変化するかを確認します。
初期設定
interface GigabitEthernet2
ip address 10.1.1.1 255.255.255.0
ip ospf network point-to-point
!
router ospf 1
router-id 1.1.1.1
network 10.1.1.0 0.0.0.255 area 0
interface GigabitEthernet2
ip address 10.1.1.2 255.255.255.0
ip ospf network point-to-point
!
interface GigabitEthernet3
ip address 10.2.2.2 255.255.255.0
!
router ospf 1
router-id 2.2.2.2
network 10.1.1.0 0.0.0.255 area 0
network 10.2.2.0 0.0.0.255 area 0
Reference Bandwith変更前
Reference Bandwidthの確認
Reference Bandwithははshow ip ospfコマンドで確認可能です。
R1のReference Bandwidthが100Mbpsであることが確認できます。
R1#show ip ospf
Routing Process "ospf 1" with ID 1.1.1.1
Start time: 10:56:04.568, Time elapsed: 00:07:17.386
Supports only single TOS(TOS0) routes
Supports opaque LSA
Supports Link-local Signaling (LLS)
Supports area transit capability
Supports NSSA (compatible with RFC 3101)
Supports Database Exchange Summary List Optimization (RFC 5243)
Event-log enabled, Maximum number of events: 1000, Mode: cyclic
Router is not originating router-LSAs with maximum metric
Initial SPF schedule delay 50 msecs
Minimum hold time between two consecutive SPFs 200 msecs
Maximum wait time between two consecutive SPFs 5000 msecs
Incremental-SPF disabled
Initial LSA throttle delay 50 msecs
Minimum hold time for LSA throttle 200 msecs
Maximum wait time for LSA throttle 5000 msecs
Minimum LSA arrival 100 msecs
LSA group pacing timer 240 secs
Interface flood pacing timer 33 msecs
Retransmission pacing timer 66 msecs
EXCHANGE/LOADING adjacency limit: initial 300, process maximum 300
Number of external LSA 0. Checksum Sum 0x000000
Number of opaque AS LSA 0. Checksum Sum 0x000000
Number of DCbitless external and opaque AS LSA 0
Number of DoNotAge external and opaque AS LSA 0
Number of areas in this router is 1. 1 normal 0 stub 0 nssa
Number of areas transit capable is 0
External flood list length 0
IETF NSF helper support enabled
Cisco NSF helper support enabled
Reference bandwidth unit is 100 mbps
Area BACKBONE(0)
Number of interfaces in this area is 1
Area has no authentication
SPF algorithm last executed 00:00:31.776 ago
SPF algorithm executed 8 times
Area ranges are
Number of LSA 2. Checksum Sum 0x01C202
Number of opaque link LSA 0. Checksum Sum 0x000000
Number of DCbitless LSA 0
Number of indication LSA 0
Number of DoNotAge LSA 0
Flood list length 0
OSPFが動作しているインタフェースの状態確認
R1のReference Bandwidthが100Mbps、R1のg2の帯域幅が1Gbpsなので、R1のg2のCostが1なことが確認できます。
R1#show ip ospf interface GigabitEthernet2
GigabitEthernet2 is up, line protocol is up
Internet Address 10.1.1.1/24, Interface ID 6, Area 0
Attached via Network Statement
Process ID 1, Router ID 1.1.1.1, Network Type POINT_TO_POINT, Cost: 1
Topology-MTID Cost Disabled Shutdown Topology Name
0 1 no no Base
Transmit Delay is 1 sec, State POINT_TO_POINT
Timer intervals configured, Hello 10, Dead 40, Wait 40, Retransmit 5
oob-resync timeout 40
Hello due in 00:00:09
Supports Link-local Signaling (LLS)
Cisco NSF helper support enabled
IETF NSF helper support enabled
Index 1/1/1, flood queue length 0
Next 0x0(0)/0x0(0)/0x0(0)
Last flood scan length is 1, maximum is 3
Last flood scan time is 0 msec, maximum is 1 msec
Neighbor Count is 1, Adjacent neighbor count is 1
Adjacent with neighbor 2.2.2.2
Suppress hello for 0 neighbor(s)
LSAの状態確認
R1が生成したLSA Type 1のR2向けのリンクのCostが1なことが確認できます。
R1#show ip ospf database router adv-router 1.1.1.1
OSPF Router with ID (1.1.1.1) (Process ID 1)
Router Link States (Area 0)
LS age: 59
Options: (No TOS-capability, DC)
LS Type: Router Links
Link State ID: 1.1.1.1
Advertising Router: 1.1.1.1
LS Seq Number: 80000004
Checksum: 0xD91D
Length: 48
Number of Links: 2
Link connected to: another Router (point-to-point)
(Link ID) Neighboring Router ID: 2.2.2.2
(Link Data) Router Interface address: 10.1.1.1
Number of MTID metrics: 0
TOS 0 Metrics: 1
Link connected to: a Stub Network
(Link ID) Network/subnet number: 10.1.1.0
(Link Data) Network Mask: 255.255.255.0
Number of MTID metrics: 0
TOS 0 Metrics: 1
SPFの計算結果の確認
R1の10.2.2.0/24のCostが2であることが確認できます。
R1#show ip ospf rib
OSPF Router with ID (1.1.1.1) (Process ID 1)
Base Topology (MTID 0)
OSPF local RIB
Codes: * - Best, > - Installed in global RIB
* 10.1.1.0/24, Intra, cost 1, area 0, Connected
via 10.1.1.1, GigabitEthernet2
*> 10.2.2.0/24, Intra, cost 2, area 0
via 10.1.1.2, GigabitEthernet2
ルーティングテーブルの確認
R1のルーティングテーブルに投入された10.2.2.0/24のメトリックが2であることが確認できます。
R1#show ip route ospf
10.0.0.0/8 is variably subnetted, 3 subnets, 2 masks
O 10.2.2.0/24 [110/2] via 10.1.1.2, 00:01:44, GigabitEthernet2
Reference Bandwidth変更後
R1のReference Bnadwidthを30Gbpsに変更します。
追加した設定
Reference Bandwidthはauto-cost reference-bandwidth <mbps>コマンドで変更可能です。
router ospf 1
auto-cost reference-bandwidth 30000
今回はauto-cost reference-bandwidth <mbps>コマンドの動作を確認するために、R1のみReference Bandwidthを変更しましたが、一般的には、OSPFが動作している全ルータでReference Bandwidthは同じ値を使用します。もし、ルータ毎にReference Bandwidthが異なる場合、非対称ルーティング(通信の行きと戻りの経路が異なる事象)が発生する可能性があります。そのため、Reference Bandwidthを変更した際、以下の警告ログが出力されます。
% OSPF: Reference bandwidth is changed.
Please ensure reference bandwidth is consistent across all routers.
Reference Bandwidthの確認
R1のReference Bandwidthが30Gbps(30000Mbps)であることが確認できます。
R1#show ip ospf
Routing Process "ospf 1" with ID 1.1.1.1
Start time: 10:56:04.568, Time elapsed: 00:10:00.670
Supports only single TOS(TOS0) routes
Supports opaque LSA
Supports Link-local Signaling (LLS)
Supports area transit capability
Supports NSSA (compatible with RFC 3101)
Supports Database Exchange Summary List Optimization (RFC 5243)
Event-log enabled, Maximum number of events: 1000, Mode: cyclic
Router is not originating router-LSAs with maximum metric
Initial SPF schedule delay 50 msecs
Minimum hold time between two consecutive SPFs 200 msecs
Maximum wait time between two consecutive SPFs 5000 msecs
Incremental-SPF disabled
Initial LSA throttle delay 50 msecs
Minimum hold time for LSA throttle 200 msecs
Maximum wait time for LSA throttle 5000 msecs
Minimum LSA arrival 100 msecs
LSA group pacing timer 240 secs
Interface flood pacing timer 33 msecs
Retransmission pacing timer 66 msecs
EXCHANGE/LOADING adjacency limit: initial 300, process maximum 300
Number of external LSA 0. Checksum Sum 0x000000
Number of opaque AS LSA 0. Checksum Sum 0x000000
Number of DCbitless external and opaque AS LSA 0
Number of DoNotAge external and opaque AS LSA 0
Number of areas in this router is 1. 1 normal 0 stub 0 nssa
Number of areas transit capable is 0
External flood list length 0
IETF NSF helper support enabled
Cisco NSF helper support enabled
Reference bandwidth unit is 30000 mbps
Area BACKBONE(0)
Number of interfaces in this area is 1
Area has no authentication
SPF algorithm last executed 00:01:17.857 ago
SPF algorithm executed 11 times
Area ranges are
Number of LSA 2. Checksum Sum 0x013255
Number of opaque link LSA 0. Checksum Sum 0x000000
Number of DCbitless LSA 0
Number of indication LSA 0
Number of DoNotAge LSA 0
Flood list length 0
OSPFが動作しているインタフェースの状態確認
R1のReference Bandwidthが30Gbps、R1のg2の帯域幅が1Gbpsなので、R1のg2のCostが30にへkンかしたことが確認できます。
R1#show ip ospf interface GigabitEthernet2
GigabitEthernet2 is up, line protocol is up
Internet Address 10.1.1.1/24, Interface ID 6, Area 0
Attached via Network Statement
Process ID 1, Router ID 1.1.1.1, Network Type POINT_TO_POINT, Cost: 30
Topology-MTID Cost Disabled Shutdown Topology Name
0 30 no no Base
Transmit Delay is 1 sec, State POINT_TO_POINT
Timer intervals configured, Hello 10, Dead 40, Wait 40, Retransmit 5
oob-resync timeout 40
Hello due in 00:00:00
Supports Link-local Signaling (LLS)
Cisco NSF helper support enabled
IETF NSF helper support enabled
Index 1/1/1, flood queue length 0
Next 0x0(0)/0x0(0)/0x0(0)
Last flood scan length is 1, maximum is 3
Last flood scan time is 0 msec, maximum is 1 msec
Neighbor Count is 1, Adjacent neighbor count is 1
Adjacent with neighbor 2.2.2.2
Suppress hello for 0 neighbor(s)
LSAの状態確認
R1が生成したLSA Type 1のR2向けのリンクのCostが30に変化したことが確認できます。
R1#show ip ospf database router adv-router 1.1.1.1
OSPF Router with ID (1.1.1.1) (Process ID 1)
Router Link States (Area 0)
LS age: 161
Options: (No TOS-capability, DC)
LS Type: Router Links
Link State ID: 1.1.1.1
Advertising Router: 1.1.1.1
LS Seq Number: 80000009
Checksum: 0x4572
Length: 48
Number of Links: 2
Link connected to: another Router (point-to-point)
(Link ID) Neighboring Router ID: 2.2.2.2
(Link Data) Router Interface address: 10.1.1.1
Number of MTID metrics: 0
TOS 0 Metrics: 30
Link connected to: a Stub Network
(Link ID) Network/subnet number: 10.1.1.0
(Link Data) Network Mask: 255.255.255.0
Number of MTID metrics: 0
TOS 0 Metrics: 30
SPFの計算結果の確認
R1の10.2.2.0/24のCostが31に変化したことが確認できます。
R1#show ip ospf rib
OSPF Router with ID (1.1.1.1) (Process ID 1)
Base Topology (MTID 0)
OSPF local RIB
Codes: * - Best, > - Installed in global RIB
* 10.1.1.0/24, Intra, cost 1, area 0, Connected
via 10.1.1.1, GigabitEthernet2
*> 10.2.2.0/24, Intra, cost 31, area 0
via 10.1.1.2, GigabitEthernet2
ルーティングテーブルの確認
R1のルーティングテーブルに投入された10.2.2.0/24のメトリックが31に変化したことが確認できます。
R1#show ip route ospf
10.0.0.0/8 is variably subnetted, 3 subnets, 2 masks
O 10.2.2.0/24 [110/31] via 10.1.1.2, 00:01:44, GigabitEthernet2
コメント