nasa / SBN

38 stars 23 forks source link

TCP - doesn't handle multiple peers from the same IP #15

Closed CDKnightNASA closed 4 years ago

CDKnightNASA commented 4 years ago

The way the TCP module (currently) determines which peer has connected is by comparing the IP address of the new connection with the IP address of the peer. But if there are multiple peers connecting from the same IP address (such as if you have more than 2 nodes locally that are all using localhost) this will cause an issue.

CDKnightNASA commented 4 years ago

Model should be that when a node connects out, it sends a brief header identifying its CPU ID. On the other side, the "server" should set aside the new socket and wait for the header and not assign it to a peer until that header has been received/confirmed.

jphickey commented 4 years ago

As an interim you might want to consider comparing IP+Port instead of just IP (and of course binding to a specific port on each side of the connection).

CDKnightNASA commented 4 years ago

just committed a fix that disassociates peer sockets on the receive side and associates the connections to peers for sending when the peer is identified by the first message received.