[zeromq-dev] PGM multicast

Martin Sustrik sustrik at 250bpm.com
Mon May 10 08:39:54 CEST 2010


Hi tradermbox :)

> I have set up the following experiment:
> 
> 1. a server connects to 2 separate multi-cast addresses over EPGM.
> 2. a client listening to messages from both multi-cast addresses
> 
> Problem - we find the order of received messages are not expected and 
> sometimes we will be missing messages completely from one multicast 
> source. I have added the source code and the results at the bottom of 
> the email.
> 
> Question - I wonder why we are missing messages or the messages come 
> through in different order?

Ordering: If you pass messages via different channels the ordering is 
not guaranteed -- and actually should not be guaranteed. That way the 
streams can have different QoS.

If you want the messages to be ordered, pass them via a single data stream.

As for missing messages, it's difficult to say straight away. Is the 
receiver already running when you start the sender? Does it miss only 
some initial messages or is one message stream blocked forever?

Martin

> Source code:
> #include <stdio.h>
> #include <zmq.hpp>
> #include <stdint.h>
> 
> int main(int argc, char* argv[]) {
> try {
> zmq::context_t ctx(1,1);
> zmq::socket_t s1(ctx,ZMQ_PUB);
> zmq::socket_t s2(ctx,ZMQ_PUB);
> int64_t rate = 10000;
> s1.setsockopt (ZMQ_RATE, &rate, sizeof (rate));
> s2.setsockopt (ZMQ_RATE, &rate, sizeof (rate));
> s1.connect ("epgm://eth0;239.192.1.1:5555");
> s2.connect ("epgm://eth0;239.192.1.1:5556");
> for (int i = 0;i<10;i++)  {
> zmq::message_t msg (10);
> memcpy (msg.data (), "xy.z\x00" "ABCDE", 10);
> s1.send (msg);
> zmq::message_t msg2 (10);
> memcpy (msg2.data (), "XY.X\x00" "123123", 10);
> s2.send (msg2);
> }
> }
> catch(std::exception &e) {
>     printf ("An error occurred: %s\n", e.what());
>         return 1;
> }
> return 0;
> }
> 
> client code:
> #include <stdio.h>
> #include <zmq.hpp>
> int main(int argc, char* argv[]) {
> try {
> zmq::context_t ctx(1,1);
> zmq::socket_t s(ctx,ZMQ_SUB);
> s.setsockopt(ZMQ_SUBSCRIBE,"",0);
> s.connect("epgm://eth0;239.192.1.1:5555");
> s.connect("epgm://eth0;239.192.1.1:5556");
> zmq::message_t res;
> int i = 100;
> while(i>0) {
> s.recv(&res);
> const char *resultset_string = (const char *)res.data ();
> printf ("Received response: '%s'\n", resultset_string);
> }
> i--;
> }
> catch(std::exception &e) {
>     printf ("An error occurred: %s\n", e.what());
>         return 1;
> }
> return 0;
> }
> 
> 
> results:
> we get 3 types of results:
> 
> 1. messages come through in the same order as the server sends them out:
> 
> Received response: 'XY.X'
> Received response: 'xy.z'
> Received response: 'XY.X'
> Received response: 'xy.z'
> Received response: 'XY.X'
> Received response: 'xy.z'
> Received response: 'XY.X'
> Received response: 'xy.z'
> Received response: 'XY.X'
> Received response: 'xy.z'
> Received response: 'XY.X'
> Received response: 'xy.z'
> Received response: 'XY.X'
> Received response: 'xy.z'
> Received response: 'XY.X'
> Received response: 'xy.z'
> Received response: 'XY.X'
> Received response: 'xy.z'
> Received response: 'XY.X'
> 
> result 2: results is in a different order to messages being sent out
> 
> Received response: 'xy.z'
> Received response: 'xy.z'
> Received response: 'xy.z'
> Received response: 'xy.z'
> Received response: 'xy.z'
> Received response: 'xy.z'
> Received response: 'xy.z'
> Received response: 'xy.z'
> Received response: 'xy.z'
> Received response: 'xy.z'
> Received response: 'XY.X'
> Received response: 'XY.X'
> Received response: 'XY.X'
> Received response: 'XY.X'
> Received response: 'XY.X'
> Received response: 'XY.X'
> Received response: 'XY.X'
> Received response: 'XY.X'
> Received response: 'XY.X'
> Received response: 'XY.X'
> 
> result 3 - missing messages:
> 
> Received response: 'xy.z'
> Received response: 'xy.z'
> Received response: 'xy.z'
> Received response: 'xy.z'
> Received response: 'xy.z'
> Received response: 'xy.z'
> Received response: 'xy.z'
> Received response: 'xy.z'
> Received response: 'xy.z'
> Received response: 'xy.z'
> 
> 
> 
> ------------------------------------------------------------------------
> 
> _______________________________________________
> zeromq-dev mailing list
> zeromq-dev at lists.zeromq.org
> http://lists.zeromq.org/mailman/listinfo/zeromq-dev




More information about the zeromq-dev mailing list