跳到主要内容

状态机

本节描述 EGP 的状态机模型,包括在任一时刻确定状态的变量和常量、引起状态转换的事件、这些转换产生的动作,以及定义其行为的状态转换表。

3.1. 状态变量​

状态机模型包含若干状态变量,它们确定网关与其每个邻居之间的协议状态。因此,与多个邻居维持 EGP 的网关必须为每个邻居分别维护一组这样的状态变量。状态机的当前状态、事件和动作分别适用于每个邻居。

该模型假定,系统资源(包括这组状态变量)在状态机离开 Idle 状态时分配,原因要么是收到了指定新邻居地址的 Request,要么是出现了指定新邻居地址的 Start 事件。这两类事件之一发生时,状态变量的值按下文所示进行初始化。回到 Idle 状态时,所有资源(包括这组状态变量)都被释放并归还系统。当然,实现者也可以选择永久性地专用这些资源和状态变量。

状态变量中包括下列决定模型状态转换的变量。除发送序列号 S 之外,所有变量的初始值都在最初的 Request/Confirm 交换期间设定。S 的初始值是任意的。

        Name    Function
--------------------------------------------------------------
R receive sequence number
S send sequence number
T1 interval between Hello command retransmissions
T2 interval between Poll command retransmissions
T3 interval during which neighbor-reachability
indications are counted
M hello polling mode
t1 timer 1 (used to control Request, Hello and Cease
command retransmissions)
t2 timer 2 (used to control Poll command retransmissions)
t3 timer 3 (abort timer)

可能还需要其他状态变量,以支持各种定时器及类似的内部管理功能。上述变量的作用和管理将在第 4 节讨论。

3.2. 固定参数​

本节定义若干表征网关功能的固定参数,并为每个参数给出基于 Internet 系统中实验性实现的建议值。这些值对具体配置而言不一定合适。

下面列出控制重传及其他与时间相关功能的时间间隔参数。

        Name    Value   Description
--------------------------------------------------------------
P1 30 sec minimum interval acceptable between successive
Hello commands received
P2 2 min minimum interval acceptable between successive
Poll commands recieved
P3 30 sec interval between Request or Cease command
retransmissions
P4 1 hr interval during which state variables are
maintained in the absence of commands or
responses in the Down and Up states.
P5 2 min interval during which state variables are
maintained in the absence of responses in the
Acquisition and Cease states

参数 P4 和 P5 仅在实现了中止定时器选项时使用。参数 P4 确定在没有命令或响应的情况下,状态机将在 Down 和 Up 状态停留多久,通常设置为足以在邻居被转储(dump)并重启期间保持状态信息。参数 P5 确定在没有响应的情况下,状态机将在 Acquisition 或 Cease 状态停留多久,通常设置为与 T3 变量的预期值同一量级。

下面列出其他值得关注的参数。

        Name    Active  Passive Description
-----------------------------------------------
j 3 1 neighbor-up threshold
k 1 4 neighbor-down threshold

参数 j 和 k 确立了后文所述邻居可达性协议的“抗噪能力”。如果网关选择进行 hello 轮询,则建议采用 Active 列中的值;否则建议采用 Passive 列中的值。

3.3. 事件​

下面列出可在模型中引起状态转换的事件。

Name            Event
----------------------------------------------------------------------
Up At least j neighbor-reachability indications have been
received within the last T3 seconds.
Down At most k neighbor-reachabilitiy indications have been
received within the last T3 seconds.
Request Request command has been received.
Confirm Confirm command has been received.
Refuse Refuse response has been received.
Cease Cease command has been received.
Cease-ack Cease-ack response has been received.
Hello Hello command has been received.
I-H-U I-H-U response has been received.
Poll Poll command has been received.
Update Update response has been received.
Start Start event has been recognized due to system or
operator intervention.
Stop/t3 Stop event has been recognized due to (a) system or
operator intervention or (b) expiration of the abort
timer t3.
t1 Timer t1 has counted down to zero.
t2 Timer t2 has counted down to zero.

有一个特殊事件,称为邻居可达性指示(neighbor-reachability indication),它在下列情形发生:

  1. 网关工作在主动模式(启用 hello 轮询),并且收到了 Confirm、I-H-U 或 Update 响应。

  2. 网关工作在被动模式(禁用 hello 轮询),并且收到了 Status 字段带有“Up state”代码的 Hello 或 Poll 命令。

3.4. 状态转换表​

下表概括了对上述事件作出响应时可能发生的状态转换。转换以 n/a 的形式表示,其中 n 是下一状态,a 表示动作。

             0 Idle      1 Aqsn      2 Down       3 Up       4 Cease
