Presentation is loading. Please wait.

Presentation is loading. Please wait.

Broadcast and Multicast. Unicast Host 2Host 1 Broadcast Packet received by every host on network (including the sender!)

Similar presentations


Presentation on theme: "Broadcast and Multicast. Unicast Host 2Host 1 Broadcast Packet received by every host on network (including the sender!)"— Presentation transcript:

1 Broadcast and Multicast

2 Unicast Host 2Host 1

3 Broadcast Packet received by every host on network (including the sender!)

4 Multicast Packet received by a selected subset of hosts in the network Root Leaf

5 Broadcast Advantages –Reducing Network Traffic Network Time Protocol (NTP), Route Broadcasts –Resource Discovery ARP, BOOTP

6 Broadcast… Disadvantage –Everybody receives a packet, whether they want it or not. Receving a packet  Interrupting your work and processing the packet.

7 Types of broadcast addresses IP Address can be broken down as {netid, subnetid, hostid} E.g. 130.245.224.19 130.245  Netid 224  subnet id 19  host id

8 Types of broadcast addresses… Subnet-directed broadcast {netid, subnetid, *} E.g. 130.245.224.255 Broadcasts to local subnet. Routers do not forward these types of broadcast.

9 Types of broadcast addresses… All-Subnet broadcast {netid, *, *} E.g. 130.245.255.255 Broadcasts to all subnets under netid Almost never used. May not be allowed for administrative reasons.

10 Types of broadcast addresses… Network directed broadcast {netid, *} For networks without sub-netting Doesn’t exist anymore

11 Types of broadcast addresses… Limited broadcast address {*, *, *} E.g. 255.255.255.255 Older form of Subnet-directed broadcast Broadcasts to local subnet Never forwarded across routers.

12 How broadcast works Sender UDP IPv4 Data Link Receiver UDP IPv4 Data Link UDP IPv4 Data Link X Dest IP = 130.245.224.255 Dest Port = 9999 Dest Ethernet addr ff:ff:ff:ff:ff:ff Port 9999

13 Example Echo from Multiple Servers

14 int sockfd, on=1, len; char recvline[MAXLILNE]; struct sockaddr_in reply_addr, bcastaddr; sockfd = Socket(…); /* Enable broadcast on socket */ Setsockopt(sockfd, SOL_SOCKET,SO_BROADCAST, &on, sizeof(on)); /* Set a receive timeout on socket */ tv.tv_sec = 5; tv.tv_usec = 0; Setsockopt( sockfd, SOL_SOCKET, SO_RCVTIMEO, (void *)&tv, sizeof(tv)); Initialize bcastaddr with IP = 130.245.224.255 and Port = 9999

15 /* Broadcast a Hello */ Sendto(sockfd, “Hello”, strlen(“Hello”), 0, (struct sockaddr *)&bcastaddr, sizeof(bcastaddr)); /* Receive Echos from servers*/ for(;;) { len = sizeof(reply_addr); n = recvfrom (sockfd, recvline, MAXLINE, 0, &reply_addr, &len); if( n < 0) { if (errno == EAGAIN) { printf(“Waited for 5 seconds - exiting\n”); } else { perror(“ERROR”); } exit(0); } recvline[n] = 0; printf(“%s\n”, recvline); }

16 Multicast

17 Multicast addresses Class D address : –224.0.0.0 to 239.255.255.255 Low order 28 bits identify a multicast group id. Link Local addresses : –224.0.0.0 to 224.0.0.255 –Reserved for network maintenance messages –Never forwarded by routers All-hosts group - 224.0.0.1 All-routers group - 224.0.0.2

18 Multicast to Ethernet mapping e 28-bit group ID 01005e Low order 23 bits 32 IP multicast groups map to one Ethernet level multicast group

19 How multicast works Sender UDP IPv4 Data Link Receiver UDP IPv4 Data Link UDP IPv4 Data Link Dest IP = 224.0.1.1 Dest Port = 9999 Dest Ethernet addr 01:00:5e:00:01:01 Port 9999 Join 224.0.1.1 Receive 01:00:5e:00:01:01

20 Managing multicast membership Five Socket options –IP_ADD_MEMBERSHIP Join a multicast group –IP_DROP_MEMBERSHIP Leave a multicast group –IP_MULTICAST_IF Specify a default interface for outgoing multicast –IP_MULTICAST_TTL Specify TTL for outgoing multicast –IP_MULTICAST_LOOP Enable or disable loopback of outgoing multicast

21 WAN Multicast R1 R2 R3 Sender S1 S2 S3 S4 S – subnet R - Router - Receiver


Download ppt "Broadcast and Multicast. Unicast Host 2Host 1 Broadcast Packet received by every host on network (including the sender!)"

Similar presentations


Ads by Google