net: coap: Add initial tx time to coap_pending structure
So far, coap_pending structure kept track only of the timeout interval between two consecutive retransmissions. Calculations inside `coap_pending_next_to_expire` relied only on this value. This approach gives incorrect results though, in case multiple messages are pending for retransmission. For instance, assuming initial retransmission timeout is set to 2 seconds. If some message had been retransmitted already, its timeout would be increased to 4 seconds. Any new message added to the pending list would have a retransmission timeout set to 2 seconds, and will be returned as a first message to expire, no matter how long the initial message was already on the list. To resolve this, add a `t0` field to the coap_pending structure. This field is initialized to the initial transmission time, and is increased on each retransmission by the retransmission timeout. `coap_pending_next_to_expire` uses this value to calculate absolute time, when the next retransmission should take place, and based on this information returns correctly first pending message to expire. Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
This commit is contained in:
parent
40ac0a7a7d
commit
df152ab59f
2 changed files with 13 additions and 2 deletions
|
@ -233,7 +233,8 @@ typedef int (*coap_reply_t)(const struct coap_packet *response,
|
|||
*/
|
||||
struct coap_pending {
|
||||
struct sockaddr addr;
|
||||
s32_t timeout;
|
||||
u32_t t0;
|
||||
u32_t timeout;
|
||||
u16_t id;
|
||||
u8_t *data;
|
||||
u16_t len;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue