pymeasure / leco-protocol

Design notes for a generic communication protocol to control experiments and measurement hardware
https://leco-laboratory-experiment-control-protocol.readthedocs.io
MIT License
6 stars 3 forks source link

Propagating sign-in/-out information #46

Open bilderbuchi opened 1 year ago

bilderbuchi commented 1 year ago

@bklebel writes: According to the latest state of the PR #38 (and my latest comments therein, e.g. this comment), I think we should boil down the Control Messages to

In the comments to #38, relating to the discussion in #44, I proposed to simplify the messages so that Coordinators do not announce individual SIGN_IN/OUT actions, but simply send their Directory to all connected Coordinators when it changes.

Originally posted by @bklebel in https://github.com/pymeasure/leco-protocol/issues/29#issuecomment-1428145358

bilderbuchi commented 1 year ago
  • Coordinators should only consider changes to their own global Directories which come from Coordinators of the corresponding Namespace, i.e. if Co1, Co2 and Co3 (with Namespaces N1, N2, and N3, respectively) are present in the leco network, and Co1 sends a CO_UPDATE message to Co3 which contains updates within the N2 Namespace which Co3 does not have yet, Co3 should, rather than trusting Co1 blindly, at least ask Co2 again for its Directory.

On this I have to ask "why?" -- why do we stop trusting our coordinators? If Co3 does not trust Co1 about its Directory, what does it trust Co1 about, and why?

BenediktBurger commented 1 year ago

Let us start with the requirements:

A few messaging options:

  1. We can have a single "directory" message, which sends the global Directory of a Coordinator. This is also used during Component sign-in. Advantage: We do not need regular exchanges of Directories (each sign-in keeps all Directories in an up-to-date version).
  2. We have the full "directory" message and "differential updates", this invites for regular exchanges of the directories among the Coordinators, just in case.
  3. We have a "local_directory" message (destined for communication between Coordinators), an "update" message, and a "global_directory" message (for Components)

A few updating options (how does a Coordinator update its global Directory):

  1. It uses whatever global Directory it gets (which might be outdated regarding some other Coordinator)
  2. It uses only the local Directory (or the corresponding part of the global Directory) of the sending Coordinator

I'm for option 2 ("distrusting other Coordinators") due to timing issues. For example:

In order to keep it simple and reliable, I vote that only a Node's Coordinator is a source of truth regarding that Node's Components. Whether that information is extracted from that Coordinator's global Directory or a special "local directory" message, is secondary.

BenediktBurger commented 1 year ago

My proposal:

bilderbuchi commented 1 year ago

In order to keep it simple and reliable, I vote that only a Node's Coordinator is a source of truth regarding that Node's Components.

thank you for the illustrative example. I agree with this point.

How do we transmit the Coordinator addresses (at Coordinator sign-in)? They do not fit into the normal Directory list, as they contain additional information (address) Where do we put these Coordinator addresses: local or global Directory? In a new Directory ("Coordinator Directory")

I think both can be done in one sweep: the local directory already is, according to your definition above, a

list of connected Components with their identities

So, in essence, a dictionary/key-value store. The coordinator addresses associated with their names are a key-value pair. Above you already say that coordinator addresses are "currently part of local Directory". This looks like it solves the problem? :shrug:

bilderbuchi commented 1 year ago

I'd rather move towards fewer directory types, not more. >.< We could have one "dictionary" directory with full names in the keys and coordinator addresses/local Component identities/nothing as values as appropriate. We trivially can filter out local entries (all starting with <localNamespace>.), coordinators (all ending with .COORDINATOR), or global entries (the rest).

Note: this is already moving a bit toward specifying implementation. How about we specify a set of behaviours/requirements, and let the implementation(s) hash out how they solve it?

bilderbuchi commented 1 year ago

One final point: If we only trust coordinators with information about their local components, but not about global components (because of the timing issue you bring up), we don't need to distribute the global directory at all, only the coordinator information and local names.

BenediktBurger commented 1 year ago

Let's frame it differently: we want to use the information with the least intermediaries.

I always thought, we exchange the local information among Coordinators and they offer the global information to end users.

Regarding the content: For the Coordinator, the local Directory contains the identities. That information does not matter to anybody else, therefore, even the transmitted local directory does not contain more, than the names.

Only the Coordinators need addresses transferred.

Let us define the Directories without the identity (implementation detail). That is even in the direction of discoupling the transport layer from the message layer (you could build a tcp transport layer without those identities).

bilderbuchi commented 1 year ago

Sounds good! (whole comment).

Let's frame it differently: we want to use the information with the least intermediaries.

"May", "Should" or "Must"? :stuck_out_tongue_winking_eye: