1 / 19

Broadcasting & Multicasting with UDP sockets

Broadcasting & Multicasting with UDP sockets. Chap 20, 21. Broadcasting. Introduction. Use of broadcasting to know server address on the local subnet: resource discovery to minimize network traffic on a LAN Internet applications ARP(Address Resolution Protocol) BOOTP(Bootstrap Protocol)

jody
Download Presentation

Broadcasting & Multicasting with UDP sockets

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Broadcasting & Multicastingwith UDP sockets Chap 20, 21

  2. Broadcasting

  3. Introduction • Use of broadcasting • to know server address on the local subnet: resource discovery • to minimize network traffic on a LAN • Internet applications • ARP(Address Resolution Protocol) • BOOTP(Bootstrap Protocol) • NTP(Network Time Protocol) • Routing daemons: broadcast routing table

  4. Broadcast Addresses • Subnet-directed: [subnetid, -1] • most commonly used today • e.g.) ping 203.253.70.255 • Limited broadcast: 255.255.255.255 • All hosts on the same LAN • must not forwarded by a router • Some systems do not understand a subnet-directed broadcast address and only interpret 255.255.255.255 as a broadcast • TFTP and BOOTP use this limited broadcast address to know IP address of its diskless workstation on bootstrapping procedure

  5. Unicast versus Broadcast

  6. Before broadcasting, set SO_BROADCAST socket option 문제점 만일 timeout이 짧다면 ?? SIGALRM signal이 blocked system call (recvfrom) 이외에서 deliver되면 loop을 빠져 나오지 못함 해결방안 1: recvfrom 외에는 ALRM signal이 뜨지 않게 만들자. 즉, signal을 block시킴. (Fig. 20.6, bcast/dgclibcast3.c) 그래도 race condition이 발생할 수 있음 Race Condition: shared data를 여러 process들이 동시에 access할 때 time-dependent error 발생 Case 1: shared data (global variable) among threads Case 2: dealing with signals  signal handler도 일종의 thread로 봐야 dg_cli Function thatbroadcasts bcast/dgclibcast1.c

  7. Correct Solutions for Avoiding Race Condition bcast/dgclibcast5.c

  8. Multicasting

  9. Multicast Address • Multicast(Group) address: IPv4 Class D Addresses • IPv4 • 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

  10. Multicasting in broadcast-capable LANs • Just Map IP address to Ethernet Address • Then, LAN will delivers.

  11. IP Multicasting 특정 Group에 Join해야 수신할 수 있음 Sender는 단지 Group 주소(Class D address)로 하나의 packet을 보냄 Network(즉, 라우터)가 Group에속한 member에게 전달할 책임 있음 (copy는 router 책임) Join/leave a group: IGMP( Internet Group Membership Protocol) Application은 setsockopt() 으로 호출 Multicast Routing Protocol Find multicast tree E.g) PIM, M-OSPF LAN 내부에서의 multicast에는 필요 없음 Multicast Types Any-source Multicast (ASM) (*, G) Source-Specific Multicast (SSM) Similar to TV channels Member may join a channel (S, G) Multicast Protocols

  12. Multicast versus Broadcast

  13. Multicast Session • A multicast session • Defined by (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

  14. Senders: 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. Disable loop back setsockopt(sockfd, IPPROTO_IP, IP_MULTICAST_LOOP, &flag, sizeof(flag)); • Send datagrams to all the members of group G (ASM인 경우) • Sender app: set destination socket addr to (G, port); sendto(); • Sender의 send socket에 꼭 bind할 필요는 없음. Why? • Internet은 Multicast routing protocol에 의해 receiver host들을 담당하는 local router까지의 Multicast tree를 구성함 • When? Dynamic(PIM-SM, PIM-DM, DVMRP, OSPF) or static (shared tree: e,g CBT) • Multicast tree를 따라 중간 라우터는 copy하여 forwarding하고, 결국, local router는 다시 receiver의 host로 forward함

  15. Receivers: Receiving Multicast Datagrams • Join the multicast group • Ask the kernel for joining the 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)); • Kernel joins the Group using IGMP • 이 group G로 보내는 IP multicast packet들이 receiver의 host computer (i.e IP protocol)에게도 보내달라고 Internet (router)에게 요청함 • Bind [the group address and] port for the multicast session • Multicast session (G, port)으로 전달된 packet을 Kernel이 Receiver application의 해당 socket으로 전달하도록 요청 • Receive datagrams: recvfrom()

  16. Multicast Socket Options IPv4, ASM IPv4, SSM IPv6, ASM IPv4/v6, ASM IPv4/v6, SSM

  17. UNP Library For Supporting Protocol-independent Multicast Application

  18. Joining Multicast Group lib/mcast_join.c

  19. Sending and Receiving Multicast Packets mcast/main.c mcast/send.c mcast/recv.c

More Related