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

Abierto
#283 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
4/5
Tiempo estimado
3-5 días
Aptitud para principiantes
52/100
Tipo de issue
Error
Claridad
Bastante claro
Estado de actividad
Activo
Stack tecnológico
python

Línea de trabajo

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.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

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.

Lenguaje dominante
Python
Estrellas
172
Forks
49
Merge medio
3 min
PR fusionados (30 d)
1

Preparar el entorno

Este proyecto no incluye contenedor de desarrollo, Dockerfile ni guía de contribución, así que la configuración corre por tu cuenta: empieza por su README y consulta nuestra guía para la primera contribución para los pasos generales.

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de zigpy/zigpy-znp

Todos los issues de zigpy/zigpy-znp

Issues similares

Más issues de Python

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.