Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Proposal: Subscribe device message #22

Open
pdf opened this issue Nov 24, 2017 · 2 comments
Open

Proposal: Subscribe device message #22

pdf opened this issue Nov 24, 2017 · 2 comments

Comments

@pdf
Copy link

pdf commented Nov 24, 2017

One of the major problems for clients implementing the current LAN protocol is that keeping local state for devices up to date in an environment where multiple clients may make changes is rather sloppy. The only way to do so currently is to poll all devices on some interval, which can be quite expensive, and adds significant delays to state detection.

I'd propose a Subscribe/Unsubscribe message that takes no additional data, and causes the device to send unsolicited State* messages upon completion of any state change to the origin of the Subscribe message.

To support this feature there should also probably be Ping/Pong keep-alive messages, so that devices can time out subscribers that are no longer available. This controls unbounded growth in case subscribers are transient or change address frequently. With this in mind, perhaps the Subscribe message would take a timeout interval for the health check, however I think it would be quite acceptable to simply have a fixed (and quite protracted) check interval. Perhaps 2 failed consecutive checks would invalidate a subscription.

Implementing this proposal would have some overhead - the device would need to store a small amount of data - the IP/port/identifier and failure count (and possibly interval) for each subscription (probably this needs to be bounded, and subscribe should return error on OOM), and to run a scheduler for keep-alives. There would also obviously be n-1 additional datagrams per state change, where n is the number of subscribers (no need to notify the originator of the state update, since they can just request ACK). I don't know what sort of hardware we're dealing with, but I suspect this wouldn't be too onerous a burden.

The overhead for packet processing/transmission probably actually reduces as clients implement this feature (depending on the health probe interval, though those packets will be considerably smaller than full state updates), as it removes the need for constant state probes against all devices, as state updates are only transmitted by devices when a change occurs.

This doesn't solve detection of new devices appearing on the network (or devices being powered on/off at the wall). The former can probably be solved by a broadcast upon joining the network, the latter not so much - open to ideas, though a long poll by the client is probably not the worst thing here.

/brain-dump

@pdf
Copy link
Author

pdf commented Nov 30, 2017

This doesn't solve detection of new devices appearing on the network (or devices being powered on/off at the wall). The former can probably be solved by a broadcast upon joining the network, the latter not so much - open to ideas, though a long poll by the client is probably not the worst thing here.

Thinking about this a little more, with a configurable keep-alive interval, clients can actually just choose to use a lack of incoming pings to detect a powered off device.

@warlord0
Copy link

warlord0 commented Jan 9, 2018

Was just asking about this. If there could be some device "power-on" event trigger broadcast so a listening controller could use it as a timer to turn off the bulb.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants