Agile FAQs
  About   Slides   Home  

 
Managed Chaos
Naresh Jain's Random Thoughts on Software Development and Adventure Sports
     
`
 
RSS Feed
Recent Thoughts
Tags
Recent Comments

Enabling Multicast on your MacOS (*Unix)

All MacOS kernel are by default capable of sending and receiving multicast datagrams (packets). (So are other kernels in Unix and Linux). However multicasting is not enabled by default. Following are the steps I followed to enable multicast on my Mac (Snow Leopard):

Step 1: Check your network interface supports multicast by running the following command in a terminal window:

$ ifconfig -a
lo0: flags=8049<UP,LOOPBACK,RUNNING,MULTICAST> mtu 16384
inet 127.0.0.1 netmask 0xff000000
inet6 ::1 prefixlen 128
inet6 fe80::1%lo0 prefixlen 64 scopeid 0x1
gif0: flags=8010<POINTOPOINT,MULTICAST> mtu 1280
stf0: flags=0<> mtu 1280
en0: flags=8863<UP,BROADCAST,SMART,RUNNING,SIMPLEX,MULTICAST> mtu 1500
ether 00:26:bb:60:a5:0e
media: autoselect status: inactive
supported media: none autoselect 10baseT/UTP <half-duplex> 10baseT/UTP <full-duplex> 10baseT/UTP <full-duplex,flow-control> 10baseT/UTP <full-duplex,hw-loopback> 100baseTX <half-duplex> 100baseTX <full-duplex> 100baseTX <full-duplex,flow-control> 100baseTX <full-duplex,hw-loopback> 1000baseT <full-duplex> 1000baseT <full-duplex,flow-control> 1000baseT <full-duplex,hw-loopback>
en1: flags=8823<UP,BROADCAST,SMART,SIMPLEX,MULTICAST> mtu 1500

Most important line:
en0: flags=8863<UP,BROADCAST,SMART,RUNNING,SIMPLEX,MULTICAST> mtu 1500

When you see MULTICAST against your network interface, it means your kernel is complied with Multicast option and your network interface supports it.

Step 2: Check if multicast routing is configured:

$netstat -nr
Routing tables

Internet:

Destination Gateway Flags Refs Use Netif Expire
default 192.168.0.1 UGSc 445 0 en0
127 127.0.0.1 UCS 0 0 lo0
127.0.0.1 127.0.0.1 UH 3 840119 lo0
169.254 link#4 UCS 0 0 en0
192.168.0 link#4 UC 2 0 en0
192.168.0.1 0:18:39:8f:69:58 UHLWI 431 46 en0 822
<your_server_ip> 127.0.0.1 UHS 0 0 lo0
192.168.0.255 ff:ff:ff:ff:ff:ff UHLWbI 0 6 en0

Internet6:

Destination Gateway Flags Netif Expire
::1 ::1 UH lo0
fe80::%lo0/64 fe80::1%lo0 Uc lo0
fe80::1%lo0 link#1 UHL lo0
fe80::%en0/64 link#4 UC en0
fe80::217:f2ff:fec9:ac94%en0 0:17:f2:c9:ac:94 UHLW en0
fe80::226:bbff:fe60:a50e%en0 0:26:bb:60:a5:e UHL lo0
ff01::/32 ::1 Um lo0
ff02::/32 ::1 UmC lo0
ff02::/32 link#4 UmC en0

If you don’t see an IP in the range of 224.0.0.0 – 239.255.255.255 in the first table, it means you need to add your desired mutlicast address to your routes table.

Step 3: To add the multicast address:

sudo route -nv add -net 228.0.0.4 -interface en0

Make sure you run this command on all servers you want to be multicast enabled.

Step 4: Using netstat check if the multicast IP is visible in your route table

$ netstat -nr
Routing tables

Internet:

Destination Gateway Flags Refs Use Netif Expire
default 192.168.0.1 UGSc 445 0 en0
127 127.0.0.1 UCS 0 0 lo0
127.0.0.1 127.0.0.1 UH 3 840119 lo0
169.254 link#4 UCS 0 0 en0
192.168.0 link#4 UC 2 0 en0
192.168.0.1 0:18:39:8f:69:58 UHLWI 431 46 en0 822
<your_server_ip> 127.0.0.1 UHS 0 0 lo0
192.168.0.255 ff:ff:ff:ff:ff:ff UHLWbI 0 6 en0
228.0.0.4/32 1:0:5e:0:0:4 UmLS 1 1221 en0

Step 5: Using tcpdump and ping check if your server is able to multicast.

$ sudo tcpdump -ni en0 host 228.0.0.4
tcpdump: verbose output suppressed, use -v or -vv for full protocol decode
listening on en0, link-type EN10MB (Ethernet), capture size 65535 bytes

Run the above command on all the servers.

Run the following command on any one server.

$ ping -t 1 -c 2 228.0.0.4

Now you should see the following line on all the servers that you want multicast enabled.

21:36:01.586800 IP <your_server_ip> > 228.0.0.4: ICMP echo request, id 62506, seq 0, length 64

In future if you want to disable multicast, just drop the IP from Routes Table:

$ sudo route -v delete -inet 228.0.0.4

Multicast over TCP/IP HOWTO is a great reference material if you want to understand Multicast in detail.

Also to enable Multicast on Linux distro refer to: http://www.dancres.org/bjspj/docs/docs/linux.html

  • rabbit

    Hi,
    I have public machine where MULTICAST is enabled (checked ifconfig eth0), but still Tomcat cluster members are not discovering each other.
    I used the route add command and checked route -n, it was added successfully. Still the same error : 'skipping state transfer. No members active in cluster group.'
    What else can I do?

  • What is the operating system on your server? Also what do you get when you
    run tcpdump on one machine and do a ping -t 1 -c 2 228.0.0.4 from another
    server?

  • rabbit

    Hi,
    I have public machine where MULTICAST is enabled (checked ifconfig eth0), but still Tomcat cluster members are not discovering each other.
    I used the route add command and checked route -n, it was added successfully. Still the same error : 'skipping state transfer. No members active in cluster group.'
    What else can I do?

  • What is the operating system on your server? Also what do you get when you
    run tcpdump on one machine and do a ping -t 1 -c 2 228.0.0.4 from another
    server?

  • yournamehere

    nice…thx

  • videyoda

    thank you for taking the time to document this how-to, naresh!


    Licensed under
Creative Commons License