4. Multicast Listener 的协议描述
本节描述 MLDv2 中适用于 multicast listener (host 或 router) 的部分. 本节描述的协议在支持 multicast reception 的每个 interface 上执行.
4.1. Multicast Listener State
multicast listener 为每个 multicast address 维护 per-interface state. 该状态由 filter mode 和 source address list 组成.
- Filter Mode: 可以是 INCLUDE 或 EXCLUDE.
- Source List: 一组 unicast IP address; 当 mode 为 INCLUDE 时, 接受来自这些 source 的 multicast packet; 当 mode 为 EXCLUDE 时, 拒绝来自这些 source 的 multicast packet.
4.2. Interface State 变化时的动作
当某个 interface 上的 multicast reception state 发生变化时 (例如 application 加入 group 或改变其 source filter), listener 会立即发送 State Change Report.
State Change Report 包含受影响 multicast address 的 Multicast Address Record. Record Type 和内容取决于变化:
| Old State | New State | Record Type | Content |
|---|---|---|---|
| INCLUDE (A) | INCLUDE (B) | ALLOW | B - A |
| INCLUDE (A) | INCLUDE (B) | BLOCK | A - B |
| EXCLUDE (A) | EXCLUDE (B) | ALLOW | A - B |
| EXCLUDE (A) | EXCLUDE (B) | BLOCK | B - A |
| INCLUDE (A) | EXCLUDE (B) | TO_EX | B |
| EXCLUDE (A) | INCLUDE (B) | TO_IN | B |
4.3. 收到 Query 时的动作
当 listener 收到 Query 时, 它执行以下动作:
- 如果 Query 是 General Query, listener 会为其拥有状态的 所有 multicast address 发送 Current State Report.
- 如果 Query 是 Multicast-Address-Specific Query, listener 会为指定 multicast address 发送 Current State Report (如果它拥有该地址的状态).
- 如果 Query 是 Multicast-Address-and-Source-Specific Query, 且指定 source 受到关注, listener 会为指定 multicast address 发送 Current State Report.
Current State Report 包含具有以下 Record Type 的 Multicast Address Record:
- MODE_IS_INCLUDE: 表示 interface 对指定 multicast address 的 filter mode 为 INCLUDE. Source List 包含受到关注的具体 source.
- MODE_IS_EXCLUDE: 表示 interface 对指定 multicast address 的 filter mode 为 EXCLUDE. Source List 包含要排除的具体 source.
Report 会在一个随机延迟之后发送 (不超过 Query 中指定的 Maximum Response Delay), 以避免多个 listener 的 Report 同步发送.