matter_mrp.c
MRP backoff schedule, retransmit state, replay window.
Overview
MRP backoff schedule, retransmit state, replay window.
depends on matter_mrp.h
API
Fstatic int32_t elapsed(uint32_t now, uint32_t since)
Milliseconds from since to now, correct across the uint32 wrap.
matter_mrp_next_deadline, reachedFstatic bool reached(uint32_t now, uint32_t deadline)
True when now has reached or passed deadline.
matter_mrp_poll · calls elapsedFuint32_t matter_mrp_backoff_ms(uint32_t base_ms, uint8_t send_count, uint8_t jitter)
Compute the MRP backoff delay in milliseconds given a base interval, send count, and random jitter, applying exponential backoff with saturation at the protocol maximum.
matter_mrp_armFvoid matter_mrp_window_init(struct matter_mrp_window *w)
Initialize an MRP replay detection window to accept the first message.
Fint matter_mrp_window_check(const struct matter_mrp_window *w, uint32_t counter)
Check whether a message counter is a replay, a new message, or too old to verify against the sliding window; does not update the window.
Fvoid matter_mrp_window_commit(struct matter_mrp_window *w, uint32_t counter)
Update the sliding window to mark a message counter as seen and advance the high-water mark; handles wrapping and slide-off of old counters.
Fvoid matter_mrp_init(struct matter_mrp *m, uint32_t base_ms)
Initialize an MRP state machine with a base retransmission interval in milliseconds.
Fint matter_mrp_arm(struct matter_mrp *m, uint32_t counter, uint32_t now_ms, uint8_t jitter)
Arm MRP transmission tracking for a datagram counter: record the counter and send count, compute the backoff delay with SENDER_BOOST, and store the time due.
matter_mrp_backoff_msFint matter_mrp_on_ack(struct matter_mrp *m, uint32_t counter)
Mark an in-flight message as acknowledged if the counter matches; returns MATTER_E_STATE if no message is pending or MATTER_E_INVAL if the counter does not match.
Fvoid matter_mrp_on_reliable_recv(struct matter_mrp *m, uint32_t counter, uint32_t now_ms)
Record receipt of a reliable message and arm the standalone acknowledgment timeout; a second reliable message before the first ack goes out replaces the owed counter.
Fbool matter_mrp_take_ack(struct matter_mrp *m, uint32_t *counter)
Retrieve and clear the pending acknowledgment counter if one is due; returns false if no acknowledgment is pending.
Fenum matter_mrp_action matter_mrp_poll(struct matter_mrp *m, uint32_t now_ms, uint32_t *counter)
Poll for the next MRP action to take: retransmit a message, send a standalone acknowledgment, or remain idle; returns MATTER_MRP_GIVE_UP if max retransmissions reached.
reachedFbool matter_mrp_next_deadline(const struct matter_mrp *m, uint32_t *out_ms)
Return the next MRP deadline and whether any retransmission or acknowledgment is pending; used to schedule the next poll.
elapsed