21.8 dg_cli Function Using Multicasting
We modify our dg_cli function from Figure 20.5 by just removing the call to setsockopt. As we said earlier, none of the multicast socket options needs to be set to send a multicast datagram if the default settings for the outgoing interface, TTL, and loopback option are acceptable. We run a modified UDP echo server that joins the allhosts group, then run our program specifying the all-hosts group as the destination address.
macosx % udpcli01 220.127.116.11
from 172.24.37.78: hi there
from 172.24.37.94: hi there
We get a response from both systems on the subnet. They are each running the multicast echo server. Each reply is unicast because the source address of the request, which is used by each server as the destination address of the reply, is a unicast address.
IP Fragmentation and Multicasts
We mentioned at the end of Section 20.4 that most systems do not allow the fragmentation of a broadcast datagram as a policy decision. Fragmentation is fine to use with multicasting, as we can easily verify using the same file with a 2,000-byte line.
macosx % udpcli01 18.104.22.168 < 2000line
from 172.24.37.78: xxxxxxxxxx[...]
from 172.24.37.94: xxxxxxxxxx[...]