Download presentation
Presentation is loading. Please wait.
Published byGary Allison Modified over 8 years ago
1
Broadcasting & Multicasting with 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
dg_cli Function that broadcasts 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 로 봐야 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
Multicast Protocols 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)
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
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.