Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 16 Current »



Address Space

Multicast ip addresses run from 224.0.0.0 - 239.255.255.255. Some of these however are reserved (e.g. 224.0.0.251 for DNS-SD that uses multicast DNS, a.k.a zeroconf). If you’re building your own application, make use of the 239.0.0.0-239.255.255.255  range.

Kernel Support

Confguration is updated by various programs in /etc/resolv.conf. This is managed by systemd-resolved and will get cached & overwritten when pursuing activities like vpn.

$ cat /boot/config-<kernel-version> | grep CONFIG_IP_MULTICAST
CONFIG_IP_MULTICAST=y

Interfaces

Introspection:

# Check if an interface is enabled or not
$ ifconfig enp0s31f6 | grep MULTICAST
enp0s31f6: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500

# Check what multicast groups it is subscribed to
$ ip maddr show enp0s31f6
2:      enp0s31f6
        ....
        inet  239.0.0.1
        inet  224.0.0.251 users 5
        inet  224.0.0.1

# Check all interfaces/group associations
$ netstat -g
IPv6/IPv4 Group Memberships
Interface       RefCnt Group
--------------- ------ ---------------------
lo              1      224.0.0.251
lo              1      all-systems.mcast.net
enp0s31f6       5      224.0.0.251
enp0s31f6       1      all-systems.mcast.net
# Get IP's instead of names
$ netstat -ng
IPv6/IPv4 Group Memberships
Interface       RefCnt Group
--------------- ------ ---------------------
lo              1      224.0.0.251
lo              1      224.0.0.1
enp0s31f6       5      224.0.0.251
enp0s31f6       1      224.0.0.1

Enable/disable:

$ ifconfig eth0 multicast
$ ifconfig eth0 -multicast

Testing

IPerf:

# On the sender side
$ iperf -c 224.0.0.1 -u -T 32 -t 3 -i 1
------------------------------------------------------------
Client connecting to 224.0.0.1, UDP port 5001
Sending 1470 byte datagrams, IPG target: 11215.21 us (kalman adjust)
Setting multicast TTL to 32
UDP buffer size:  208 KByte (default)
------------------------------------------------------------
[  3] local 192.168.1.4 port 44915 connected with 224.0.0.1 port 5001
[ ID] Interval       Transfer     Bandwidth
[  3]  0.0- 1.0 sec   131 KBytes  1.07 Mbits/sec
[  3]  1.0- 2.0 sec   128 KBytes  1.05 Mbits/sec
[  3]  2.0- 3.0 sec   128 KBytes  1.05 Mbits/sec
[  3]  0.0- 3.0 sec   386 KBytes  1.05 Mbits/

# On the listener side
$ iperf -s -u -B 224.0.0.1 -i 1
------------------------------------------------------------
Server listening on UDP port 5001
Binding to local address 224.0.0.1
Joining multicast group  224.0.0.1
Receiving 1470 byte datagrams
UDP buffer size:  208 KByte (default)
------------------------------------------------------------
[  3] local 224.0.0.1 port 5001 connected with 192.168.1.4 port 49386
[ ID] Interval       Transfer     Bandwidth        Jitter   Lost/Total Datagrams
[  3]  0.0- 1.0 sec   129 KBytes  1.06 Mbits/sec   0.189 ms    0/   90 (0%)
[  3]  1.0- 2.0 sec   128 KBytes  1.05 Mbits/sec   0.230 ms    0/   89 (0%)
[  3]  2.0- 3.0 sec   128 KBytes  1.05 Mbits/sec   0.175 ms    0/   89 (0%)
[  3]  0.0- 3.0 sec   386 KBytes  1.05 Mbits/sec   0.182 ms    0/  269 (0%)

Ping 224.0.0.1:

# From kernel 2.6 the ping response from subscribers to multicast groups has been disabled by default.
#   https://0x657573.wordpress.com/2010/11/22/localhost-does-not-response-to-ping-to-multicast-address-224-0-0-1/
# To re-enable
$ echo "0" | sudo tee -a /proc/sys/net/ipv4/icmp_echo_ignore_broadcasts

# Then from the same computer, or another computer on the multicast group
$ ping 224.0.0.1
PING 224.0.0.1 (224.0.0.1) 56(84) bytes of data.
64 bytes from 192.168.1.4: icmp_seq=1 ttl=64 time=0.030 ms

Create MCast Groups

# Create a new mcast group.
# Remember to keep it in the 239.0.0.0-239.255.255.255 range.
$ sudo smcroute -j enp0s31f6 239.0.0.1

# Verify
$ ip maddr show enp0s31f6 
       inet  239.0.0.1
       inet  224.0.0.251 users 5
       inet  224.0.0.1
       inet6 ff02::fb

$ ping 239.0.0.1
PING 239.0.0.1 (239.0.0.1) 56(84) bytes of data.
64 bytes from 192.168.1.4: icmp_seq=1 ttl=64 time=0.031 ms

# Leave
$ sudo smcroute -l enp0s31f6 239.0.0.1

Zeroconf

Uses multicast, typically on IPv4 address 224.0.0.251 or IPv6 address ff02::fb and UDP port 5353.

  • No labels