TheThingsProducts / gateway

The Things Kickstarter Gateway
https://www.thethingsindustries.com/docs/gateways/models/thethingskickstartergateway
54 stars 20 forks source link

Downlinks are rejected with "LORA: TXPKT failed, too late!" due to integer overflow? #53

Open avbentem opened 5 years ago

avbentem commented 5 years ago

This is a bug report.

What do you want to do? What do you expect?

When the gateway receives a downlink in time, it should not reject it when the server's timestamp encountered an overflow.

What steps did you take? (Give as many details as possible so that we can reproduce it)

Gateway is just running fine, and some (ADR) downlink comes in.

What went wrong? What is missing?

The gateway's serial output shows, with timestamps added by my own logging:

[2018-08-12T15:19:18.062Z] LORA: TXPKT failed, too late! tx: 283227 rx: 4294250523
...
[2018-08-29T04:16:59.029Z] LORA: TXPKT failed, too late! tx: 263659 rx: 4294230955
...
[2018-09-26T18:35:51.432Z] LORA: TXPKT failed, too late! tx: 230388 rx: 4293197684

Values like above make me feel some overflow is not being handled, rather than some true delay in receiving the downlink on the gateway?

The maximum value of an unsigned integer is 4,294,967,295, so all above rx values are just below that maximum. For example, I assume that in the last line the tx value of 230,388 should be interpreted as 4,294,967,295 + 230,388 = 4,295,197,683, leaving 4,295,197,683 - 4,293,197,684 = 1,999,999 microseconds or 1.99 seconds between receiving the downlink at the gateway, and the requested time to transmit it? Likewise for the first 2 lines, 0.99 seconds are available?

What firmware is running on your gateway?

1.0.5 with the factory bootloader.

What do the logs show?

See above.

Note that similar messages might show that downlinks were truly received too late. That has been nicely explained by @htdvisser; see https://www.thethingsnetwork.org/forum/t/getting-lora-txpkt-failed-too-late-in-ttn-gateways-serial-output/18206 But the 3 examples above suggest an overflow rather than a true delay.

Any Screenshots or Photos?

N/A

Do you think you can try to fix this yourself and submit a pull request?

No.