LinuxQuestions.org
Register a domain and help support LQ
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 04-08-2016, 05:26 AM   #1
break_da_funk
LQ Newbie
 
Registered: Apr 2016
Posts: 15

Rep: Reputation: Disabled
Unhappy Multicast routing with Quagga Pimd


Hello!
Dears, I will be grateful for help.

I have network configuration like below:

PC1[br0](10.64.50.2) <=> (10.64.50.1)[eth2]PC2[eth0](10.64.48.128) <=> (10.64.48.158)[eth0]PC3

I would like to use PC2 as multicast router and client.

PC2 has Quagga Zebra daemon and Quagga pimd daemon running on.

What have I done so far?
Configured pimd (PC2):
Code:
quagga-pimd-router# show running-config 

Current configuration:
!
hostname quagga-pimd-router
password zebra
enable password zebra
log stdout
!
interface eth0
 ip pim ssm
 ip igmp
!
interface eth2
 ip pim ssm
 ip igmp
!
interface lo
!
interface virbr0
!
!
ip multicast-routing
!
line vty
 exec-timeout 60 0
!
end

Configured zebra (PC2):
Code:
Router# show running-config 

Current configuration:
!
hostname Router
password zebra
enable password zebra
!
interface eth0
 no link-detect
 multicast
 ipv6 nd suppress-ra
!
interface eth2
 no link-detect
 multicast
 ipv6 nd suppress-ra
!
interface lo
 no link-detect
!
interface virbr0
 no link-detect
 ipv6 nd suppress-ra
!
ip forwarding
!
!
line vty
!
end
Routing table (PC2):
Code:
>route
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
default         10.64.48.1      0.0.0.0         UG    0      0        0 eth0
10.64.48.0      *               255.255.255.0   U     1      0        0 eth0
10.64.50.0      *               255.255.255.0   U     1      0        0 eth2
192.168.122.0   *               255.255.255.0   U     0      0        0 virbr0
224.0.0.0       *               240.0.0.0       U     0      0        0 eth2
224.0.0.0       *               240.0.0.0       U     0      0        0 eth0
Multicast features of kernel (PC2):
Code:
>grep -i multicast /boot/config-3.13.0-85-generic
CONFIG_IP_MULTICAST=y
Code:
>grep -i ip_mroute /boot/config-3.13.0-85-generic
CONFIG_IP_MROUTE=y
# CONFIG_IP_MROUTE_MULTIPLE_TABLES is not set
Multicast forwarding (PC2):
Code:
>sysctl -A | grep -i mc_forwarding
sysctl: permission denied on key 'fs.protected_hardlinks'
sysctl: permission denied on key 'fs.protected_symlinks'
sysctl: permission denied on key 'kernel.cad_pid'
sysctl: permission denied on key 'kernel.usermodehelper.bset'
sysctl: permission denied on key 'kernel.usermodehelper.inheritable'
net.ipv4.conf.all.mc_forwarding = 1
net.ipv4.conf.default.mc_forwarding = 0
net.ipv4.conf.eth0.mc_forwarding = 1
net.ipv4.conf.eth2.mc_forwarding = 1
net.ipv4.conf.lo.mc_forwarding = 0
net.ipv4.conf.virbr0.mc_forwarding = 0
sysctl: permission denied on key 'net.ipv4.tcp_fastopen_key'
net.ipv6.conf.all.mc_forwarding = 0
net.ipv6.conf.default.mc_forwarding = 0
net.ipv6.conf.eth0.mc_forwarding = 0
net.ipv6.conf.eth2.mc_forwarding = 0
net.ipv6.conf.lo.mc_forwarding = 0
net.ipv6.conf.virbr0.mc_forwarding = 0
Multicast memberships (PC2):
Code:
>netstat -gn
IPv6/IPv4 Group Memberships
Interface       RefCnt Group
--------------- ------ ---------------------
lo              1      224.0.0.1
eth0            1      224.0.0.13
eth0            1      224.0.0.22
eth0            1      224.0.0.251
eth0            2      224.0.0.1
virbr0          1      224.0.0.251
virbr0          1      224.0.0.1
eth2            1      224.0.0.13
eth2            1      224.0.0.22
eth2            1      224.0.0.251
eth2            2      224.0.0.1
lo              1      ff02::1
lo              1      ff01::1
eth0            1      ff02::fb
eth0            1      ff02::1:ffbc:723d
eth0            1      ff02::1
eth0            1      ff01::1
virbr0          1      ff02::1
virbr0          1      ff01::1
eth2            1      ff02::fb
eth2            1      ff02::1:ff3c:76
eth2            1      ff02::1
eth2            1      ff01::1
When I try to send multicast packets from:
  • PC1 then PC2 doesn't receive multicast packets, PC3 doesn't receive multicast packets.
  • PC2 then PC1 doesn't receive multicast packets, PC3 doesn't receive multicast packets
  • PC3 then PC2 receive multicast packets, PC1 doesn't receive multicast packets

