DataConfirm timeout (8 s) for routers can be shorter than Z-Stack's APS retry window

未关闭
#283 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
4/5
预计耗时
3-5 天
新手友好度
52/100
Issue 类型
缺陷
描述清晰度
基本清楚
活跃度
活跃
技术栈
python

调研方向

The timeout is defined in zigbee/application.py at DATA_CONFIRM_TIMEOUT; the issue also says startup already reads NV. Start by tracing that NV read path and how ACK_REQUEST packets wait for AF.DataConfirm. Compare reading the configured retry values with using the 30 s extended timeout. Done means acknowledged sends wait long enough for the configured APS retry window without disrupting other packet paths.

由索引模型根据 Issue 内容生成。

描述

Found while investigating zigpy/zigpy#1891. The full analysis is in https://github.com/zigpy/zigpy/issues/1891#issuecomment-5925240976. Possibly related: zigpy/zigpy-znp#282 (data confirm timeouts to a router during an OTA update; its cause isn't established). Related: zigpy/zigpy-znp#290 (confirms are matched by ZCL TSN only, so confirms can go to the wrong request when same-TSN requests to different devices are in flight; a confirm arriving after its listener timed out here could likewise be taken by another request with the same TSN).

For unicast packets without extended_timeout, zigpy-znp waits 8 s for AF.DataConfirm (DATA_CONFIRM_TIMEOUT, application.py#L36). In practice that's routers: end devices and devices without a node descriptor get the 30 s EXTENDED_DATA_CONFIRM_TIMEOUT, and ZDO requests and broadcasts don't wait for a confirm at all.

Z-Stack's APS retry window

With TI's default configuration, Z-Stack waits APSC_ACK_WAIT_DURATION_POLLED (3000 × 2 ms = 6 s) for the ack after each transmission of an APS-acked frame, for every destination, despite the "polled devices" wording in TI's config comments. I checked this in the prebuilt libZStack_nwk_all.a from SDK 8.30.01.01:

  • NLDE_DataCnf reschedules every frame that waits for an APS ack using zgApscAckWaitDurationPolled. Only NWK_NO_ROUTE and MAC_TRANSACTION_EXPIRED are reported without waiting.
  • nwk_event_loop reports ZApsNoAck after the last wait.
  • With APS_FRAME_RETRIES = N, that's N transmissions and N waits. The default is 3, so about 18 s.
Effect on zigpy-znp
  • Unreachable router: an acked send can take up to about 18 s before Z-Stack reports. zigpy-znp times out first, and zigpy retries while Z-Stack is still retrying.
  • Reachable router whose first acks get lost: a success on the third transmission is only confirmed after more than 12 s. zigpy-znp has already timed out, and zigpy sends a new frame with a new APS counter, which the router receives as a duplicate.
Which firmware is affected

Koenkk's CC26xx/CC13xx coordinator firmware (Z-Stack_3.x.0) sets APSC_ACK_WAIT_DURATION_POLLED to 500 (1 s, about 3 s in total), so users of that firmware generally aren't affected. Firmware that keeps TI's default is.

The compiled value isn't necessarily the one in effect, though. Z-Stack writes it to NV item 0x0044 (ZCD_NV_APS_ACK_WAIT_DURATION) only when that item doesn't exist yet, or when it boots with the clear-config startup option (zgInit / zgItemInit). zigpy-znp sets that option when it forms or restores a network (unless form_quickly is used). Otherwise, Z-Stack uses whatever NV holds, so a coordinator flashed without erasing NV, and not re-formed since, can still carry an older value.

Possible fix

Read the ack wait (APS_ACK_WAIT_DURATION, 0x0044) and retry count (APS_FRAME_RETRIES, 0x0043) from NV at startup. zigpy-znp already reads NV there. Then size the confirm timeout for packets with ACK_REQUEST from them.

Simpler: use the 30 s EXTENDED_DATA_CONFIRM_TIMEOUT for packets with ACK_REQUEST. That costs nothing when Z-Stack reports on time; it only lengthens the wait for a confirm that never arrives.

主要语言
Python
星标
172
派生
49
平均合并
3 分钟
30 天内合并 PR
1

环境准备

这个项目没有提供开发容器、Dockerfile 或贡献指南,环境需要你自己搭建:先看它的 README,通用步骤见我们的新手贡献指南。

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

zigpy/zigpy-znp 的其他 Issue

查看 zigpy/zigpy-znp 的全部 Issue

相似的 Issue

更多 Python Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。