180 likes | 353 Views
Multicast. Speaker : Sandra Date : 2012-07-18. What is Multicast?. There are three possible ways of data communication among computers: (1) unicast transmission is the sending of messages to a single network destination identified by a unique address.
E N D
Multicast Speaker:Sandra Date:2012-07-18
What is Multicast? • There are three possible ways of data communication among computers: • (1) unicast transmission is the sending of messages to a single network destination identified by a unique address. • (2)broadcast refers to a method of transferring a message to all recipients simultaneously. broadcast unicast
What is Multicast?(con.) • (3) On a multicast network, you can send a single packet of information from one computer for distribution to several other computers, instead of having to send that packet once for every destination. • Also, when you use multicasting to send a packet, you don't need to know the address of everyone who wants to receive the multicast. multicast
Levels of conformance • Level 0 is the "no support for IP Multicasting" level. • Level 1 is the "support for sending but not receiving multicast IP datagrams" level. • Level 2 is the "full support for IP multicasting" level.
Sending Multicast Datagrams • A list of TTL thresholds and their associated scope follows:
The MBone • The purpose of Mbone is to minimize the amount of data required for multipoint audio/video-conferencing. • topology: combination of mesh and star networks. • IP addresses: 224.2.0.0. • routing schemes: DVMRP, MOSPF.
Multicast applications • Many applications transmit the same data at one time to multiple receivers. • Broadcasts of Radio or Video. • Videoconferencing. • Shared Applications. • A network must have mechanisms to support such applications in an efficient manner.
Multicast programming • All of them are handled via two system calls: • setsockopt() (used to pass information to the kernel) . • getsockopt() (to retrieve information regarded multicast behavior).
Multicast programming(con.) • The following are the setsockopt()/getsockopt() function prototypes: • int getsockopt(int s, int level, int optname, void* optval, int* optlen); • int setsockopt(int s, int level, int optname, const void* optval, int optlen);
Multicast programming(con.) • The optnames involved in multicast programming are the following:
IP_MULTICAST_LOOP • You have to decide, as the application writer, whether you want the data you send to be looped back to your host or not. If you plan to have more than one process or user "listening", loopback must be enabled. u_char loop; setsockopt(socket, IPPROTO_IP, IP_MULTICAST_LOOP, &loop, sizeof(loop));
IP_MULTICAST_TTL • if not otherwise specified, multicast datagrams are sent with a default value of 1, to prevent them to be forwarded beyond the local network. To change the TTL to the value you desire (from 0 to 255), put that value into a variable (here I name it "ttl") and write somewhere in your program: u_char ttl; setsockopt(socket, IPPROTO_IP, IP_MULTICAST_TTL, &ttl, sizeof(ttl));
IP_MULTICAST_IF • Usually, the system administrator specifies the default interface multicast datagrams should be sent from. The programmer can override this and choose a concrete outgoing interface for a given socket with this option. struct in_addr interface_addr; setsockopt (socket, IPPROTO_IP, IP_MULTICAST_IF, &interface_addr, sizeof(interface_addr));
IP_ADD_MEMBERSHIP • Recall that you need to tell the kernel which multicast groups you are interested in. • If no process is interested in a group, packets destined to it that arrive to the host are discarded. struct ip_mreq { struct in_addr imr_multiaddr; /* IP multicast address of group */ struct in_addr imr_interface; /* local IP address of interface */ };
IP_DROP_MEMBERSHIP • The process is quite similar to joining a group: struct ip_mreq mreq; setsockopt (socket, IPPROTO_IP, IP_DROP_MEMBERSHIP, &mreq, sizeof(mreq));
Demo • gcc –o mc mc.c • Client:10.21.10.177 • ./mc • Server:10.21.11.138 • ./ms • http://ms11.voip.edu.tw/~sandra/socket/multicast.htm
Reference • Multicast [1][2][3] • Broadcast[1] • Unicast[1] • MBONE[1]