Protocol in Code · OSPF Session 01

Hello Starts The Neighbor

Session 01 では hello.py を読み、OSPF Hello を「隣接の前にある最初の gate」として理解します。area、netmask、interval、neighbor list を、設定例ではなく関数入力として追います。

IntermediateSession 01hello gateOSPF

Session Goal

Hello を adjacency の入口として説明できるようにする

OSPF の最初の山場は SPF ではありません。Hello がこの link に属してよい packet かどうかを先に見ています。Session 01 のゴールは、なぜ Hello mismatch で話が終わるのかをコードの分岐で説明できるようになることです。

Read The Source

area と interval が最初の if 文になる

if packet.area_id != config.area_id:
    reasons.append("area_mismatch")
if packet.hello_interval != config.hello_interval:
    reasons.append("hello_interval_mismatch")

この session では、OSPF Hello を「neighbor 形成前の適格性チェック」として読みます。ここでの出力は `accepted` と `saw_self` までで、`Init` や `2-Way` への state change 自体は Session 02 の責務です。

Walkthrough

accepted と mismatch を 1 回ずつ見る

cd protocol-in-code
PYTHONPATH=src python3 examples/ospf/session_01_walkthrough.py

walkthrough では 1 つの accepted Hello と 1 つの area mismatch を並べて、`accepted`, `saw_self`, `reasons` を確認します。

Done Check

Session 01 を終えたと言える条件

  • OSPF Hello で一致している必要がある field を挙げられる
  • `neighbors` に自分がいるかどうかで bidirectional visibility が変わると説明できる
  • SPF の前に packet admission の gate があると説明できる

Next Session

次は Hello の結果を state machine に載せます

Session 02 では、accepted Hello と `saw_self` を adjacency state に変換します。`2-Way` で止まる neighbor と `Full` まで進む neighbor を分けて見ます。