+-----------+-----------+-----------+-----------+-----------+
Up |0 |1 |3/Poll |3 |4 |
Down |0 |1 |2 |2 |4 |
Request |2/Confirm *|2/Confirm |2/Confirm |2/Confirm |4/Cease |
Confirm |0/Cease **|2 |2 |3 |4 |
Refuse |0/Cease **|0 |2 |3 |4 |
Cease |0/Cease-ack|0/Cease-ack|0/Cease-ack|0/Cease-ack|0/Cease-ack|
Cease-ack |0 |1 |2 |3 |0 |
Hello |0/Cease **|1 |2/I-H-U |3/I-H-U |4 |
I-H-U |0/Cease **|1 |2/Process |3/Process |4 |
Poll |0/Cease **|1 |2 |3/Update |4 |
Update |0/Cease **|1 |2 |3/Process |4 |
Start |1/Request |1/Request |1/Request |1/Request |4 |
Stop/t3 |0 |0 |4/Cease |4/Cease |0 |
t1 |0 |1/Request |2/Hello |3/Hello |4/Cease |
t2 |0 |1 |2 |3/Poll |4 |
+-----------+-----------+-----------+-----------+-----------+

Note *: The transition shown applies to the case where the
neighbor-acquisition request is accepted. The transition "0/Refuse"
applies to the case where the request is rejected.

Note **: The Cease action shown is optional.

3.5. 状态转换与动作​

下表详细描述状态机的转换及其引发的动作。

                Next    Message
Event           State   Sent            Actions
------------------------------------------------------------------------

Idle State (0)

Request         2       Confirm         Initialize state variables and
                        Hello           reset timer t1 to T1 seconds and
                                        reset timer t3 to P5 seconds.
  (or)          0       Refuse          Return resources.
Cease           0       Cease-ack       Return resources.
Start           1       Request         Reset timer t1 to P3 seconds and
                                        reset timer t3 to P5 seconds.

Acquisition State (1)

Request         2       Confirm         Initialize state variables and
                        Hello           reset timer t1 to T1 seconds and
                                        reset timer t3 to P5 seconds.
Confirm         2       Hello           Initialize state variables and
                                        reset timer t1 to T1 seconds and
                                        reset timer t3 to P5 seconds.
Refuse          0                       Stop timers and return
                                        resources.
Cease           0       Cease-ack       Stop timers and return
                                        resources.
Start           1       Request         Reset timer t1 to P3 seconds and
                                        reset timer t3 to P5 seconds.
Stop/t3         0                       Stop timers and return
                                        resources.
t1              1       Request         Reset timer t1 to P3 seconds.

Down State (2)
Note: Reset timer t3 to P4 seconds on receipt of a reachability
indication.

Up              3       Poll            Reset timer t2 to T2 seconds.
Request         2       Confirm         Reinitialize state variables and
                        Hello           reset timer t1 to T1 seconds and
                                        reset timer t3 to P5 seconds.
Cease           0       Cease-ack       Stop timers and return
                                        resources.
Hello           2       I-H-U
I-H-U           2                       Process neighbor-reachability
                                        info.
Start           1       Request         Reset timer t1 to P3 seconds and
                                        reset timer t3 to P5 seconds.
Stop/t3         4       Cease           Reset timer t1 to P3 seconds and
                                        reset timer t3 to P5 seconds.
t1              2       Hello           Reset timer t1 to T1 seconds.

Up State (3)
Note: Reset timer t3 to P4 seconds on receipt of a reachability
indication.

Down            2                       Stop timer t2.
Request         2       Confirm         Renitialize state variables and
                        Hello           reset timer t1 to T1 seconds and
                                        reset timer t3 to P5 seconds.
Cease           0       Cease-ack       Stop timers and return
                                        resources.
Hello           3       I-H-U
I-H-U           3                       Process neighbor-reachability
                                        info.
Poll            3       Update
Update          3                       Process net-reachability info.
Start           1       Request         Reset timer t1 to P3 seconds and
                                        reset timer t3 to P5 seconds.
Stop/t3         4       Cease           Reset timer t1 to P3 seconds and
                                        reset timer t3 to P5 seconds.
t1              3       Hello           Reset timer t1 to T1 seconds.
t2              3       Poll            Reset timer t2 to T2 seconds.

Cease State (4)

Request         4       Cease
Cease           0       Cease-ack       Stop timers and return
                                        resources.
Cease-ack       0                       Stop timers and return
                                        resources.
Stop/t3         0                       Stop timers and return
                                        resources.
t1              4       Cease           Reset timer t1 to P3 seconds.