[zeromq-dev] "Who said that?"

Oliver Smith oliver at kfs.org
Thu Dec 16 22:39:20 CET 2010

Martin Sustrik said the following on 12/16/2010 6:41 AM:
> There's no API to get sender's address. The reason is that in multi-hop
> scenarios is not even clear, who's the sender: The original sender or
> the device at the last hop?
I'm not actually looking for the sender's address so much as who */I/* 
got the message from, IE the previous hop. While the address and port 
would be nice for diagnosing sources of bad data within a fabric (I 
spent 2 days this week tracking down what turned out to be a bad stick 
of ram in a machine corrupting outgoing data), it could be any 
thread-unique value that discretely identifies a given TCP-socket-pair 
connection to this zmq context.


     p = sock.recv()
     if p.previousHopID() in sessions:
         p = decrypt(p, sessions[p.previousHopID].encryptionStuff)
         p = process(p)
         session = Session(p.previousHopID())
         sessions[p.previousHopID()] = session

         sock.setsockopt(zmq.SENDMORE, True)
         sock.send(encrypt(salt, server.encryptionStuff))
         p = process(p)
         sock.setsockopt(zmq.SENDMORE, False)

Note carefully: If the previousHopID() was the IP/port, you could easily 
get confused when a node behind NAT disconnects and another node 
subsequently connects with the same NATed ip/port.

> However, with XREQ/XREP sockets the identites of individual hops are
> aggregated in the request (as initial message parts). Check the guide
> for details.

As I said - I can't put the ID information in the WAN packets.

I just have to not use ZMQ for the WAN transit. I'm using a half-baked 
little ZMQ->TCP->TCP->ZMQ bridge for now.

- Oliver

More information about the zeromq-dev mailing list