set_extended_timeout: clearing for acked sends only affects devices behind routers, no-op round-trips for own children, address table eviction

Đang mở
#765 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

Đánh giá

Độ khó
5/5
Thời gian dự kiến
Hơn một tuần
Mức phù hợp với người mới
35/100
Loại issue
Lỗi
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
python
Lĩnh vực
backend

Hướng nghiên cứu

Read the linked analysis in zigpy/zigpy#1891 and inspect bellows/ezsp/v4/__init__.py and bellows/zigbee/application.py at the cited lines, along with the XNCP combined send. Compare the host and firmware behavior for child devices, routed sleepy devices, and address table entries. Done means choosing and validating a consistent change across the host and combined send paths while accounting for the stated retry-time trade-off.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

Found while investigating zigpy/zigpy#1891. The full analysis is in https://github.com/zigpy/zigpy/issues/1891#issuecomment-5925240976. Related: zigpy/bellows#764, zigpy/bellows#668, zigpy/bellows#747 (fixed).

Before every unicast to a known device, bellows checks EmberZNet's per-device extended-timeout flag and writes it if it differs (set_extended_timeout, ezsp/v4/__init__.py#L222-L263, or the XNCP combined send). Since zigpy/bellows#668, it forces the flag off for APS-acked sends (application.py#L1032-L1040). Based on the prebuilt EmberZNet 9.1 stack library (not reproduced on hardware), this has several side effects.

1. The clearing only takes effect where the extension is needed

EmberZNet decides the extension for its own children from its child table (sli_zigbee_child_extended_timeout) and ignores the address table / binding flag. So clearing it before acked sends changes nothing for the coordinator's own children; those still take up to about 28 s (see zigpy/bellows#764).

It only affects sleepy devices behind a router, cutting their retry window from about 28 s to about 5 s. That's shorter than a typical router's 7.68 s hold. So on EmberZNet, an acked frame such as the OTA Image Notify to a sleepy device behind a router can be reported as failed while the router still holds it, whenever the device doesn't poll and ack within about 5 s. That's the zigpy/zigpy#1891 scenario, which was reported there on Z-Stack. Since zigpy/zigpy#1909 (merged; it closed zigpy/zigpy#1891), a failed Image Notify no longer ends the OTA: zigpy waits for the device to query for the image itself, so the update can still complete. The early failure report described here is unchanged.

2. Round-trips that never stick for own children

getExtendedTimeout answers from the child table, so for an own sleepy child it always reports "extended". Every acked send to such a child then runs getExtendedTimeout, lookupNodeIdByEui64 and setExtendedTimeout(False). The last call only updates binding flags and existing address table entries, so it doesn't change the child's retry timing. On firmware without the combined send, that's three serial round-trips before each acked send instead of one.

3. Address table eviction and flag toggling

For an end device the stack doesn't know (not a child or neighbor, no address table entry, and no binding carrying the flag; typically behind a router), the first send that wants the flag set writes an address table entry for it. Until zigpy/bellows#768 that was a random slot (L254-L263); since then bellows fills the application slots in order and, once all are used, replaces them round-robin. By default, bellows configures at least 16 slots.

After that, the flag flips between unacked requests (True) and acked sends (False; responses and other frames that expect no reply, e.g. the Image Notify), and each flip or re-add costs extra serial round-trips. With more such devices than slots, entries keep evicting each other. A device whose entry is evicted while one of zigpy's retry attempts is in flight falls back to 1.6 s retries for the remaining transmissions (unless a binding entry carries the flag).

On a plain unacked send, the flag does nothing, since there's only one transmission. It only matters on zigpy's retry attempts, which force route discovery and are sent with APS_OPTION_RETRY (unless source routing is enabled). See zigpy/bellows#764 for how long those can take.

4. NabuCasa's combined send mirrors this

The XNCP combined send in NabuCasa's 9.1.1.x beta firmware (NabuCasa/silabs-firmware-builder#209, apply_extended_timeout in xncp_common_commands.c) performs the same check-and-set in firmware ("Mirrors the host set_extended_timeout logic"). It saves the serial round-trips but keeps the behavior above.

One difference: it picks the random slot with % sli_zigbee_address_table_size. On the NCP, that size includes the trust center address cache slots (at least two; bellows configures them as a minimum), while the host path only uses the application slots returned by getConfigurationValue(CONFIG_ADDRESS_TABLE_SIZE). A random pick can therefore land in a trust center cache slot, which the stack overwrites round-robin. Any change to the logic here would need a matching firmware change. NabuCasa/silabs-firmware-builder#236 (open) makes that change: the firmware then uses only the application slots (a free one first, else round-robin) and never touches the trust center cache, in line with zigpy/bellows#768 on the host side.

Possible direction
  • Honour zigpy's extended_timeout for acked sends to end devices again, and size the host wait to match (see zigpy/bellows#764).
  • Skip the call entirely for the coordinator's own children, e.g. based on the child table.
  • Only create address table entries when the extension will actually be used.

The trade-off: acked sends to an unreachable sleepy device behind a router would take about 28 s to fail instead of about 5 s, which is what zigpy/bellows#668 wanted to avoid. (Retry attempts of unacked requests already keep the extension today.)

Ngôn ngữ chính
Python
Star
221
Fork
104
Merge trung bình
5 ngày 15 giờ
Pull request đã merge (30 ngày)
4

Chuẩn bị môi trường

Dự án này không cung cấp dev container, Dockerfile hay hướng dẫn đóng góp, nên bạn cần tự thiết lập môi trường: hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của zigpy/bellows

Tất cả issue của zigpy/bellows

Issue tương tự

Thêm issue về Python

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.