Bridge
tree はそのまま route table ではない
Session 07 の tree は `どの router へどの cost で届くか` まででした。Session 08 では、その router が持つ stub network を引いてきて、prefix と next hop を持つ route に変えます。
Read The Source
router cost と stub metric を合算する
routes.append(
OSPFRoute(
prefix=stub.prefix,
next_hop_router_id=next_hop,
total_cost=router_cost + stub.metric,
)
)ここで route cost は 2 つの部分からできています。root から advertising router までの tree cost と、その router が持つ stub network への metric です。
Walkthrough
local stub と remote stub を route にする
cd protocol-in-code PYTHONPATH=src python3 examples/ospf/session_08_walkthrough.py
walkthrough では local prefix と remote prefix がそれぞれ `next_hop_router_id` と `total_cost` を持つ route になることを見ます。
Done Check
Session 08 を終えたと言える条件
- SPF tree と route table を分けて説明できる
- first hop を `parents` から戻す理由を説明できる
- route cost が tree cost と stub metric の合算だと説明できる
Next Session
次は prefix が重複したときの winner を決めます
Session 09 では cost-based choice を読みます。同じ prefix の複数 candidate から 1 本を選ぶところを見ます。