If I remove multicast route for eth2 from routing table (PC2):
Code:
>route del -net 224.0.0.0 netmask 240.0.0.0 dev eth2

>route
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
default         10.64.48.1      0.0.0.0         UG    0      0        0 eth0
10.64.48.0      *               255.255.255.0   U     1      0        0 eth0
10.64.50.0      *               255.255.255.0   U     1      0        0 eth2
192.168.122.0   *               255.255.255.0   U     0      0        0 virbr0
224.0.0.0       *               240.0.0.0       U     0      0        0 eth0
and send multicast packets from:
  • PC1 then PC2 doesn't receive multicast packets, PC3 doesn't receive multicast packets.
  • PC2 then PC1 doesn't receive multicast packets, PC3 receive multicast packets
  • PC3 then PC2 receive multicast packets, PC1 doesn't receive multicast packets

For multicast testing I'm using iperf:
Server:
Code:
>iperf -c 234.5.6.7 -u -T 64 -t 3000 -i 1
Clients:
Code:
>iperf -s -u -B 234.5.6.7 -i 1
PC1 routing table (there are some VLANS and virtual interfaces):
Code:
>route
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
1.1.1.0         *               255.255.255.252 U     0      0        0 br0
2.0.0.0         *               255.0.0.0       U     0      0        0 br0
10.64.42.0      *               255.255.255.0   U     0      0        0 br0
10.64.43.0      *               255.255.255.0   U     0      0        0 br0
10.64.44.0      *               255.255.255.0   U     0      0        0 br0.1
10.64.45.0      *               255.255.255.0   U     0      0        0 br0.0
10.64.50.0      *               255.255.255.0   U     0      0        0 br0
224.0.0.0       *               240.0.0.0       U     0      0        0 br0
PC3 routing table:
Code:
>route
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
10.64.48.0      *               255.255.255.0   U     1      0        0 eth0
link-local      *               255.255.0.0     U     1000   0        0 eth0
224.0.0.0       *               240.0.0.0       U     0      0        0 eth0
eth2 on PC2 is some usb lan card.

Connection between:
PC1 and PC2 is direct
PC2 and PC3 is via switch

Whan am I doing wrong?

Last edited by break_da_funk; 04-08-2016 at 05:38 AM.
 
Old 04-11-2016, 01:56 AM   #2
break_da_funk
LQ Newbie
 
Registered: Apr 2016
Posts: 15

Original Poster
Rep: Reputation: Disabled
_up_
 
Old 04-15-2016, 10:20 AM   #3
pammud
LQ Newbie
 
Registered: Nov 2011
Posts: 4

Rep: Reputation: Disabled
Quagga PIMD doesnt work

Hi,

I have been trying a similar configuration. In your case kernel routing table is atleast getting updated. In my case, I dont see kernel multicast entry at all.
Can you please post these results.
show ip igmp queriers
show ip mroute
show ip igmp groups

what is the quagga version you are using?

Last edited by pammud; 04-15-2016 at 10:22 AM.
 
Old 04-15-2016, 10:22 AM   #4
pammud
LQ Newbie
 
