DLMS/COSEM 蓝皮书解读(四十五):ISO/IEC 8802-2 LLC Type 3 setup(class_id = 59)—— 确认无连接的 LLC
DLMS/COSEM 蓝皮书解读四十五ISO/IEC 8802-2 LLC Type 3 setupclass_id 59—— 确认无连接的 LLCACn 一问一答T1/T2/T3 还能设无穷大系列说明本系列基于 DLMS UA《Blue Book蓝皮书第 16 版 · 第 2 部分》一个接口类一篇。第 43 篇 Type 1无连接、不确认、第 44 篇 Type 2面向连接、确认把 LLC 的两种极端讲完了。本篇class_id 59是Type 3 —— 确认无连接acknowledged connectionless不建链但每条 ACn 命令都要对方回 ACn 应答是轻量又要有回音的那一档。上篇回顾第 44 篇 Type 2 用整套窗口定时器换来了可靠但代价是建链/断链/状态机重。有些场景只想要我发一条、你确认一条不想背建链开销——Type 3 正好补这个空档用 ACn 命令/应答做一问一答确认配置项比 Type 2 少且时间变量还能设成无穷大关掉定时器。0. 为什么需要这个类 —— “要确认但别让我建链”Type 3 的定位工程视角维度Type 1 (57)Type 3 (59本篇)Type 2 (58)是否建链否否是是否确认否是ACn 命令/应答是I 帧确认配置复杂度极低1 项中5 项高8 项适合广播/丢了无妨单笔请求要确认、嫌建链重长会话/可靠按序典型用法偶发的点名查询 / 点名控制发一条 ACn 命令、等一条 ACn 应答即可没必要为这一来一回建一条 LLC 连接。没有Type 3 setup这类带确认的无连接就没法标准化配置。蓝皮书原文ISO/IEC 8802-2 LLC Type 3 setup, Overview“An instance of the ‘ISO/IEC 8802-2 LLC Type 3 setup’ IC holds the parameters necessary to set up the ISO/IEC 8802-2 LLC layer in Type 3 operation.”1. 类蓝图ISO/IEC 8802-2 LLC Type 3 setup 0…n class_id 59, version 0属性静态/动态数据类型MinMaxDefShort namelogical_namestaticoctet-string———xmax_octets_acn_pdu_n3staticlong-unsigned———x 0x08max_number_transmissions_n4staticunsigned———x 0x10acknowledgement_time_t1staticlong-unsigned———x 0x18receive_lifetime_var_t2staticlong-unsigned———x 0x20transmit_lifetime_var_t3staticlong-unsigned———x 0x28Specific methodsm/oISO/IEC 8802-2 LLC Type 3 setup该类无方法。说明蓝图未列 Min/Max/Def除数据类型与 Short name。三个时间变量T1/T2/T3 支持无穷大 全 1all bits set to 1这是 Type 3 区别于 Type 2 的一个关键特性见 §2.3~2.5。2. 属性逐条解读2.1 logical_name蓝皮书原文“Identifies the ‘ISO/IEC 8802-2 LLC Type 3 setup’ object instance.”示例 OBIS0.0.27.2.0.255非蓝皮书原文实际以设备对象列表为准。2.2 max_octets_acn_pdu_n3static, long-unsigned蓝皮书原文“N3 is a logical link parameter that denotes the maximum number of octets in an ACn command PDU. Refer to the various MAC descriptions to determine the precise value of N3 for a given medium access method. LLC places no restrictions on the value of N3.”N3 ACn 命令 PDU 的最大字节数。与 Type 1 的 UI、Type 2 的 I 同理LLC 不限制具体上限看 MAC 规范。2.3 max_number_transmissions_n4static, unsigned蓝皮书原文“N4 is a logical link parameter that indicates the maximum number of times that an ACn command PDU is sent by LLC trying to accomplish a successful information exchange. Normally, N4 is set large enough to overcome the loss of a PDU due to link error conditions. If the medium access control sublayer has its own retransmission capability, the value of N4 may be set to one so that LLC does not itself requeue a PDU to the medium access control sublayer.”N4 ACn 命令最多重传几次才放弃。关键优化若MAC 子层自己会重传可把 N4 设成1让 LLC 不再二次排队重传避免重复重传。2.4 acknowledgement_time_t1static, long-unsigned单位 秒蓝皮书原文“The acknowledgment time is a logical link parameter that determines the period of the acknowledgment timers … shall define the time interval during which the LLC shall expect to receive an ACn response PDU from a specific LLC from which the LLC is awaiting a response PDU. … If the medium access control sublayer performs its own retransmissions and if the logical link parameter N4 is set to one to prevent LLC from re-queuing a PDU, then the acknowledgment time T1 may be set to infinity, making the acknowledgment timers unnecessary.”T1 发 ACn 命令后等ACn 应答的超时。可设无穷大当 MAC 自己重传(N41)时LLC 的确认定时器可以关掉T1 全 1 infinity完全交给 MAC。2.5 receive_lifetime_var_t2static, long-unsigned单位 秒蓝皮书原文“This time value is a logical link parameter that determines the period of all of the receive variable lifetime timers. T2 shall be longer by a margin of safety than the longest possible period during which the first transmission and all retries of a single PDU may occur. … If the destruction of the received state variables is not desired, the value of time T2 may be set to infinity. In this case the receive variable lifetime timer need not be implemented.”T2 接收端状态变量寿命定时器周期必须比单帧首传所有重传的最长可能耗时还长留安全余量。可设无穷大若不想让收到的状态变量被销毁T2 全 1 infinity此时接收寿命定时器可不实现。2.6 transmit_lifetime_var_t3static, long-unsigned单位 秒蓝皮书原文“This time value is a logical link parameter that determines the minimum lifetime of the transmit sequence state variables. T3 shall be longer by a margin of safety than: a) the logical link variable T2 at stations to which ACn commands are sent; and b) the longest possible lifetime of an ACn command-response pair. … if the receive variable lifetime parameter, T2 is set to infinity at remote stations to which ACn commands are sent, then the T3 parameter shall be set to infinity at the local station.”T3 发送端序列状态变量的最小寿命必须比 (a) 对端 T2、(b) 单个 ACn 命令-应答对的最长寿命 都长留余量。联动约束若对端 T2 设成 infinity本端 T3必须也设 infinity。3. 方法无蓝皮书原文Specific methods m/o该类 methods 列为空——ISO/IEC 8802-2 LLC Type 3 setup没有方法。ACn 的收发与重传由 LLC 状态机按这 5 个参数自动跑无需对象方法配置即可用。4. 【实战举例】示例 1最普通的 ACn 一问一答工程示意主站 发 ACn command如点名读某寄存器 启动 T1如 1s等 ACn response server 回 ACn response → T1 停 → 完成一次确认无连接交互比 Type 2 省了 XID 建链/断链比 Type 1 多了确认。示例 2MAC 自带重传 → N41、T1infinity推荐组合所用 MAC 自己会重传如某些 PLC MAC → SET max_number_transmissions_n4 unsigned 1 → SET acknowledgement_time_t1 long-unsigned 0xFFFFFFFF全 1 infinity → LLC 不再二次重传、确认定时器关掉可靠性全交 MAC说明0xFFFFFFFF表示全 1的示意32 位原文只说all bits set to 1具体位宽看实现。这是原文明确允许的优化。示例 3T2 / T3 设 infinity 的连锁反应对端收 ACn 的一方设 T2 infinity不想销毁接收状态变量 → 本端发 ACn 的一方必须把 T3 也设 infinity原文强制 否则 T3 会比对端 T2 短状态变量寿命不一致 → 行为未定义示例 4T2 必须 首传所有重传时长假设 N43、单帧重传间隔约 0.3s、首传 0.1s单次交互最长 ≈ 0.1 3×0.3 1.0s → T2 必须 1.0s留安全余量如设 2s T2 若设成 0.5s 1.0s → 状态变量可能被提前销毁丢应答说明数值为示意非蓝皮书原文用于说明T2 要比交互最长耗时更长的约束。示例 5N3 与 MAC 上限max_octets_acn_pdu_n3上限看 MAC同 Type 1/2 的 N1/UI 逻辑。设超过 MAC 能力ACn 命令会被 MAC 丢弃。示例 6Type 1/2/3 选型速查结合 42/43场景选广播费率/时钟丢了无所谓Type 1 (57)单笔点名要确认、不想建链Type 3 (本篇)长会话、可靠按序、要流控Type 2 (58)示例 7ACn 命令 PDU 的典型用法工程示意Type 3 的 ACn 常用于点名式交互例如主站点名读某寄存器主站 → ACn command(含 xDLMS GET 请求) 启动 T1等 ACn response server → ACn response(含 GET 结果)比 Type 2 省 XID 建链比 Type 1 多了确认。示例 8N41 与 MAC 重传的职责划分若 MAC 自己重传如 PLC MAC 有 HARQ/重传设 N41LLC 发一次 ACn剩下的丢了重发全交给 MACLLC 的 T1 可设 infinity。好处避免 LLC 和 MAC 双重重传造成时延翻倍。示例 9T1infinity 时怎么知道没收到T1infinity 意味着 LLC 不等确认、不重传——可靠性完全由 MAC兜底。若 MAC 也不保证或 MAC 重传次数用尽那这次 ACn 就真丢了上层要自己发现超时/重试。设 infinity 前务必确认 MAC 可靠。示例 10T2/T3 的状态变量寿命是什么Type 3 为处理 ACn 命令/应答会在两端保留一些状态变量如已发/已收的序号、待确认项。T2/T3 决定这些变量活多久才被清。设 infinity 表示永不自动清——省去定时器但变量长期占内存适合连接极少、但每次都要对的场景。示例 11Type 3 与 Type 2 的确认有何不同Type 2 确认基于I 帧序号(N(S)/N®)面向一条已建连接连续按序Type 3 确认基于ACn 命令/应答的配对无连接每条独立确认。Type 3 没有窗口/流控所以不适合大块连续传输适合零星点名。示例 12选型速查结合 42/43需求选广播费率/时钟Type 1 (57)单笔点名要确认、嫌建链重Type 3 (59, 本篇)长会话/可靠按序/流控Type 2 (58)5. 工程上容易踩的坑T1/T2/T3 可设无穷大全 1这不是 bug是原文特性MAC 自带重传时设 infinity 反而更干净。T2 设 infinity ⇒ T3 必须 infinity两端寿命参数联动漏设会导致状态变量寿命不一致。T2 必须 首传所有重传的最长耗时否则接收状态变量被提前销毁、丢应答留安全余量。N4 与 MAC 重传重叠若 MAC 自己重传把 N4 设 1 避免 LLC 二次重传否则可能重复重传、翻倍时延。三个时间变量单位都是秒、long-unsigned别填毫秒T1 等超时值看网络时延。N3 上限看 MACLLC 不限制 ACn 字节数真正上限来自所用 MAC 规范。Type 3 无方法建链/重传全自动无 reset 之类动作。别和 Type 2 混淆Type 3 是无连接但确认ACn 命令/应答没有窗口 k/RW、没有 I 帧序列号要窗口流控请回 58。6. 小结 下期预告本篇要点ISO/IEC 8802-2 LLC Type 3 setup(59) 配置Type 3 确认无连接LLC5 个静态属性、无方法尺寸/重传N3ACn 命令最大字节上限看 MAC、N4ACn 最大重传MAC 自带重传时可设 1三个时间变量T1等 ACn 应答/T2接收状态变量寿命/T3发送状态变量最小寿命单位秒均可设infinity全 1关键约束T2infinity ⇒ T3infinityT2 必须比首传重传最长耗时更长。下一篇第 46 篇Register tableclass_id 61注意 class_id 60 为空档—— 把多个Register(3) 对象按表格形式组织成一张寄存器表一次 GET 就能读出一组寄存器适合需要批量、结构化读取的场景。参考资料DLMS UA《Blue Book Ed.16 Part 2 – COSEM interface classes》ISO/IEC 8802-2 LLC Type 3 setup(class_id 59, version 0) 章节文中属性、数据类型、Short name 偏移、引文含 infinity all bits set to 1、T2⇒T3 联动等均与原文一致示例中的取值、秒数、字节、时序为帮助理解而构造标注示例/非蓝皮书原文实际以设备对象列表及所用 MAC 规范为准。