<div>
Hi everyone,
</div><div><br></div><div>I’m seem to be having issues setting up multicast on Raspberry Pi running latest available Raspbian (2015-05-05 Wheezy).</div><div>I have created a minimal viable example to make sure that all the complexity of my software is out of the way.</div><div><br></div><div>First, verifying that multicast is working - on RPi:</div><div><br></div><div><font face="Monaco">iperf -s -u -B 239.0.0.250 -i 1</font></div><div><br></div><div>and on my machine:</div><div><br></div><div><font face="Monaco">iperf -c 239.0.0.250 -u -T 32 -t 3 -i 1</font></div><div><br></div><div>My RPi displays:</div><div><br></div><div><div><font face="Monaco">Server listening on UDP port 5001</font></div><div><font face="Monaco">Binding to local address 239.0.0.250</font></div><div><font face="Monaco">Joining multicast group 239.0.0.250</font></div><div><font face="Monaco">Receiving 1470 byte datagrams</font></div><div><font face="Monaco">UDP buffer size: 160 KByte (default)</font></div><div><font face="Monaco">------------------------------------------------------------</font></div><div><font face="Monaco">[ 3] local 239.0.0.250 port 5001 connected with 10.128.30.104 port 55840</font></div><div><font face="Monaco">[ ID] Interval Transfer Bandwidth Jitter Lost/Total Datagrams</font></div><div><font face="Monaco">[ 3] 0.0- 1.0 sec 79.0 KBytes 647 Kbits/sec 12.543 ms 0/ 55 (0%)</font></div><div><font face="Monaco">[ 3] 1.0- 2.0 sec 169 KBytes 1.39 Mbits/sec 11.075 ms 0/ 118 (0%)</font></div><div><font face="Monaco">[ 3] 2.0- 3.0 sec 51.7 KBytes 423 Kbits/sec 15.568 ms 0/ 36 (0%)</font></div><div><font face="Monaco">[ 3] 3.0- 4.0 sec 83.3 KBytes 682 Kbits/sec 11.260 ms 0/ 58 (0%)</font></div><div><font face="Monaco">[ 3] 0.0- 4.3 sec 386 KBytes 728 Kbits/sec 54.013 ms 0/ 268 (0%)</font></div><div><font face="Monaco">[ 3] 0.0- 4.3 sec 1 datagrams received out-of-order</font></div></div><div><br></div><div>Suggesting that I can receive multicast. This works both ways.</div><div><br></div><div>Here is my Erlang UDP multicast server:</div><div><br></div><div><div><font face="Monaco">-module(udp_multicast).</font></div><div><font face="Monaco"><br></font></div><div><font face="Monaco">-behaviour(gen_server).</font></div><div><font face="Monaco"><br></font></div><div><font face="Monaco">-export([start_link/0, stop/0]).</font></div><div><font face="Monaco">-export([init/1, handle_call/3, handle_cast/2, handle_info/2, code_change/3, terminate/2]).</font></div><div><font face="Monaco"><br></font></div><div><font face="Monaco">start_link() -></font></div><div><font face="Monaco"> gen_server:start_link({local, ?MODULE}, ?MODULE, [], []).</font></div><div><font face="Monaco"><br></font></div><div><font face="Monaco">stop() -> gen_server:cast(?MODULE, stop).</font></div><div><font face="Monaco"><br></font></div><div><font face="Monaco">init([]) -></font></div><div><font face="Monaco"> Port = 6666,</font></div><div><font face="Monaco"> MulticastIp = {239,0,0,251},</font></div><div><font face="Monaco"> IfaceIp = {0,0,0,0},</font></div><div><font face="Monaco"> {ok, OverlaySocket} = gen_udp:open(Port, [ binary,</font></div><div><font face="Monaco"> {ip, MulticastIp},</font></div><div><font face="Monaco"> {multicast_ttl, 4},</font></div><div><font face="Monaco"> {multicast_loop, true},</font></div><div><font face="Monaco"> {broadcast, true},</font></div><div><font face="Monaco"> {add_membership, {MulticastIp, IfaceIp}} ] ),</font></div><div><font face="Monaco"> { ok, OverlaySocket }.</font></div><div><font face="Monaco"><br></font></div><div><font face="Monaco">handle_info({udp, _ClientSocket, _ClientIp, _ClientPort, Msg}, State) -></font></div><div><font face="Monaco"> error_logger:info_msg("Received multicast data: ~p", [ Msg ]),</font></div><div><font face="Monaco"> {noreply, State}.</font></div><div><font face="Monaco"><br></font></div><div><font face="Monaco">handle_call( _, _From, State) -></font></div><div><font face="Monaco"> { reply, ok, State }.</font></div><div><font face="Monaco"><br></font></div><div><font face="Monaco">code_change(_OldVsn, State, _Extra) -></font></div><div><font face="Monaco"> {ok, State}.</font></div><div><font face="Monaco"><br></font></div><div><font face="Monaco">terminate(_, _) -></font></div><div><font face="Monaco"> ok.</font></div><div><font face="Monaco"><br></font></div><div><font face="Monaco">handle_cast(stop, LoopData) -></font></div><div><font face="Monaco"> {noreply, LoopData}.</font></div></div><div><br></div><div>And this is the client I use to push multicast data:</div><div><br></div><div><div><font face="Monaco">-module(mcc).</font></div><div><font face="Monaco"><br></font></div><div><font face="Monaco">-export([run/0]).</font></div><div><font face="Monaco"><br></font></div><div><font face="Monaco">run() -></font></div><div><font face="Monaco"> Port = 6666,</font></div><div><font face="Monaco"> MulticastIp = {239,0,0,251},</font></div><div><font face="Monaco"> IfaceIp = {0,0,0,0},</font></div><div><font face="Monaco"> {ok, OverlaySocket} = gen_udp:open(Port, [ binary,</font></div><div><font face="Monaco"> {ip, MulticastIp},</font></div><div><font face="Monaco"> {multicast_ttl, 4},</font></div><div><font face="Monaco"> {multicast_loop, true},</font></div><div><font face="Monaco"> {broadcast, true},</font></div><div><font face="Monaco"> {add_membership, {MulticastIp, IfaceIp}} ] ),</font></div><div><font face="Monaco"> gen_udp:send( OverlaySocket, MulticastIp, Port, <<"some random datas">> ),</font></div><div><font face="Monaco"> gen_udp:close( OverlaySocket ).</font></div></div><div><br></div><div>If I start the <font face="Monaco">udp_multicast</font> program on my development machine and run <font face="Monaco">mcc</font> from RPi, I receive the data. If I do it the other way around, <font face="Monaco">udp_multicast</font> listening on RPi and <font face="Monaco">mcc</font> run from development box, no data is received on RPi. There’s no firewall in between and the router puts no restriction on multicast.</div>
<div><div>I’m baffled and looking for some ideas where could I start looking for possible cause. These tests have been done with OTP 17.4 and 17.5.</div><div><br></div><div>RPi system details:</div><div><br></div><div><div><font face="Monaco">pi@raspberrypi ~ $ erl</font></div><div><font face="Monaco">Erlang/OTP 17 [erts-6.4] [source] [smp:4:4] [async-threads:10] [kernel-poll:false]</font></div><div><font face="Monaco"><br></font></div><div><font face="Monaco">Eshell V6.4 (abort with ^G)</font></div></div><div><div><font face="Monaco">1> erlang:system_info(system_architecture).</font></div><div><font face="Monaco">"armv7l-unknown-linux-gnueabihf”</font></div></div><div><font face="Monaco"><br></font></div><div><font face="Monaco">> uname -a</font></div><div><font face="Monaco">Linux raspberrypi 3.18.11-v7+ #781 SMP PREEMPT Tue Apr 21 18:07:59 BST 2015 armv7l GNU/Linux</font></div><div><br></div><div>Erlang built from sources using following instructions:</div><div><a href="https://gist.github.com/radekg/93c1ca2c18c34830ac05">https://gist.github.com/radekg/93c1ca2c18c34830ac05</a></div>
<p style="font-family: Helvetica; font-size: 10pt; margin-bottom: 0cm;">
</p><p style="font-family: Helvetica; font-size: 10pt; margin-bottom: 0cm;">
</p><p style="margin-bottom: 0cm;">
</p><p style="margin-bottom: 0cm"><font color="#000000"><font face="Helvetica, sans-serif"><font style="font-size: 9pt">Kind
regards,
<br>Radek
Gruchalski<br>
</font></font></font><font face="Helvetica, sans-serif"><font style="font-size: 9pt"><a href="mailto:radek@gruchalski.com">radek@gruchalski.com</a><a href="mailto:radek@gruchalski.com">
</a></font></font><font color="#0084d1"><font face="Helvetica, sans-serif"><font style="font-size: 9pt"><br></font></font></font><a href="http://de.linkedin.com/in/radgruchalski/"><font color="#0084d1"><font face="Helvetica, sans-serif"><font style="font-size: 9pt">de.linkedin.com/in/radgruchalski/</font></font></font></a><font color="#000000"><font face="Helvetica, sans-serif"><font style="font-size: 9pt"><br><br></font></font></font><font color="#878787"><font face="Helvetica, sans-serif"><font style="font-size: 8pt"><b>Confidentiality:<br></b></font></font></font><font color="#878787"><font face="Helvetica, sans-serif"><font style="font-size: 8pt">This
communication is intended for the above-named person and may be
confidential and/or legally privileged.<br>If it has come to you in
error you must take no action based on it, nor must you copy or show
it to anyone; please delete/destroy and inform the sender
immediately.</font></font></font></p></div>