4. Packet Types (分组类型)
RADIUS 分组类型由分组第一个 octet 中的 Code 字段决定.
4.1. Accounting-Request (计费请求)
Description (描述)
Accounting-Request 分组由 Client (通常为 NAS 或其代理) 发往 RADIUS accounting server, 用于承载为向用户所提供服务进行 Accounting 所需的信息. Client 发送 Code 字段设为 4 (Accounting-Request) 的 RADIUS 分组.
收到 Accounting-Request 后, 若服务器成功记录了 Accounting 分组, 则必须发送 Accounting-Response 应答; 若未能记录 Accounting 分组, 则必须不发送任何应答.
凡在 RADIUS Access-Request 或 Access-Accept 分组中合法的属性, 在 RADIUS Accounting-Request 分组中也合法, 但以下属性必须不出现在 Accounting-Request 中: User-Password, CHAP-Password, Reply-Message, State. RADIUS Accounting-Request 中必须出现 NAS-IP-Address 或 NAS-Identifier 之一 (或两者). 除非服务不涉及端口或 NAS 不在其端口之间区分, 否则应该包含 NAS-Port 或 NAS-Port-Type 属性, 或两者兼而有之.
若 Accounting-Request 分组包含 Framed-IP-Address, 则该属性必须包含用户的 IP 地址. 若 Access-Accept 对 Framed-IP-Address 使用了指示 NAS 为用户分配或协商 IP 地址的特殊值, 则 Accounting-Request 中的 Framed-IP-Address (若有) 必须包含实际分配或协商得到的 IP 地址.
Accounting-Request 分组格式概要如下. 字段从左到右传输.
0 1 2 3
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Code | Identifier | Length |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| |
| Request Authenticator |
| |
| |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Attributes ...
+-+-+-+-+-+-+-+-+-+-+-+-+
Code
4, 表示 Accounting-Request.
Identifier
每当 Attributes 字段内容发生变化, 以及每当已为前一请求收到有效应答时, Identifier 字段必须更改. 对于内容完全相同的重传, Identifier 必须保持不变.
注意, 若 Accounting-Request 的属性中包含 Acct-Delay-Time, 则在重传分组时会更新 Acct-Delay-Time 的值, 从而改变 Attributes 字段内容, 并需要新的 Identifier 与 Request Authenticator.
Request Authenticator
Accounting-Request 的 Request Authenticator 包含按上文 "Request Authenticator" 所述方法计算的 16 octet MD5 散列值.
Attributes
Attributes 字段长度可变, 包含属性列表.
4.2. Accounting-Response (计费响应)
Description (描述)
Accounting-Response 分组由 RADIUS accounting server 发往 Client, 用于确认 Accounting-Request 已成功接收并记录. 若 Accounting-Request 记录成功, RADIUS accounting server 必须发送 Code 字段设为 5 (Accounting-Response) 的分组. Client 收到 Accounting-Response 后, 将 Identifier 字段与挂起的 Accounting-Request 匹配. Response Authenticator 字段必须对挂起的 Accounting-Request 给出正确响应. 无效分组应被静默丢弃.
RADIUS Accounting-Response 不要求包含任何属性.
Accounting-Response 分组格式概要如下. 字段从左到右传输.
0 1 2 3
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Code | Identifier | Length |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| |
| Response Authenticator |
| |
| |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Attributes ...
+-+-+-+-+-+-+-+-+-+-+-+-+
Code
5, 表示 Accounting-Response.
Identifier
Identifier 字段是引发本 Accounting-Response 的 Accounting-Request 中 Identifier 字段的副本.
Response Authenticator
Accounting-Response 的 Response Authenticator 包含按上文 "Response Authenticator" 所述方法计算的 16 octet MD5 散列值.
Attributes
Attributes 字段长度可变, 包含零个或多个属性的列表.