Registered: Nov 2011
Posts: 4

Rep: Reputation: Disabled
what is the quagga version you are using?
 
Old 04-15-2016, 10:30 AM   #5
break_da_funk
LQ Newbie
 
Registered: Apr 2016
Posts: 15

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by pammud View Post
Hi,

I have been trying a similar configuration. In your case kernel routing table is atleast getting updated. In my case, I dont see kernel multicast entry at all.
Can you please post these results.
show ip igmp queriers
show ip mroute
show ip igmp groups

what is the quagga version you are using?
I will let you know on Monday. Today I have free day. I got it work so will post how to make diagnosis.
 
Old 04-15-2016, 11:09 PM   #6
pammud
LQ Newbie
 
Registered: Nov 2011
Posts: 4

Rep: Reputation: Disabled
Quote:
Originally Posted by break_da_funk View Post
I will let you know on Monday. Today I have free day. I got it work so will post how to make diagnosis.
Did you add this entry in PC2 kernel routing table?
224.0.0.0 * 240.0.0.0 U 0 0 0 eth0

I believe PIMD should internally update the PC2 kernel routing table (which is not happening in my testing)
 
Old 04-16-2016, 04:08 AM   #7
break_da_funk
LQ Newbie
 
Registered: Apr 2016
Posts: 15

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by pammud View Post
Did you add this entry in PC2 kernel routing table?
224.0.0.0 * 240.0.0.0 U 0 0 0 eth0

I believe PIMD should internally update the PC2 kernel routing table (which is not happening in my testing)
Yes, I added the route. But I think that PIMD should do the job without route. Pimd is communicating with kernel.
I dropped Quagga PIMD and focused on PIMD (v2.2.0).
Steps to do:
  • Check KERNEL options connected with multicast
  • Turn on IP Forwarding
  • Start PIM Daemon
  • Start sending from PC1 multicast packets (some group)
  • Start receiving packets in PC3

I don't remeber details about steps above but will let You know about them on Monday.
I cannot use Quagga PIMD because it is not released for production so I came back to PIMD 2.2.0.
 
Old 04-16-2016, 09:41 AM   #8
sergeyrar
LQ Newbie
 
Registered: Apr 2016
Posts: 1

Rep: Reputation: Disabled
I don't have much experience with Quagga specifically, but maybe I can help with some multicast issues.

Which version of IGMP are you using?
For PIM SSM to actually work, the host has to specify the source of the multicast stream which is supported only by IGMPv3.

Additionally I think you may have to activate some sort of IGP ( maybe OSPF ) , so that you can reach the source of the multicast stream - so it won't get dropped by RPF.


Do you have some log info regarding dropped multicast traffic?
 
Old 04-18-2016, 03:48 AM   #9
break_da_funk
LQ Newbie
 
Registered: Apr 2016
Posts: 15

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by break_da_funk View Post
  • Check KERNEL options connected with multicast
  • Turn on IP Forwarding
  • Start PIM Daemon
  • Start sending from PC1 multicast packets (some group)
  • Start receiving packets in PC3
  • Required kernel options:
CONFIG_IP_MULTICAST=y
CONFIG_IP_MROUTE=y
CONFIG_IP_PIMSM_V1=y
CONFIG_IP_PIMSM_V2=y

Code:
cat /boot/config-`uname -r` | grep -i ip_mroute
cat /boot/config-`uname -r` | grep -i ip_multicast
cat /boot/config-`uname -r` | grep -i pim
  • Multicast forwarding:
(change from br0 to your interface name)
Code:
cat /proc/sys/net/ipv4/conf/br0/mc_forwarding
  • PIMD config:
