Sending IP Multicast Datagrams
CyberData Corporation
930367H
Operations Guide
52
maintenance protocols, such as gateway discovery and group membership reporting. The current
specification for IP multicasting requires this behavior only for addresses 224.0.0.0 and 224.0.0.1; the
next revision of the specification is expected to contain this more general restriction.
Each multicast transmission is sent from a single network interface, even if the host has more than
one multicast-capable interface. (If the host is also serving as a multicast router, a multicast may be
FORWARDED to interfaces other than originating interface, provided that the TTL is greater than 1.)
The system manager establishes the default interface to be used for multicasting as part of the
installation procedure, described below. A socket option is available to override the default for
subsequent transmissions from a given socket:
struct in_addr addr;
setsockopt(sock, IPPROTO_IP, IP_MULTICAST_IF, &addr, sizeof(addr)) where "addr" is the local IP
address of the desired outgoing interface. An address of INADDR_ANY may be used to revert to
the default interface. The local IP address of an interface can be obtained via the SIOCGIFCONF
ioctl. To determine if an interface supports multicasting, fetch the interface flags via the
SIOCGIFFLAGS ioctl and see if the IFF_MULTICAST flag is set. (Normal applications should not
need to use this option; it is intended primarily for multicast routers and other system services
specifically concerned with internet topology.)
If a multicast datagram is sent to a group to which the sending host itself belongs (on the outgoing
interface), a copy of the datagram is, by default, looped back by the IP layer for local delivery.
Another socket option gives the sender explicit control over whether or not subsequent datagrams
are looped back:
u_char loop;
setsockopt(sock, IPPROTO_IP, IP_MULTICAST_LOOP, &loop, sizeof(loop))
where "loop" is 0 to disable loopback, and 1 to enable loopback. This option provides a performance
benefit for applications that may have no more than one instance on a single host (such as a router or
a mail demon), by eliminating the overhead of receiving their own transmissions. It should
generally not be used by applications for which there may be more than one instance on a single
host (such as a conferencing program) or for which the sender does not belong to the destination
group (such as a time querying program).
A multicast datagram sent with an initial TTL greater than 1 may be delivered to the sending host
on a different interface from that on which it was sent, if the host belongs to the destination group on
that other interface. The loopback control option has no effect on such delivery.