pub struct SessionParams {
pub idle_interval_ms: u32,
pub active_interval_ms: u32,
pub active_threshold_ms: u16,
pub data_model_revision: u16,
pub interaction_model_revision: u16,
pub specification_version: u32,
pub max_paths_per_invoke: u16,
pub supported_transports: TransportModes,
pub max_tcp_message_size: Option<u32>,
}Expand description
session-parameter-struct — what each side announces about itself during session
establishment (Core §4.13.1, Table 23).
It rides in five messages: CASE Sigma1, Sigma2 and Sigma2_Resume, and PASE
PBKDFParamRequest and PBKDFParamResponse. Nine fields, and the shape of the struct is
not the shape of the schema, deliberately:
| Tag | Field | §4.13.1 | Here |
|---|---|---|---|
| 1 | SESSION_IDLE_INTERVAL | optional | always sent |
| 2 | SESSION_ACTIVE_INTERVAL | optional | always sent — see below |
| 3 | SESSION_ACTIVE_THRESHOLD | optional | always sent |
| 4 | DATA_MODEL_REVISION | mandatory | Self::data_model_revision |
| 5 | INTERACTION_MODEL_REVISION | mandatory | Self::interaction_model_revision |
| 6 | SPECIFICATION_VERSION | mandatory | Self::specification_version |
| 7 | MAX_PATHS_PER_INVOKE | mandatory | Self::max_paths_per_invoke |
| 8 | SUPPORTED_TRANSPORTS | mandatory | Self::supported_transports |
| 9 | MAX_TCP_MESSAGE_SIZE | optional | Self::max_tcp_message_size |
Why no field is an Option except the last. Tags 4–8 have been mandatory since
Matter 1.3, so a struct that can omit them is a struct that can represent a message the
specification forbids. Tags 1–3 stay optional in the schema, but §4.13.1 adds “if any tag
after tag 2 (SESSION_ACTIVE_INTERVAL) is present, then the SESSION_ACTIVE_INTERVAL SHALL
also be present” — and tags 4–8 are always present — so tag 2 is mandatory in practice,
and sending 1 and 3 alongside it costs eight octets and removes two more Options. What
is left optional is the one field that genuinely is: MAX_TCP_MESSAGE_SIZE, which is
meaningless on a node that does not speak TCP.
The consequence that matters is that this struct cannot encode to an empty structure.
The previous shape — three Options and a derived Default — could, and did: every
released CHIP SDK refuses an empty session-parameter-struct, because
PairingSession::DecodeSessionParametersIfPresent calls Next() once without guarding
it against CHIP_END_OF_TLV where every later call in the same function is guarded. A
conformant struct is never empty, so conformance and interoperability close the same hole.
Receiving is the asymmetric half. A peer older than 1.3 sends only tags 1–3, so
SessionParams::decode — crate-private, because a peer’s parameters reach this crate only
inside a message it parses — starts from SessionParams::legacy_peer, Table 23’s default
for every parameter, and overwrites what the peer actually sent. Table 23 requires
exactly that: “A Node SHALL use the provided default value for each parameter unless the
message recipient Node advertises an alternate value”.
Fields§
§idle_interval_ms: u32SESSION_IDLE_INTERVAL [1], in milliseconds — “minimum amount of time between sender
retries when the destination node is Idle”. Table 23’s default is 500 ms.
active_interval_ms: u32SESSION_ACTIVE_INTERVAL [2], in milliseconds — the same when the destination is
Active. Table 23’s default is 300 ms.
active_threshold_ms: u16SESSION_ACTIVE_THRESHOLD [3], in milliseconds — “minimum amount of time the node
SHOULD stay active after network activity”. Table 23’s default is 4000 ms.
data_model_revision: u16DATA_MODEL_REVISION [4] — §7.1.1’s revision. crate::DATA_MODEL_REVISION here.
interaction_model_revision: u16INTERACTION_MODEL_REVISION [5] — §8.1.1’s revision.
crate::im::INTERACTION_MODEL_REVISION here.
specification_version: u32SPECIFICATION_VERSION [6] — §11.1.5.22’s four component bytes.
crate::SPECIFICATION_VERSION here.
max_paths_per_invoke: u16MAX_PATHS_PER_INVOKE [7] — “the maximum number of elements in the InvokeRequests
list that the Node is able to process”. §11.1.5.23: “If the MaxPathsPerInvoke
attribute is absent or zero … clients SHALL assume a value of 1”, so 1 is the floor
and never 0.
supported_transports: TransportModesSUPPORTED_TRANSPORTS [8] — Table 7’s bitmap, “in addition to MRP”. Empty means MRP
only, which is every node that does not speak TCP.
max_tcp_message_size: Option<u32>MAX_TCP_MESSAGE_SIZE [9], in octets — “maximum size of the message carried over
TCP, excluding the framing message length field, that the node is capable of
receiving”. None on a node with no TCP; Table 23’s default is 64000.
Implementations§
Source§impl SessionParams
impl SessionParams
Sourcepub const DEFAULT_MAX_TCP_MESSAGE_SIZE: u32 = 64_000
pub const DEFAULT_MAX_TCP_MESSAGE_SIZE: u32 = 64_000
Table 23’s default MAX_TCP_MESSAGE_SIZE.
The three MRP timings have defaults too, and they are not repeated here: Table 22 and
Table 23 are the same three numbers, and MrpParams::default already carries them.
Two copies of a specification default are two things to forget at an uplift.
Sourcepub fn legacy_peer() -> Self
pub fn legacy_peer() -> Self
What a peer is assumed to be when it sends no session-parameter-struct at all, or
one from before Matter 1.3 — every parameter at Table 23’s default.
The revisions are the floors, not this crate’s values, and that is the whole point: §4.13.1 says “if the DATA_MODEL_REVISION field is missing, it implies a DataModelRevision value of either 16 or 17”, so a peer that omitted it is a 1.0-era peer and must be treated as one. Assuming this node’s own revisions for a silent peer would be assuming the peer understands everything this node does.
Sourcepub fn announce(mrp: &MrpParams) -> Self
pub fn announce(mrp: &MrpParams) -> Self
What this node announces: its own MRP timings, and this crate’s revisions.
MAX_PATHS_PER_INVOKE starts at 1 — §11.1.5.23’s floor, and the value a node that
has not thought about batched Invoke must report — and SUPPORTED_TRANSPORTS starts
empty. Both are raised with the builders below, and both must match what the node
actually does: a peer is entitled to send MAX_PATHS_PER_INVOKE commands in one
Invoke and to open a TCP connection if this says it may.
Sourcepub const fn with_max_paths_per_invoke(self, max: u16) -> Self
pub const fn with_max_paths_per_invoke(self, max: u16) -> Self
Announces a MAX_PATHS_PER_INVOKE above the floor.
Clamped to at least 1, because §11.1.5.23 makes zero mean one and a zero on the wire would be read as “absent” by a peer that follows it.
Sourcepub const fn with_transports(
self,
modes: TransportModes,
max_tcp_message: u32,
) -> Self
pub const fn with_transports( self, modes: TransportModes, max_tcp_message: u32, ) -> Self
Announces the transports this node supports in addition to MRP, and the largest TCP message it can receive.
The two travel together because one without the other is a contradiction: a size for
a transport that was not announced tells a peer nothing, and announcing
TransportModes::TCP_SERVER without a size leaves the peer on Table 23’s 64000.
Sourcepub fn to_mrp(self) -> MrpParams
pub fn to_mrp(self) -> MrpParams
Turns an announcement into MRP parameters, clamping what the peer sent.
The clamping is not optional politeness: these values decide how long this node waits before retransmitting, and they came from a stranger.
Sourcepub const fn accepts_tcp(&self) -> bool
pub const fn accepts_tcp(&self) -> bool
Whether the peer said it will accept a TCP connection (Table 7, bit 2).
Sourcepub const fn max_tcp_message_size_or_default(&self) -> u32
pub const fn max_tcp_message_size_or_default(&self) -> u32
The largest TCP message the peer said it can receive, or Table 23’s default.
Trait Implementations§
Source§impl Clone for SessionParams
impl Clone for SessionParams
impl Copy for SessionParams
Source§impl Debug for SessionParams
impl Debug for SessionParams
Source§impl Default for SessionParams
impl Default for SessionParams
Source§fn default() -> Self
fn default() -> Self
This node’s announcement with Table 22’s MRP timings — the same thing
SessionParams::announce builds from MrpParams::default.
A Default here was once the defect rather than the convenience: when every field was
an Option, the derived Default was three Nones and encoded to an empty structure
that every released CHIP SDK refuses. It is safe now for a structural reason
rather than a careful one — §4.13.1’s tags 4-8 are mandatory, so they are plain fields,
and there is no combination of this type that encodes to an empty container.