Code:
#   This is the configuration file for "pimd", an IP multicast router.
#   pimd looks for it in "/etc/pimd.conf".
#
#   $Id: pimd.conf,v 1.17 2001/09/10 20:31:37 pavlin Exp $
#
#   Command formats:
##########
#phyint br0:0 disable
#phyint br0:1 disable
# default_source_preference <preference>
# default_source_metric <metric>
#
# phyint <local-addr | ifname> [disable|enable]  [threshold <t>] [preference <p>]
#                              [metric <m>]
#                              [altnet <net-addr> masklen <masklen>]
#                              [scoped <net-addr> masklen <masklen>]
#
# cand_rp [<local-addr>] [priority <number> ] [time <number>]
# cand_bootstrap_router [<local-addr>] [priority <number>]
# rp_address <rp-addr> [<group-addr> [masklen <masklen>] [priority <number>]]
#
# group_prefix <group-addr> [masklen <masklen>]
# group_prefix <group-addr> [masklen <masklen>]
# .
# .
# group_prefix <group-addr> [masklen <masklen>]
#
#
# switch_data_threshold [rate <number> interval <number>]
#
# switch_register_threshold [rate <number> interval <number>]
##########
# By default PIM will be activated on all interfaces.  Use phyint to 
# disable on interfaces where PIM should not be run.
#
# Preferences are used by assert elections to determine upstream routers.
# Currently pimd cannot reliably obtain preferences and metrics from the
# unicast routing protocols, so a default preference may be configured.
# In an assert election, the router advertising the lowest assert preference
# will be selected as the forwarder and upstream router for the LAN.
# 101 should be sufficiently high so that asserts from Cisco or GateD
# routers are prefered over poor-little pimd.
#
# It is reccommended that preferences be set such that metrics are never
# consulted.  However, default metrics may also be set and will default to
# 1024.
#
#
# A "phyint" can be specified by either its IP address or interface name.
#
# `preference` and `metric` after "phyint" are used to configure manually
# the default preference and metric for the Assert messages sent on that
# interface. Usually you don't need this, but if you do, think of them
# like `preference` and `metric` defined per iif, but used by the
# Asserts on the oifs.
#
# If you want to add "alternative (sub)net" to a physical interface,
# e.g., if you want to make incoming traffic with a non-local source address
# to appear as it is coming from a local subnet, then use the command:
#   phyint <local-addr | ifname> altnet <net-addr> masklen <len>
# XXX: if you use this command, make sure you know what you are doing!!
#
# If you want administrative scoped multicast filtering, use the
# following command:
#   phyint <local-addr | ifname> scoped <net-addr> masklen <masklen>
# This allows interfaces to be configured as an administrative boundary
# for the specified scoped address. Packets belonging to the scoped
# address will not be forwarded. To use this compile with -DSCOPED_ACL
# option (in Makefile).
# 
# `local-addr` after "cand_rp" and "cand_bootstrap_router" specifies
#  the local address to be used in the Cand-RP and Cand-BSR messages.
#  If not specified, the largest local IP address will be used (excluding
#  the disabled interfaces)
#
# `time` after `cand_rp` specifies how often to send the Cand-RP messages.
#  Its default value should be 60 seconds. Use smaller value for faster
#  convergence.
#
# `group_prefix` is/are the prefix(es) advertised if cand_rp
#
# It is possible to set a static Rendez-Vous Point using the "rp_address"
# setting.  The argument can be either a unicast or a multicast address
# followed by an optional group address and optional masklen to that.
#
# `rate` specifies the minimum rate in bits/s before the last hop
#  router or the RP switch to the shortest path (`switch_data_threshold`
#  and `switch_register_threshold` respectively)
#  `interval` specifies the interval for periodical testing of the rate
#  Currently, `interval` must be at least 5 (seconds)
#  XXX: Both intervals should be the same
#
#
#default_source_preference	101  # smaller is better
#default_source_metric		1024 # smaller is better

# The phyint setting MUST BE AFTER default_source_*,
# BUT MUST BE BEFORE everything else
# By default, all non-loopback multicast capable interfaces are enabled.
#phyint de1 disable

# Smaller value means "higher" priority
cand_rp time 30 priority 20

# Bigger value means  "higher" priority
cand_bootstrap_router priority 5

# Static rendez-vous point
#rp_address 192.168.10.1 224.0.0.0 masklen 8 priority 5

