My current infrastructure is like this
openwrt router, configured for lan and wifi interface.
lan is only used for software download and
wifi is used only for the wireless routing between the clients (tablets, mobile phones)
custom software running in the router listens to incoming multicast messages in port 225.0.0.38:12345
My intention is to share the message sent from one wireless client to a group of wireless client (can go upto 64 clients) also router custom software also listens to this and process it. Instead of sending this data to each client, i thought multicast is better option, but it is not working at the moment for my needs.
Scenario #1 :- one wireless client is the multicast sender, other wireless clients and router are listeners
-------------------
tab1 (mulitcast server sending messages to 225.0.0.38 12345) - running android multicast app (red color logo)
tab2 (multicast client listening on 225.0.0.38 12345) - running android multicast tester app (blue color logo)
tab3 (multicast client listening on 225.0.0.38 12345) - custom android app written by me
openwrt router (custom multicast client software listening on 225.0.0.38 12345 wlan0 (i tried without hardcore binding - but still the same result)
Observation :- tab2 and tab3 can receive the multicast message properly but openwrt router cant receive.
Scenario#2 :- router is the multicast sender, other wireless clients and linux PC connected on the network (Ethernet) are listener
-----------------
Observation :- PC application (same custom multicast client software without wireless binding wlan0) works as expected.
tab1, tab2, tab3 - nothing received.
Any idea why this is happening, I'm new to OpenWRT and trying my best to get it working, but i think I'm kind of stuck on this ?
Supporting Information
----------------------------
igmpsnooping is running
OpenWrt:/# cat /sys/devices/virtual/net/br-lan/bridge/multicast_snooping
1
<= tried '0' too
echo "0" > /sys/devices/virtual/net/br-lan/bridge/multicast_snooping
br-lan Link encap:Ethernet HWaddr FE:ED:F0:0D:A1:10
inet addr:192.168.1.45 Bcast:192.168.1.255 Mask:255.255.255.0
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:18385 errors:0 dropped:0 overruns:0 frame:0
TX packets:772 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:1886205 (1.7 MiB) TX bytes:54952 (53.6 KiB)
wlan0 Link encap:Ethernet HWaddr 00:11:33:22:44:55
inet addr:11.11.11.1 Bcast:11.11.11.255 Mask:255.255.255.0
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:6139 errors:0 dropped:0 overruns:0 frame:0
TX packets:6215 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:501496 (489.7 KiB) TX bytes:633292 (618.4 KiB)
OpenWrt:/# cat /etc/config/network
config interface 'loopback'
option ifname 'lo'
option proto 'static'
option ipaddr '127.0.0.1'
option netmask '255.0.0.0'
config globals 'globals'
config interface 'lan'
option type 'bridge'
option ifname 'eth0'
option proto 'static'
option netmask '255.255.255.0'
option macaddr 'fe:ed:f0:0d:a1:10'
option ipaddr '192.168.1.45'
option gateway '192.168.1.1'
option dns '192.168.1.250'
option broadcast '192.168.1.255'
config interface 'wifi'
option proto 'static'
option ipaddr '11.11.11.1'
option macaddr 'fe:ed:f0:0d:a1:11'
option netmask '255.255.255.0'
OpenWrt:/# cat /etc/config/wireless
config wifi-device 'radio0'
option type 'mac80211'
option channel '11'
option hwmode '11g'
option path 'platform/ar933x_wmac'
option htmode 'HT20'
option disabled '0'
config wifi-iface
option device 'radio0'
option mode 'ap'
option network 'wifi'
option ssid 'Olimex_Test01_BS'
option encryption 'psk2'
option key 'ZigZag1968'
OpenWrt:/# cat /etc/config/ igmpproxy
config igmpproxy
option quickleave 1
# option verbose [0-2]
config phyint wan
option network wan
option direction upstream
list altnet 192.168.1.0/24
config phyint lan
option network lan
option direction downstream
OpenWrt:/# cat /etc/igmpproxy.conf
quickleave
OpenWrt:/# cat /etc/config/dhcp
config dnsmasq
option domainneeded '1'
option boguspriv '1'
option filterwin2k '0'
option localise_queries '1'
option rebind_protection '1'
option rebind_localhost '1'
option local '/lan/'
option domain 'lan'
option expandhosts '1'
option nonegcache '0'
option authoritative '1'
option readethers '1'
option leasefile '/tmp/dhcp.leases'
option resolvfile '/tmp/resolv.conf.auto'
option localservice '1'
config dhcp 'wifi'
option interface 'wifi'
option start '2'
option limit '64'
option leasetime '12h'
OpenWrt:/# cat /etc/config/firewall
config defaults
option syn_flood 1
option input ACCEPT
option output ACCEPT
option forward REJECT
# Uncomment this line to disable ipv6 rules
# option disable_ipv6 1
config zone
option name lan
list network 'lan'
option input ACCEPT
option output ACCEPT
option forward ACCEPT
config zone
option name wan
list network 'wan'
list network 'wan6'
option input REJECT
option output ACCEPT
option forward REJECT
option masq 1
option mtu_fix 1
config forwarding
option src lan
option dest wan
# We need to accept udp packets on port 68,
config rule
option name Allow-DHCP-Renew
option src wan
option proto udp
option dest_port 68
option target ACCEPT
option family ipv4
# Allow IPv4 ping
config rule
option name Allow-Ping
option src wan
option proto icmp
option icmp_type echo-request
option family ipv4
option target ACCEPT
config rule
option name Allow-IGMP
option src wan
option proto igmp
option family ipv4
option target ACCEPT
# Allow DHCPv6 replies
config rule
option name Allow-DHCPv6
option src wan
option proto udp
option src_ip fc00::/6
option dest_ip fc00::/6
option dest_port 546
option family ipv6
option target ACCEPT
config rule
option name Allow-MLD
option src wan
option proto icmp
option src_ip fe80::/10
list icmp_type '130/0'
list icmp_type '131/0'
list icmp_type '132/0'
list icmp_type '143/0'
option family ipv6
option target ACCEPT
# Allow essential incoming IPv6 ICMP traffic
config rule
option name Allow-ICMPv6-Input
option src wan
option proto icmp
list icmp_type echo-request
list icmp_type echo-reply
list icmp_type destination-unreachable
list icmp_type packet-too-big
list icmp_type time-exceeded
list icmp_type bad-header
list icmp_type unknown-header-type
list icmp_type router-solicitation
list icmp_type neighbour-solicitation
list icmp_type router-advertisement
list icmp_type neighbour-advertisement
option limit 1000/sec
option family ipv6
option target ACCEPT
# Allow essential forwarded IPv6 ICMP traffic
config rule
option name Allow-ICMPv6-Forward
option src wan
option dest *
option proto icmp
list icmp_type echo-request
list icmp_type echo-reply
list icmp_type destination-unreachable
list icmp_type packet-too-big
list icmp_type time-exceeded
list icmp_type bad-header
list icmp_type unknown-header-type
option limit 1000/sec
option family ipv6
option target ACCEPT
# include a file with users custom iptables rules
config include
option path /etc/firewall.user
# allow IPsec/ESP and ISAKMP passthrough
config rule
option src wan
option dest lan
option proto esp
option target ACCEPT
config rule
option src wan
option dest lan
option dest_port 500
option proto udp
option target ACCEPT
custom client software (both with dedicated interface connection - wlan0 and non dedicated it is still the same.
#define GROUP_PORT 12345
#define GROUP_ADDRESS "225.0.0.38"
#define NETWORK_IF_NAME "wlan0"
int main(int argc, char *argv[])
{
struct sockaddr_in addr;
struct ip_mreq mreq;
int hndlSocket, nbytes,addrlen;
char message[32];
u_int allow=1;
struct ifreq ifr;
/* set up destination address */
memset(&addr, 0, sizeof(addr));
addr.sin_family = AF_INET;
addr.sin_addr.s_addr = htonl(INADDR_ANY); /* N.B.: differs from sender */
addr.sin_port = htons(GROUP_PORT);
/* use setsockopt() to request that the kernel join a multicast group */
mreq.imr_multiaddr.s_addr = inet_addr(GROUP_ADDRESS);
mreq.imr_interface.s_addr = htonl(INADDR_ANY);
memset(&ifr, 0, sizeof(struct ifreq));
snprintf(ifr.ifr_name, sizeof(ifr.ifr_name), NETWORK_IF_NAME);
/* create what looks like an ordinary UDP socket */
if ((hndlSocket = socket(AF_INET, SOCK_DGRAM, 0)) < 0)
{
perror("socket"); exit(1);
}
/* allow multiple sockets to use the same PORT number */
else if (setsockopt(hndlSocket, SOL_SOCKET, SO_REUSEADDR, &allow, sizeof(allow)) < 0)
{
perror("Reusing ADDR failed"); exit(1);
}
/* bind to receive address */
else if (bind(hndlSocket, (struct sockaddr *) &addr, sizeof(addr)) < 0)
{
perror("bind"); exit(1);
}
else if (ioctl(hndlSocket, SIOCGIFINDEX, &ifr) < 0)
{
perror("ioctl SIOCGIFINDEX"); exit(1);
}
else if (setsockopt(hndlSocket, SOL_SOCKET, SO_BINDTODEVICE, (void*)&ifr, sizeof(struct ifreq)) < 0)
{
DEBUG_ERROR("setsockopt bind to specified interface(%s) failed(%s)", NETWORK_IF_NAME, strerror(errno)); exit(1);
}
else if (setsockopt(hndlSocket, IPPROTO_IP, IP_ADD_MEMBERSHIP, &mreq, sizeof(mreq)) < 0)
{
perror("setsockopt for multi membership"); exit(1);
}
DEBUG_MIL ("Using multicast address/port %s/%d to listen for incoming message", GROUP_ADDRESS, GROUP_PORT);
/* now just enter a read-print loop */
while (true)
{
addrlen = sizeof(addr);
if ((nbytes=recvfrom(hndlSocket, message, sizeof(message), 0, (struct sockaddr *) &addr, &addrlen)) < 0)
{
perror("recvfrom"); exit(1);
}
puts(message);
}
}