Main index | Section 4 | Options |
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <netinet/ip_mroute.h>
#include <netinet/pim.h>
PIM-SM is a multicast routing protocol that can use the underlying unicast routing information base or a separate multicast-capable routing information base. It builds unidirectional shared trees rooted at a Rendezvous Point (RP) per group, and optionally creates shortest-path trees per source.
PIM-DM is a multicast routing protocol that uses the underlying unicast routing information base to flood multicast datagrams to all multicast routers. Prune messages are used to prevent future datagrams from propagating to routers with no group membership information.
Both PIM-SM and PIM-DM are fairly complex protocols, though PIM-SM is much more complex. To enable PIM-SM or PIM-DM multicast routing in a router, the user must enable multicast routing and PIM processing in the kernel (see SYNOPSIS about the kernel configuration options), and must run a PIM-SM or PIM-DM capable user-level process. From developer's point of view, the programming guide described in the Programming Guide section should be used to control the PIM processing in the kernel.
/* IPv4 */ int v = 1; /* 1 to enable, or 0 to disable */ setsockopt(mrouter_s4, IPPROTO_IP, MRT_PIM, (void *)&v, sizeof(v));
/* IPv6 */ int v = 1; /* 1 to enable, or 0 to disable */ setsockopt(mrouter_s6, IPPROTO_IPV6, MRT6_PIM, (void *)&v, sizeof(v));
After PIM processing is enabled, the multicast-capable interfaces should be added (see multicast(4)). In case of PIM-SM, the PIM-Register virtual interface must be added as well. This can be accomplished by using the following options:
/* IPv4 */ struct vifctl vc; memset(&vc, 0, sizeof(vc)); /* Assign all vifctl fields as appropriate */ amp;... if (is_pim_register_vif) vc.vifc_flags |= VIFF_REGISTER; setsockopt(mrouter_s4, IPPROTO_IP, MRT_ADD_VIF, (void *)&vc, sizeof(vc));
/* IPv6 */ struct mif6ctl mc; memset(&mc, 0, sizeof(mc)); /* Assign all mif6ctl fields as appropriate */ amp;... if (is_pim_register_vif) mc.mif6c_flags |= MIFF_REGISTER; setsockopt(mrouter_s6, IPPROTO_IPV6, MRT6_ADD_MIF, (void *)&mc, sizeof(mc));
Sending or receiving of PIM packets can be accomplished by opening first a "raw socket" (see socket(2)), with protocol value of IPPROTO_PIM:
/* IPv4 */ int pim_s4; pim_s4 = socket(AF_INET, SOCK_RAW, IPPROTO_PIM);
/* IPv6 */ int pim_s6; pim_s6 = socket(AF_INET6, SOCK_RAW, IPPROTO_PIM);
Then, the following system calls can be used to send or receive PIM packets: sendto(2), sendmsg(2), recvfrom(2), recvmsg(2).
This manual page was written by Pavlin Radoslavov (ICSI).
PIM (4) | February 12, 2007 |
Main index | Section 4 | Options |
Please direct any comments about this manual page service to Ben Bullock. Privacy policy.
“ | Ken Thompson has an automobile which he helped design. Unlike most automobiles, it has neither speedometer, nor gas gauge, nor any of the other numerous idiot lights which plague the modern driver. Rather, if the driver makes a mistake, a giant “?” lights up in the center of the dashboard. “The experienced driver,” says Thompson, “will usually know what's wrong.” | ” |