# All multicast groups
group_prefix 224.0.0.0 masklen 4

# 
spt_threshold		rate 50000 interval 20	# 50kbps (approx.)
  • Send/receive multicast packets:

sender.c
Code:
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <time.h>
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>

#define HELLO_PORT 12345
#define HELLO_GROUP "225.0.0.37"

int main(int argc, char *argv[]) {
	struct sockaddr_in addr;
	int fd;
	char message[30];
	memset(message, '\0', 30);
	strcpy(message, "Hello world!");

	if ((fd = socket(AF_INET, SOCK_DGRAM, 0)) < 0) {
		perror("socket");
		exit(1);
	}
	unsigned char ttl = 32;
	setsockopt(fd, IPPROTO_IP, IP_MULTICAST_TTL, &ttl, sizeof(ttl));
	
	memset(&addr, 0, sizeof(addr));
	addr.sin_family = AF_INET;
	addr.sin_addr.s_addr = inet_addr(HELLO_GROUP);
	addr.sin_port = htons(HELLO_PORT);
	double i = 0;
	
	const unsigned short int mes_size = strlen(message) + 10;
	char message_out[mes_size];
	while (1) {
		memset(message_out, '\0', mes_size);
		sprintf(message_out, "[%0.f] %s%c", i++, message, '\0');
		fprintf(stderr, "Message out=%s, length=%d\n", message_out, strlen(message_out));
		if (sendto(fd, message_out, strlen(message_out), 0,
				(struct sockaddr *) &addr, sizeof(addr)) < 0) {
			perror("sendto");
			exit(1);
		}
		sleep(1);
	}
	return 0;
}
listener.c
Code:
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <time.h>
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>

#define HELLO_PORT 12345
#define HELLO_GROUP "225.0.0.37"
#define MSGBUFSIZE 256

int main(int argc, char *argv[]) {
	struct sockaddr_in addr;
	int fd, nbytes;
	size_t addrlen;
	struct ip_mreq mreq;
	char msgbuf[MSGBUFSIZE];

	u_int yes = 1;

	if ((fd = socket(AF_INET, SOCK_DGRAM, 0)) < 0) {
		perror("Create socket");
		exit(1);
	}

	if (setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, &yes, sizeof(yes)) < 0) {
		perror("Reusing ADDR failed");
		exit(1);
	}

	memset(&addr, 0, sizeof(addr));
	addr.sin_family = AF_INET;
	addr.sin_addr.s_addr = htonl(INADDR_ANY);
	addr.sin_port = htons(HELLO_PORT);

	if (bind(fd, (struct sockaddr *) &addr, sizeof(addr)) < 0) {
		perror("Bind");
		exit(1);
	}

	mreq.imr_multiaddr.s_addr = inet_addr(HELLO_GROUP);
	mreq.imr_interface.s_addr = htonl(INADDR_ANY);
	if (setsockopt(fd, IPPROTO_IP, IP_ADD_MEMBERSHIP, &mreq, sizeof(mreq))
			< 0) {
		perror("Set socket option");
		exit(1);
	}

	while (1) {
		addrlen = sizeof(addr);
		memset(msgbuf, '\0', MSGBUFSIZE);
		if ((nbytes = recvfrom(fd, msgbuf, MSGBUFSIZE, 0,
				(struct sockaddr *) &addr, &addrlen)) < 0) {
			perror("Read from socket");
			exit(1);
		}
		puts(msgbuf);
	}
	return 0;
}
Make sure that You start sender/listener on machines with one interface - the programs run with default interfaces. If You want to use multi interface You have to modify sender/listener according to 6.3 point in this document.
It You do steps above and still have problems then You can check:
Code:
> sysctl -A | grep -i mc_forwarding
net.ipv4.conf.all.mc_forwarding = 1
net.ipv4.conf.br0.mc_forwarding = 1
net.ipv4.conf.default.mc_forwarding = 0
net.ipv4.conf.eth0.mc_forwarding = 0
net.ipv4.conf.eth1.mc_forwarding = 0
net.ipv4.conf.lo.mc_forwarding = 0
net.ipv4.conf.pimreg.mc_forwarding = 1
Check multicast packets cache:
Code:
> cat /proc/net/ip_mr_cache 
Group    Origin   Iif     Pkts    Bytes    Wrong Oifs
250000E1 8030400A -1         0        0        0
In example above router (PC2) ip_mr_cache says that kernel receives packets from group 250000E1 = 225.0.0.37 (sender.c) and drops them (Iif = -1). If listener [that is connected to other interface in PC2 than sender] joins to 225.0.0.37 group then PC2 should receives IGMP with the information. After that Iif in ip_mr_cache should change to non negative value (ex 0). In my case there is some gap between sender join and receive IGMP and process it - gap is from 10 to 15 secs).
I hope You will get it work.
 
