enbility / ship-go

EEBUS SHIP protocol implementation in go
https://enbility.net
MIT License
5 stars 6 forks source link

Handling of simultaneous connection attempts according to spec is too complex #5

Open DerAndereAndi opened 1 year ago

DerAndereAndi commented 1 year ago

The SHIP Spec defines in 12.2.2 how to "Prevent Double Connections with SKI Comparison":

If a SHIP node recognizes that there are two or more simultaneous connections to another SHIP node, the SHIP node with the bigger 160 bit SKI value SHALL only keep the most recent connection open and close all other connections to the same SHIP node (a previous release of this SHIP specification may permit a different preference). If an older connection is already in the SME data exchange phase, the SHIP node with the bigger SKI value SHOULD initiate a connection termination as described in section 13.4.7.

This is quite complex and could still run into issues as both devices may consider both connections "as old as the other".

This stack instead does the following: The connection initiated by the higher SKI will be kept. This is a lot simpler and always clear to both ends.