Reputation: 11
I need to design a peer to peer network for communication using ZeroMQ. Reading through chapter 8 of the guide regarding the harmony pattern made me think that this was possible but I am very confused about particular points that the author made. For example, I understand the need for every node having its own specific dealer socket as but I do not understand how he chooses to format the router socket(s). Does each node have its own individual router socket and, if so, how is it centralized? If not, how would I used a centralized router socket to communicate with the individual dealers. Lastly, is this harmony model really peer to peer? Based on my understanding, it requires a centralized "broker" to facilitate the entire system rather than having each node directly connect to each other? Thank you in advance.
Upvotes: 1
Views: 88
Reputation: 8414
Other responders will no doubt be able to fill in here and there, but as I understand it the "format of the router socket" is that messages that arrive from other peers through the ROUTER socket come with a UUID pre-pended as a message part. The ROUTER socket invents random UUIDs, one for each remote peer that has connected to it. There's some information here, near Figure 28.
You use this UUID to remember which peer this message came from, so that you can associate future received messages with the same peer. Technically speaking, all incoming messages are multiplexed through that single ROUTER socket, and the UUIDs allow you to demultiplex them out into separate messages streams from separate peers.
Meanwhile you have a DEALER socket per connected peer. This is used to send message back to that peer. Thus you need to store the following items per peer: UUID, DEALER socket.
Note that since ZMQ3.0 it's not a UUID, it's a random 32bit number. But it serves the same purpose.
Upvotes: 1