51
CyberData Corporation
930367H
Operations Guide
Appendix C: How to Use the Multicast
Extensions
C.1 Sending IP Multicast Datagrams
Note
The following information is also available at the following site:
http://www.kohala.com/start/mcast.api.txt
IP multicasting is currently supported only on AF_INET sockets of type SOCK_DGRAM and
SOCK_RAW, and only on subnetworks for which the interface driver has been modified to support
multicasting.
To send a multicast datagram, specify an IP multicast address in the range 224.0.0.0 to
239.255.255.255 as the destination address in a sendto() call.
By default, IP multicast datagrams are sent with a time-to-live (TTL) of 1, which prevents them from
being forwarded beyond a single subnetwork. A new socket option allows the TTL for subsequent
multicast datagrams to be set to any value from 0 to 255, in order to control the scope of the
multicasts:
u_char ttl;
setsockopt(sock, IPPROTO_IP, IP_MULTICAST_TTL, &ttl, sizeof(ttl))
Multicast datagrams with a TTL of 0 will not be transmitted on any subnet, but may be delivered
locally if the sending host belongs to the destination group and if multicast loopback has not been
disabled on the sending socket (see below). Multicast datagrams with TTL greater than one may be
delivered to more than one subnet if there are one or more multicast routers attached to the first-hop
subnet. To provide meaningful scope control, the multicast routers support the notion of TTL
"thresholds", which prevent datagrams with less than a certain TTL from traversing certain subnets.
The thresholds enforce the following convention:
multicast datagrams with initial TTL 0 are restricted to the same host
multicast datagrams with initial TTL 1 are restricted to the same subnet
multicast datagrams with initial TTL 32 are restricted to the same site
multicast datagrams with initial TTL 64 are restricted to the same region
multicast datagrams with initial TTL 128 are restricted to the same continent
multicast datagrams with initial TTL 255 are unrestricted in scope.
"Sites" and "regions" are not strictly defined, and sites may be further subdivided into smaller
administrative units, as a local matter. An application may choose an initial TTL other than the ones
listed above. For example, an application might perform an "expanding-ring search" for a network
resource by sending a multicast query, first with a TTL of 0, and then with larger and larger TTLs,
until a reply is received, perhaps using the TTL sequence 0, 1, 2, 4, 8, 16, 32.
The multicast router accompanying this release refuses to forward any multicast datagram with a
destination address between 224.0.0.0 and 224.0.0.255, inclusive, regardless of its TTL. This range of
addresses is reserved for the use of routing protocols and other low-level topology discovery or