project-chip / connectedhomeip

Matter (formerly Project CHIP) creates more connections between more objects, simplifying development for manufacturers and increasing compatibility for consumers, guided by the Connectivity Standards Alliance.
https://buildwithmatter.com
Apache License 2.0
7.49k stars 2.01k forks source link

Constructs to make it possible for applications to infer liveness to a peer #17256

Open mrjerryjohns opened 2 years ago

mrjerryjohns commented 2 years ago

Problem

It is not terribly easy to infer the liveness to a peer node today, even though there are a number of signals in the SDK to make such an inference possible.

Solution

Create a new LivenessAssessor class that given a 'liveness timeout' parameter and a peer NodeId, can be used to figure out if we are seeing positive message activity from that peer.

There are two variants here that need discussion:

  1. Activity at the exchange layer (i.e receipt of messages on any exchange on any valid secure session to the peer).
  2. Activity at the subscription layer (i.e receipt of a valid report on a valid subscription).

These cover two different use-cases. The first just indicates a positive network pathway to the peer, as well as a valid, healthy secure session.

The second goes a step further - it ensures that we have a valid, healthy subscription to the peer.

The second is needed since just having a valid secure session to the peer doesn't necessarily imply a valid, functioning IM layer above that. The latter is a function of other parameters on the target as well.

If no activity is seen within the liveness timeout, a callback is triggered to indicate loss of liveness. If activity is seen again, the application is notified of the resumption of liveness.

A query-able stateful parameter is also provided.

mrjerryjohns commented 2 years ago

I've been fielding questions of late on how to assess liveness to a peer, and I think providing a construct in the SDK to help tackle that for consumers is highly valuable for 1.0.

stale[bot] commented 1 year ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.

stale[bot] commented 1 year ago

This stale issue has been automatically closed. Thank you for your contributions.