[zeromq-dev] PGM multicast
tradermbox-zmq at yahoo.com
tradermbox-zmq at yahoo.com
Mon May 10 01:07:02 CEST 2010
Hi,
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?
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'
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.zeromq.org/pipermail/zeromq-dev/attachments/20100509/c226b449/attachment.htm>
More information about the zeromq-dev
mailing list