Old 04-18-2016, 09:27 AM   #10
pammud
LQ Newbie
 
Registered: Nov 2011
Posts: 4

Rep: Reputation: Disabled
Quote:
Originally Posted by break_da_funk View Post
  • Required kernel options:
CONFIG_IP_MULTICAST=y
CONFIG_IP_MROUTE=y
CONFIG_IP_PIMSM_V1=y
CONFIG_IP_PIMSM_V2=y

Code:
cat /boot/config-`uname -r` | grep -i ip_mroute
cat /boot/config-`uname -r` | grep -i ip_multicast
cat /boot/config-`uname -r` | grep -i pim
  • Multicast forwarding:
(change from br0 to your interface name)
Code:
cat /proc/sys/net/ipv4/conf/br0/mc_forwarding
  • PIMD config:
Code:
#   This is the configuration file for "pimd", an IP multicast router.
#   pimd looks for it in "/etc/pimd.conf".
#
#   $Id: pimd.conf,v 1.17 2001/09/10 20:31:37 pavlin Exp $
#
#   Command formats:
##########
#phyint br0:0 disable
#phyint br0:1 disable
# default_source_preference <preference>
# default_source_metric <metric>
#
# phyint <local-addr | ifname> [disable|enable]  [threshold <t>] [preference <p>]
#                              [metric <m>]
#                              [altnet <net-addr> masklen <masklen>]
#                              [scoped <net-addr> masklen <masklen>]
#
# cand_rp [<local-addr>] [priority <number> ] [time <number>]
# cand_bootstrap_router [<local-addr>] [priority <number>]
# rp_address <rp-addr> [<group-addr> [masklen <masklen>] [priority <number>]]
#
# group_prefix <group-addr> [masklen <masklen>]
# group_prefix <group-addr> [masklen <masklen>]
# .
# .
# group_prefix <group-addr> [masklen <masklen>]
#
#
# switch_data_threshold [rate <number> interval <number>]
#
# switch_register_threshold [rate <number> interval <number>]
##########
# By default PIM will be activated on all interfaces.  Use phyint to 
# disable on interfaces where PIM should not be run.
#
# Preferences are used by assert elections to determine upstream routers.
# Currently pimd cannot reliably obtain preferences and metrics from the
# unicast routing protocols, so a default preference may be configured.
# In an assert election, the router advertising the lowest assert preference
# will be selected as the forwarder and upstream router for the LAN.
# 101 should be sufficiently high so that asserts from Cisco or GateD
# routers are prefered over poor-little pimd.
#
# It is reccommended that preferences be set such that metrics are never
# consulted.  However, default metrics may also be set and will default to
# 1024.
#
#
# A "phyint" can be specified by either its IP address or interface name.
#
# `preference` and `metric` after "phyint" are used to configure manually
# the default preference and metric for the Assert messages sent on that
# interface. Usually you don't need this, but if you do, think of them
# like `preference` and `metric` defined per iif, but used by the
# Asserts on the oifs.
#
# If you want to add "alternative (sub)net" to a physical interface,
# e.g., if you want to make incoming traffic with a non-local source address
# to appear as it is coming from a local subnet, then use the command:
#   phyint <local-addr | ifname> altnet <net-addr> masklen <len>
# XXX: if you use this command, make sure you know what you are doing!!
#
# If you want administrative scoped multicast filtering, use the
# following command:
#   phyint <local-addr | ifname> scoped <net-addr> masklen <masklen>
# This allows interfaces to be configured as an administrative boundary
# for the specified scoped address. Packets belonging to the scoped
# address will not be forwarded. To use this compile with -DSCOPED_ACL
# option (in Makefile).
# 
# `local-addr` after "cand_rp" and "cand_bootstrap_router" specifies
#  the local address to be used in the Cand-RP and Cand-BSR messages.
#  If not specified, the largest local IP address will be used (excluding
#  the disabled interfaces)
#
# `time` after `cand_rp` specifies how often to send the Cand-RP messages.
#  Its default value should be 60 seconds. Use smaller value for faster
#  convergence.
#
# `group_prefix` is/are the prefix(es) advertised if cand_rp
#
# It is possible to set a static Rendez-Vous Point using the "rp_address"
# setting.  The argument can be either a unicast or a multicast address
# followed by an optional group address and optional masklen to that.
#
# `rate` specifies the minimum rate in bits/s before the last hop
#  router or the RP switch to the shortest path (`switch_data_threshold`
#  and `switch_register_threshold` respectively)
#  `interval` specifies the interval for periodical testing of the rate
#  Currently, `interval` must be at least 5 (seconds)
#  XXX: Both intervals should be the same
#
#
#default_source_preference	101  # smaller is better
#default_source_metric		1024 # smaller is better

