120 likes | 226 Views
Multicasting. Chap 21. Multicast Address. IPv4 Class D Addresses 224.0.0.0 - 239.255.255.255(first 4bit: 1110) Special IPv4 multicast addresses 224.0.0.1 all-hosts group (on a subnet, i.e. link-local) 224.0.0.2 all-routers group (on a subnet, i.e. link-local) IPv6 Multicast Addresses
E N D
Multicasting Chap 21
Multicast Address • IPv4 Class D Addresses • 224.0.0.0 - 239.255.255.255(first 4bit: 1110) • Special IPv4 multicast addresses • 224.0.0.1 all-hosts group (on a subnet, i.e. link-local) • 224.0.0.2 all-routers group (on a subnet, i.e. link-local) • IPv6 Multicast Addresses • ff01::1, ff02::1 all-nodes group (interface-local, link-local) • ff01::2, ff02::2, ff05::2 all-routers group(…, site-local) Scope of multicast addresses
Multicast Session • A multicast session • = (IP multicast addr, UDP port) • Always use different ports • Sometimes use different groups • Audio/video conference may require two multicast sessions • A session for audio • A session for video
Group membership protocol Join/leave a group Application은 setsockopt()으로 호출 E.g) IGMP: Internet Group Membership Protocol Multicast Routing Protocol Find multicast tree LAN 내부에서의 multicast에는 필요 없음 E.g) PIM, M-OSPF Any-source Multicast (ASM) (*, G) Source-Specific Multicast (SSM) Similar to TV channels Member may join a channel (S, G) Multicast Protocols
Sending Multicast Datagrams • Specify interface, TTL, and enable/disable loop back • Default, • Interface for outgoing datagram will be chosen by kernel • TTL or hop limit == 1 • Enable loop back: sender도 보낸 패킷을 받음 • E.g. • setsockopt(sockfd, IPPROTO_IP, IP_MULTICAST_LOOP, &flag, sizeof(flag)); • Then, send datagram to group address and receiver’s port
Receiving Multicast Datagrams • Join the multicast group struct ip_mreq mreq; struct in_addr group_addr; memcpy(&mreq.imr_multiaddr, group_addr, sizeof(group_addr)); setsockopt(sockfd, IPPROTO_IP, IP_ADDMEMBERSHIP, &mreq, sizeof(mreq)); • Bind a port • Receive datagrams
UNP Library For Supporting Protocol-independent Multicast Application
Joining Multicast Group lib/mcast_join.c
Sending and Receiving Multicast Packets mcast/main.c mcast/send.c mcast/recv.c