Boost C++ Libraries: Ticket #6446: Mulicast receiver does not work https://svn.boost.org/trac10/ticket/6446 <p> Quickfast 1.4 uses Boost 1.47.0 to receive FAST Marketdata via Multicast. We are developing an EBS (Eurex) Market Data Feed on Red Hat Linux 5.7 64 Bit. Starting the <a class="missing wiki">InterpretApplication</a> from quickfast no data are received. Starting in parallel a Java based multicast reader, then the data are then received in the <a class="missing wiki">InterpretApplication</a>. I have also tried it with the boost test program: <a href="http://www.boost.org/doc/libs/1_37_0/doc/html/boost_asio/example/multicast/receiver.cpp">http://www.boost.org/doc/libs/1_37_0/doc/html/boost_asio/example/multicast/receiver.cpp</a> with the same behaviour </p> <p> best regards </p> <p> Dieter </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/6446 Trac 1.4.3 chris_kohlhoff Tue, 29 May 2012 01:22:12 GMT status, severity changed; resolution set https://svn.boost.org/trac10/ticket/6446#comment:1 https://svn.boost.org/trac10/ticket/6446#comment:1 <ul> <li><strong>status</strong> <span class="trac-field-old">new</span> → <span class="trac-field-new">closed</span> </li> <li><strong>resolution</strong> → <span class="trac-field-new">worksforme</span> </li> <li><strong>severity</strong> <span class="trac-field-old">Showstopper</span> → <span class="trac-field-new">Problem</span> </li> </ul> <p> Most likely you have multiple network cards and the default route does not match the interface you need to use for the multicast group. You need to either: </p> <ul><li>get your system administrator to add a route for the multicast group that uses the correct device; or </li></ul><ul><li>change your code to use the two-argument join_group constructor that lets you specify the interface. </li></ul><p> Most likely the Java application does the latter. As multicast group subscriptions are system-wide, this makes your application work too. However, the first option is IMHO the preferred approach. </p> Ticket dieer.mayer@… Sun, 10 Jun 2012 21:13:25 GMT <link>https://svn.boost.org/trac10/ticket/6446#comment:2 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/6446#comment:2</guid> <description> <p> Chris, </p> <p> have you tried the testprogramm ? have you understood my problem report ? </p> <p> best regards </p> <p> Dieter </p> </description> <category>Ticket</category> </item> <item> <dc:creator>chris_kohlhoff</dc:creator> <pubDate>Wed, 27 Jun 2012 11:48:04 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/6446#comment:3 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/6446#comment:3</guid> <description> <p> I understood your problem report... The behaviour you describe is consistent with a routing issue. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>anonymous</dc:creator> <pubDate>Wed, 27 Jun 2012 12:26:17 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/6446#comment:4 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/6446#comment:4</guid> <description> <p> Hi, A Java mcast reader wirks fine, a pure C mcast readers works also, only The boost base reader is a problem </p> <p> Best regards Dieter </p> </description> <category>Ticket</category> </item> <item> <dc:creator>chris_kohlhoff</dc:creator> <pubDate>Wed, 27 Jun 2012 12:56:19 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/6446#comment:5 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/6446#comment:5</guid> <description> <p> As I said, it looks like a routing issue. Please note my first comment, in particular: </p> <blockquote> <p> Most likely the Java application [uses the equivalent of the two-argument join_group constructor]. As <em>multicast group subscriptions are system-wide</em>, this makes your application work too. </p> </blockquote> <p> You need to explore one of the two options I outlined in my first comment. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>cgarcia</dc:creator> <pubDate>Wed, 04 Jul 2012 18:40:16 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/6446#comment:6 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/6446#comment:6</guid> <description> <p> Boost examples are wrong, doesn't work in linux for machines with several network interfaces. Proper truly working code snippet for receiving on network interface 1.2.3.4: </p> <blockquote> <p> std::string address_listen = "1.2.3.4"; std::string address_mcast = "224.0.0.0"; unsigned short address_port = 50000; boost::system::error_code ec; boost::asio::ip::address listen_addr = boost::asio::ip::address::from_string(address_listen, ec); boost::asio::ip::address mcast_addr = boost::asio::ip::address::from_string(address_mcast, ec); boost::asio::ip::udp::endpoint listen_endpoint(mcast_addr, address_port); socket.open(listen_endpoint.protocol(), ec); <em> boost::asio::ip::udp::socket socket.set_option(boost::asio::ip::udp::socket::reuse_address(true), ec); socket.bind(listen_endpoint, ec); socket.set_option(boost::asio::ip::multicast::join_group(mcast_addr.to_v4(), listen_addr.to_v4()), ec); </em></p> </blockquote> </description> <category>Ticket</category> </item> <item> <dc:creator>cgarcia</dc:creator> <pubDate>Wed, 04 Jul 2012 18:43:41 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/6446#comment:7 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/6446#comment:7</guid> <description> <p> Sorry for the improper code formatting. Repeated here: </p> <pre class="wiki"> std::string address_listen = "1.2.3.4"; std::string address_mcast = "224.0.0.0"; unsigned short address_port = 50000; boost::system::error_code ec; boost::asio::ip::address listen_addr = boost::asio::ip::address::from_string(address_listen, ec); boost::asio::ip::address mcast_addr = boost::asio::ip::address::from_string(address_mcast, ec); boost::asio::ip::udp::endpoint listen_endpoint(mcast_addr, address_port); socket.open(listen_endpoint.protocol(), ec); // boost::asio::ip::udp::socket socket.set_option(boost::asio::ip::udp::socket::reuse_address(true), ec); socket.bind(listen_endpoint, ec); socket.set_option(boost::asio::ip::multicast::join_group(mcast_addr.to_v4(), listen_addr.to_v4()), ec); </pre> </description> <category>Ticket</category> </item> <item> <dc:creator>chris_kohlhoff</dc:creator> <pubDate>Wed, 04 Jul 2012 23:49:32 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/6446#comment:8 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/6446#comment:8</guid> <description> <p> Thanks for your comment, but the examples are not wrong. The approach shown in the examples works on multi-homed hosts provided you have configured the host's routing table correctly. However, you are correct that the two-argument join_group constructor is a valid alternative (although IMHO not generally preferred) approach, as I indicated in comment 1. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Ludwig Schultze</dc:creator> <pubDate>Sat, 31 Oct 2015 00:19:44 GMT</pubDate> <title>status changed; resolution deleted https://svn.boost.org/trac10/ticket/6446#comment:9 https://svn.boost.org/trac10/ticket/6446#comment:9 <ul> <li><strong>status</strong> <span class="trac-field-old">closed</span> → <span class="trac-field-new">reopened</span> </li> <li><strong>resolution</strong> <span class="trac-field-deleted">worksforme</span> </li> </ul> <p> Request to reopen and fix receiver.cpp. </p> <p> sender.cpp is ok. Like Chris wrote, the routing table of the OS can be used to select the network interface through which to send outgoing multicast traffic. But sending was never the topic of this bug. </p> <p> There might exist operating systems that use the routes for outgoing multicast traffic to also have the network interfaces join multicast groups for incoming traffic. At least Linux is not one of them. </p> <p> As a result, the following does not work on Linux. It is the shell transcript of an attempt to use the kernel routing tables to make receiver.cpp work as suggested by Chris: </p> <pre class="wiki"># MCAST_IP=&lt;your multicast group&gt; # ETH0_IP=&lt;your IP of eth0 network interface&gt; # sudo route add $MCAST_IP dev eth0 # ./receiver $ETH0_IP $MCAST_IP </pre><p> This does not detect multicast packets of group MCAST_IP that arrive at eth0. </p> <p> The packets are only detected if receiver is invoked as </p> <pre class="wiki">./receiver 0.0.0.0 $MCAST_IP </pre><p> but this receives also packets to the same port in all other multicast groups currently joined. Most likely because 0.0.0.0, being IPADDR_ANY, matches all multicast groups. </p> <p> Thanks to cgarcia for sharing the correct code. </p> Ticket