1

I'm implementing a mechanism to detect packet loss in ZeroMQ PUSH/PULL socket type.
1) I was wondering if kvmsg can be used for the same?
2) I would like the client to detect gaps in sequence numbers if there are any loss of packets and implement a resend mechanism accordingly.

1 Answer 1

1

Assuming that kvmsg can cope with arbitrary message structures, then yes. Alternatives include Google Protocol Buffers, XML, etc.

In general one does this by adding a field to the messages that you send, perhaps called "sequence". The software you've written for the PUSH end will set this to zero for the very first message, 1 for the next, incrementing by 1 for each message. The PULL end then simply checks the sequence.

However, the real question is, why is this required by your application? ZMQ guarantees ( in normal circumstances ) delivery of messages. That's kinda the whole point of it. PUSH/PULL means that exactly one PULLer will receive a PUSHed message. If you have one PUSH and one PULL, every PUSHed message will be delivered in the correct order with no loss to the PULLer, barring catastrophic network failures. AFAIK it will even deal with temporary network problems for you, managing reconnection, etc, and still deliver messages in the correct order.

Messages that cannot be sent because the outgoing queue on the PUSH end is full will result in the zmq_send() returning an error, so the PUSH end already knows that a message wasn't sent.

Is there something else more complex about the application?

Sign up to request clarification or add additional context in comments.

11 Comments

Thank you for your answer! Yes, as far as we know there no packets lost in PUSH/PULL model but when the rate of send() increases, we've observed packets being dropped silently without PUSH being blocked. Also, I tried killing PULL temporarily and PUSH did block but when I restarted PULL, there were few messages in between that were lost. Is there a solution to it? Not sure how HWM works here.
@NoName What flags are you passing to zmq_send()?
I am not setting any flags yet.
@NoName, OK, without using ZMQ_DONTWAIT, zmq_send() will block until your PULLer is able to receive the message. You won't be able to send any quicker than the PULL can process them. Regarding the kill, ZMQ gets the message as close to the recipient as possible before queuing the message. So it's possible that messages have propagated across the network to get PULL end, but didn't get processed by the PULL before you killed it. Those will be lost
@NoName, Also the receive buffer HWM size is, by default, 1000 messages. This means that the PULL end will queue up 1000 messages. So if the PULL is being slow to call zmq_recv(), then 1000 will build up inside zmq's own buffers before the PUSH starts having to buffer messages. And when the PUSH buffer fills up too, the zmq_send() will block.
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.