Presentation is loading. Please wait.

Presentation is loading. Please wait.

MULTICAST USING UDP SOCKETS. PRELIMINARIES *CAST Unicast Communication is strictly from one sender to another specified receiver eg: TCP on LAN Broadcast.

Similar presentations


Presentation on theme: "MULTICAST USING UDP SOCKETS. PRELIMINARIES *CAST Unicast Communication is strictly from one sender to another specified receiver eg: TCP on LAN Broadcast."— Presentation transcript:

1 MULTICAST USING UDP SOCKETS

2 PRELIMINARIES

3 *CAST Unicast Communication is strictly from one sender to another specified receiver eg: TCP on LAN Broadcast Communication is strictly from one sender to all other connected receivers eg: ARP on LAN Multicast Communication is from one or more senders to a set of connected clients who have elected to receive

4 ○Efficient if the routers do it (may use hardware capabilities) ○When bandwidth savings are required (up to 1/N of the bandwidth compared to N separate unicast clients) ○Used primarily in streaming media (surveillance, habitat monitoring, etc) MULTICAST APPLICATIONS

5 ○IP MCAST packet is nearly identical to unicast packets ○Uses a special class of destination address (class D) which denotes a specific mcast group □Leading address bits = 1110 in IPv4 and ff00 in IPv6 ○TCP supports just unicast and hence mcast must use UDP MULTICAST PACKETS

6 PROCEDURE

7 ○Multicast clients receive a stream of packets only if they have previously elect to do so from a sender ○This is realized through MCAST group memberships which are dynamic and controlled by receivers ○Routers’ responsibility to learn which sub-networks have active clients with the objective of minimizing packets transmitted ○Once the receivers join a particular IP multicast group, a multicast distribution tree is constructed for that group MULTICAST GROUPS

8  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); ○s = socket (DGRAM/RAW + AF_INET) ○level = IPPROTO_IP ○optname = value passed/returned to/from kernel MULTICAST GROUPS REALIZATION

9 OPTNAME IP_MULTICAST_TTL Dictates time to live and is set to 1 by default to avoid mcast packets from moving beyond local network u_char ttl = 2; setsockopt(socket, IPPROTO_IP, IP_MULTICAST_TTL, &ttl, sizeof(ttl)); IP_MULTICAST_IF Select interface from which mcast packets are sent struct in_addr interface_addr; setsockopt (socket, IPPROTO_IP, IP_MULTICAST_IF, &interface_addr, sizeof(interface_addr)); IP_DROP_MEMBERSHIP Leave an mcast group struct ip_mreq mreq; setsockopt (socket, IPPROTO_IP, IP_DROP_MEMBERSHIP, &mreq, sizeof(mreq)); IP_ADD_MEMBERSHIP fill a ip_mreq structure and inform kernel of your interest to join group struct ip_mreq mreq; setsockopt (socket, IPPROTO_IP, IP_ADD_MEMBERSHIP, &mreq, sizeof(mreq)); IP_MULTICAST_LOOP Decide whether data sent must loopback - Needed if a process is listening u_char loop = 0; setsockopt(socket, IPPROTO_IP, IP_MULTICAST_LOOP, &loop, sizeof(loop));

10 IOCTLS and CAVEATS ○To select outgoing interfaces, ioctls might be useful: □ SIOCGIFADDR (to get an interface's address) □ SIOCGIFCONF (to get the list of all the interfaces) □ SIOCGIFFLAGS (to get an interface's flags and determine if it is multicast capable [IFF_MULTICAST]) ○Alternatively, use ifconfig ○If the host has more than one interface and the IP_MULTICAST_IF option is not set, multicast transmissions are sent from the default interface

11 MULTICAST METHODOLOGY Socket Creation sock = socket(AF_INET, SOCK_DGRAM, 0); Populate Sockaddr_in addr.sin_family = AF_INET; addr.sin_addr.s_addr = htonl(INADDR_ANY); addr.sin_port = htons(MCAST_PORT); Sender addrs.sin_addr.s_addr = inet_addr(MCAST_GROUP); sendto(sock, message, sizeof(message), 0,&addr, addrlen); Receive recvfrom(sock, message, sizeof(message), 0, &addr, &addrlen); Join MCAST group mreq.imr_multiaddr.s_addr = inet_addr(MCAST_GROUP); mreq.imr_interface.s_addr = htonl(INADDR_ANY); setsockopt(sock, IPPROTO_IP, IP_ADD_MEMBERSHIP,&mreq, sizeof(mreq)); 1 2 33 4

12 Experiment 1: One sender and one receiver

13 Experiment 2: Two senders and one receiver

14 Experiment 3: One sender and two receivers

15 ○One sender many receivers work if all on stdlinux ○Many senders and many receivers work if all on stdlinux ○One sender many receivers work if all on RI ○Many senders and many receivers work if all on RI ○Mcast doesn’t work across these networks ○Changing ttl didn’t work ○Used “239.0.0.1” and port 6000 for mcast program ○Attempted different mcast group ips and ports ○Mostly port 22 packets are allowed EXPERIMENTS CONCLUSIONS

16 ROUTING ○Source address used to determine stream direction ○Source of mcast traffic is considered upstream ○Router determines which downstream interfaces are destinations for the mcast group

17 QUESTIONS ○What happens when there are no receivers? Do packets get dropped at the router closest source? ○What are the limits? ○How is security ensured? Didn’t see any authentication mechanism to allow mcast membership join ○Are there any restrictions on which IPs can be used for group identification? If not how do routers figure out where receivers lie? Is it brute force?

18 ○http://www.erg.abdn.ac.uk/users/gorry/course/intro- pages/uni-b-mcast.htmlhttp://www.erg.abdn.ac.uk/users/gorry/course/intro- pages/uni-b-mcast.html ○http://www.tldp.org/HOWTO/Multicast-HOWTO-6.htmlhttp://www.tldp.org/HOWTO/Multicast-HOWTO-6.html ○http://web.cs.wpi.edu/~claypool/courses/4514- B99/samples/multicast.chttp://web.cs.wpi.edu/~claypool/courses/4514- B99/samples/multicast.c ○http://en.wikipedia.org/wiki/IP_multicasthttp://en.wikipedia.org/wiki/IP_multicast ○http://www.cisco.com/c/en/us/support/docs/ip/ip- multicast/16450-mcastguide0.htmlhttp://www.cisco.com/c/en/us/support/docs/ip/ip- multicast/16450-mcastguide0.html REFERENCES


Download ppt "MULTICAST USING UDP SOCKETS. PRELIMINARIES *CAST Unicast Communication is strictly from one sender to another specified receiver eg: TCP on LAN Broadcast."

Similar presentations


Ads by Google