# The phyint setting MUST BE AFTER default_source_*,
# BUT MUST BE BEFORE everything else
# By default, all non-loopback multicast capable interfaces are enabled.
#phyint de1 disable

# Smaller value means "higher" priority
cand_rp time 30 priority 20

# Bigger value means  "higher" priority
cand_bootstrap_router priority 5

# Static rendez-vous point
#rp_address 192.168.10.1 224.0.0.0 masklen 8 priority 5

# All multicast groups
group_prefix 224.0.0.0 masklen 4

# 
spt_threshold		rate 50000 interval 20	# 50kbps (approx.)
  • Send/receive multicast packets:

sender.c
Code:
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <time.h>
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>

#define HELLO_PORT 12345
#define HELLO_GROUP "225.0.0.37"

int main(int argc, char *argv[]) {
	struct sockaddr_in addr;
	int fd;
	char message[30];
	memset(message, '\0', 30);
	strcpy(message, "Hello world!");

	if ((fd = socket(AF_INET, SOCK_DGRAM, 0)) < 0) {
		perror("socket");
		exit(1);
	}
	unsigned char ttl = 32;
	setsockopt(fd, IPPROTO_IP, IP_MULTICAST_TTL, &ttl, sizeof(ttl));
	
	memset(&addr, 0, sizeof(addr));
	addr.sin_family = AF_INET;
	addr.sin_addr.s_addr = inet_addr(HELLO_GROUP);
	addr.sin_port = htons(HELLO_PORT);
	double i = 0;
	
	const unsigned short int mes_size = strlen(message) + 10;
	char message_out[mes_size];
	while (1) {
		memset(message_out, '\0', mes_size);
		sprintf(message_out, "[%0.f] %s%c", i++, message, '\0');
		fprintf(stderr, "Message out=%s, length=%d\n", message_out, strlen(message_out));
		if (sendto(fd, message_out, strlen(message_out), 0,
				(struct sockaddr *) &addr, sizeof(addr)) < 0) {
			perror("sendto");
			exit(1);
		}
		sleep(1);
	}
	return 0;
}
listener.c
Code:
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <time.h>
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>

#define HELLO_PORT 12345
#define HELLO_GROUP "225.0.0.37"
#define MSGBUFSIZE 256

