class

Matter::Transport::MessageCounter

Inherits Reference < Object

Manages message IDs and deduplication

Matter protocol uses 32-bit message counters for:

  • Ensuring message ordering
  • Detecting duplicate messages
  • Replay attack protection

Constants

WINDOW_SIZE = 64

Rolling window size for duplicate detection (spec recommends at least 32)

Constructors

new(counter : UInt32 = 0_u32)
Source

Instance methods

check(message_id : UInt32) : CheckResult

Check whether a received message ID is accepted, a duplicate, or stale.

This allows reliability layers to treat duplicates as valid retransmissions (e.g. re-send a cached response) while still rejecting stale replays.

Source
counter
Source
mark_received(message_id : UInt32) : Nil

Mark a message ID as received (for testing/manual tracking)

Source
next

Get next message ID to send

Source
reset(value : UInt32 = 0_u32) : Nil

Reset counter (used when establishing new session)

Source
valid?(message_id : UInt32) : Bool

Check if a received message ID is valid (not a duplicate or replay) Returns true if message should be accepted

Source

Nested types