- 1 Introduction
- 2 Description
- 3 Enabling the IGMP Code
- 4 Sending Multicast Packets
- 5 IGMP Protocol
- 6 Treck Stack Initialization of the IGMP Protocol
- 7 Limitations
- 8 Function Calls
IP multicasting is the transmission of an IP datagram to a "host group", a set of zero or more hosts identified by a single IP destination address. A host group IP address is a multicast IP address, or class D IP address, where the first 4 bits of the address are 1110. The range of host group IP addresses (class D) are from 18.104.22.168 to 22.214.171.124. Class D addresses starting with 224.0.0.x and 224.0.1.x have been reserved for various permanent assignments (see RFC 1700). The range of addresses between 126.96.36.199 and 188.8.131.52 are local multicast addresses (i.e. they cannot be forwarded beyond the local subnet), and have been reserved for the use of routing protocols and other low-level topology discovery or maintenance protocols, such as gateway discovery and group membership recording. The membership of a host group is dynamic: hosts may join and leave groups at any time. IGMP (Internet Group Management Protocol) is the protocol used by IP hosts to report their multicast group memberships to multicast routers. Local host groups (184.108.40.206 through 220.127.116.11) memberships do not need to be reported, since as indicated above they cannot be forwarded beyond the local subnet. Without the IGMP protocol, a host can send multicast IP datagrams, but cannot receive any.
The following RFC's are implemented in the Treck IGMP implementation:
We will describe the design of the IP multicasting, and the host IP IGMP protocol implementation in the Treck stack in detail.
Enabling the IGMP Code
To compile in the IGMP code you must define TM_IGMP in <trsystem.h>.
Sending Multicast Packets
Sending multicast packets does not require new API functions. The user uses the send and sendto functions on a UDP socket with a multicast IP address destination.
IP Outgoing Interface for Multicast Packets
The user can choose a per socket default interface to send multicast packets by using a new setsockopt() option (IPO_MULTICAST_IF) at the IPPROTO_IP level with the IP address of the outgoing interface as the option value. If the user does not specify a destination interface that way, then a default outgoing interface will be used, if, after having configured the interface, the user specified a system wide one, using the new tfSetMcastInterface() API. Otherwise, the multicast sendto() will fail.
IP TTL for Multicast Packets
By default, the IP layer will send a multicast packet with a TTL value of 1, unless the user changes the default multicast IP ttl value for the socket with setsockopt(). A TTL value of 1, will not allow the multicast IP datagram to be forwarded beyond the local subnet. The option IPO_MULTICAST_TTL at the IPPROTO_IP level has been added to setsockopt(), and getsockopt().
Mapping Multicast Addresses to Layer 2 Hardware Addresses
To enable multicast mapping from the IP multicast address to an Ethernet multicast address, the TM_DEV_MCAST_ENB flag must be set in the tfOpenInterface() flags parameter.
Receiving UDP Multicast Packets
When a UDP datagram whose destination IP address is a multicast address, arrives on an interface from the network, we check that the host is a member of the multicast group on the interface it came in. A host is a member of a group address for a given interface, if it joined that multicast group.
|Note:||In order to receive multicast packets, the user must join a host group.|
Joining a Host Group
To join a host group, a user socket application calls setsockopt with the IPO_ADD_MEMBERSHIP option at the IPPROTO_IP level. The option pointer points to a structure containing the IP host group address and the interface (defined by its IP address). It will return TM_EINVAL if the IP host group address is not a class D address or if there is no interface configured with the IP address stored in the structure. It will return TM_EADDRINUSE if there was a previous successful IPO_ADD_MEMBERSHIP call for that host group on the same interface. Otherwise, this is the first call to IPO_ADD_MEMBERSHIP for the pair. The IP host group address will be added to the interface. In order to enable reception of that multicast address, the Treck stack will call the interface driver specific ioctl() function. The driver specific ioctl() function is called with the TM_DEV_SET_MCAST_LIST flag value, optionPtr pointing to the list of Ethernet multicast addresses corresponding to all the IP host group addresses added so far, and optionLen indicating the number of those Ethernet multicast addresses. We keep track of the list of Ethernet multicast addresses, so that the driver does not have to.
|Note:||In order to receive multicast packets, the user must implement a section in drvIoctlFunc() to create a multicast address from a list of Ethernet addresses, and store that multicast address in the Ethernet chip. (See drvIoctlFunc() for details.)|
Leaving a Host Group
To stop receiving multicast packets for a given host group destination on an interface, the user need to leave that host group on that interface by calling setsockopt with the IPO_DROP_MEMBERSHIP option at the IPPROTO_IP level. The option pointer points to a structure containing the IP host group address, and the interface (defined by its IP address). It will return TM_EINVAL if the IP host group address is not a class D address or if there is no interface configured with the IP address stored in the structure. It will return TM_ENOENT if there is no such host group on the interface. Otherwise, the IP Host group address will be deleted from the interface, and the Treck stack will call the interface driver specific ioctl() to update the list of Ethernet multicast addresses corresponding to the IP host group addresses that have been added and not dropped. The driver specific ioctl() function is called with the TM_DEV_SET_MCAST_LIST flag value, and with optionPtr pointing to the list of Ethernet multicast addresses corresponding to all the IP host group addresses added (and not dropped), and with optionLen indicating the number of those Ethernet multicast addresses. We keep track of the list of Ethernet multicast addresses so that the driver does not have to.
Treck Stack Initialization of the IGMP Protocol
When a new interface is configured, the Treck stack will automatically join the 18.104.22.168 host group on that interface. If RIP is enabled, the Treck stack will also automatically join the 22.214.171.124 host group on that interface.
This implementation is for IP hosts only. It does not include multicast routing.
|Warning:||No loop back of multicast packets is allowed.|