int main(int argc, char *argv[]) {
	struct sockaddr_in addr;
	int fd, nbytes;
	size_t addrlen;
	struct ip_mreq mreq;
	char msgbuf[MSGBUFSIZE];

	u_int yes = 1;

	if ((fd = socket(AF_INET, SOCK_DGRAM, 0)) < 0) {
		perror("Create socket");
		exit(1);
	}

	if (setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, &yes, sizeof(yes)) < 0) {
		perror("Reusing ADDR failed");
		exit(1);
	}

	memset(&addr, 0, sizeof(addr));
	addr.sin_family = AF_INET;
	addr.sin_addr.s_addr = htonl(INADDR_ANY);
	addr.sin_port = htons(HELLO_PORT);

	if (bind(fd, (struct sockaddr *) &addr, sizeof(addr)) < 0) {
		perror("Bind");
		exit(1);
	}

	mreq.imr_multiaddr.s_addr = inet_addr(HELLO_GROUP);
	mreq.imr_interface.s_addr = htonl(INADDR_ANY);
	if (setsockopt(fd, IPPROTO_IP, IP_ADD_MEMBERSHIP, &mreq, sizeof(mreq))
			< 0) {
		perror("Set socket option");
		exit(1);
	}

	while (1) {
		addrlen = sizeof(addr);
		memset(msgbuf, '\0', MSGBUFSIZE);
		if ((nbytes = recvfrom(fd, msgbuf, MSGBUFSIZE, 0,
				(struct sockaddr *) &addr, &addrlen)) < 0) {
			perror("Read from socket");
			exit(1);
		}
		puts(msgbuf);
	}
	return 0;
}
Make sure that You start sender/listener on machines with one interface - the programs run with default interfaces. If You want to use multi interface You have to modify sender/listener according to 6.3 point in this document.
It You do steps above and still have problems then You can check:
Code:
> sysctl -A | grep -i mc_forwarding
net.ipv4.conf.all.mc_forwarding = 1
net.ipv4.conf.br0.mc_forwarding = 1
net.ipv4.conf.default.mc_forwarding = 0
net.ipv4.conf.eth0.mc_forwarding = 0
net.ipv4.conf.eth1.mc_forwarding = 0
net.ipv4.conf.lo.mc_forwarding = 0
net.ipv4.conf.pimreg.mc_forwarding = 1
Check multicast packets cache:
Code:
> cat /proc/net/ip_mr_cache 
Group    Origin   Iif     Pkts    Bytes    Wrong Oifs
250000E1 8030400A -1         0        0        0
In example above router (PC2) ip_mr_cache says that kernel receives packets from group 250000E1 = 225.0.0.37 (sender.c) and drops them (Iif = -1). If listener [that is connected to other interface in PC2 than sender] joins to 225.0.0.37 group then PC2 should receives IGMP with the information. After that Iif in ip_mr_cache should change to non negative value (ex 0). In my case there is some gap between sender join and receive IGMP and process it - gap is from 10 to 15 secs).
I hope You will get it work.


Thanks a ton!!!. I got it working using PIMD v2.3.2.
Quagga PIMD supports only source specific multicast, infact I tried and Quagga PIM daemon got hanged.
 
Old 04-18-2016, 09:33 AM   #11
break_da_funk
LQ Newbie
 
Registered: Apr 2016
Posts: 15

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by pammud View Post
Thanks a ton!!!. I got it working using PIMD v2.3.2.
Quagga PIMD supports only source specific multicast, infact I tried and Quagga PIM daemon got hanged.
My friend discovered that it is good to add all interfaces to pimd.conf - phyinit interface.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
quagga static routing johnmaxwell Linux - Networking 0 02-22-2014 10:45 PM
dynamic routing using quagga laginagesh Linux - Networking 1 06-25-2010 11:28 AM
Problem with RIP routing using Quagga learnlinux2day Linux - Newbie 0 05-18-2009 05:58 AM
Quagga Routing Problems amitabhmca Linux - Networking 1 05-28-2006 11:59 AM
implementing multicast protocol using mrouted or pimd abirami Linux - Networking 0 10-27-2004 11:58 PM


All times are GMT -5. The time now is 08:14 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration