1 / 32

Broadcasting

Broadcasting. Many networks support the notion of sending a message from one host to all other hosts on the network. A special address called the “broadcast address” is often used. Some popular network services are based on broadcasting (YP/NIS, rup, rusers). Broadcasting.

nardo
Télécharger la présentation

Broadcasting

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 • Many networks support the notion of sending a message from one host to all other hosts on the network. • A special address called the “broadcast address” is often used. • Some popular network services are based on broadcasting (YP/NIS, rup, rusers)

  2. Broadcasting • TCP works only with unicast addresses, UDP supports also broadcasting and multicasting • Multicasting support is optional in IPv4, but mandatory in IPv6 • Broadcasting support is not provided in IPv6; if an IPv4 application uses broadcasting, recode with IPv6 to use multicasting instead of broadcasting

  3. Broadcasting Types of Casting: Unicast: One to One Anycast: a set to one in a set Multicast: a set to all in a set Broadcast: all to all Useful over LAN only, and with UDP

  4. Uses of Broadcasting • Mainly used for resource discovery purposes (server is known to exist in the local subnet, but IP address is not known) • ARP (Address Resolution Protocol) • Broadcast to find MAC address for known IP address – The owner of the IP address is to reply • BOOTP (Bootstrap Protocol) • For a diskless workstation to discover its own IP address, the IP address of a BOOTP server on the network, and a file to be loaded into memory to boot the machine • NTP (Network Time Protocol) • To synchronize time and coordinate time distribution in a large network • Routing Daemons :broadcasts routing table on LAN

  5. Broadcast Address Types • IPv4 address: {netid; subnetid; hostid} • Subnet-directed Broadcast Address: • {netid; subnetid; -1} //-1 means all bits are 1’s • netid = 128.7, subnetid: 6 Broadcast Address: 128.7.6.255 • Normally, routers do not forward these broadcasts • All-subnets-directed Broadcast Address: • {netid; -1; -1} • All subnets on the specified network – very rarely used • Network-directed Broadcast Address: • {netid: -1} • If a network has no subnetting – almost non-existent

  6. Broadcast Address Types • Limited Broadcast Address: • {-1; -1; -1} or 255.255.255.255 • Must never be forwarded by a router • Subnet-directed broadcast and limited broadcast are the most common • Old systems do not understand subnet-directed broadcast • For protocols like BOOTP, 255.255.255.255 is the only option

  7. Unicast Vs Broadcast • In Unicast, only peers participate • In Broadcast, every host on the subnet has to receive the packet and process it up to the transport layer i.e through DL,IP, and UDP • Every non-IP host also must receive at the datalink layer • If broadcast datagrams arrive at higher rate, processing can affect severely the performance

  8. Unicast Sending Appl Receiving Appl Sendto Dest IP: 128.7.6.5 Dest Port: 7433 7433 Port =7433 UDP UDP UDP Protocol =UDP IPv4 IPv4 IPv4 128.7.6.99 = unicast 128.7.6.255 = broadcast 128.7.6.5 = unicast 128.7.6.255 = broadcast Frame type = 0800 Data Link Data Link Data Link 08:00:20:03:f6:42 02:60:8c:2f:4e:00 subnet 128.7.6 Enet hdr IPv4 hdr UDP hdr UDP Data Dest Enet: 08:00:20:03:f6:42 Frame type: 0800 Dest Port: 7433 Dest IP: 128.7.6.5 Protocol: UDP

  9. Broadcast Set SO_BROADCAST option using setsockopt() Sending Appl Receiving Appl sendto Dest IP: 128.7.6.255 Dest Port: 520 520 Port =520 UDP UDP UDP Discard Protocol =UDP Protocol =UDP IPv4 IPv4 IPv4 128.7.6.99 = unicast 128.7.6.255 = broadcast 128.7.6.5 = unicast 128.7.6.255 = broadcast Frame type = 0800 Frame type = 0800 Data Link Data Link Data Link 02:60:8c:2f:4e:00 02:60:20:03:f6:42 subnet 128.7.6 Enet hdr IPv4 hdr UDP hdr UDP Data Dest Enet: ff:ff:ff:ff:ff:ff Frame type: 0800 Dest Port: 520 Dest IP: 128.7.6.255 Protocol: UDP

  10. Programming Requirements • Socket option has to be set with SO_BROADCAST • Setsockopt(sockfd, SOL_SOCKET,SO_BROADCAST,&on,sizeof(on)). • IP Fragmentation: BSD generates EMSGSIZE if size exceeds outgoing MTU

  11. Race Condition • When multiple processes accessing shared data output depends on the execution order of the processes. void dg_cli(…) { setsockopt(sockfd, SOL_SOCKET,SO_BROADCAST,&on,sizeof(on)); signal(SIGALRM, func); while(fgets(…)!=NULL) { sendto(…); alarm(1); for(; ; ) { if (n=recvfrom(…) <0) { if (errno==EINTR) break; else err_sys(…); } else { recvline[n]=0; sleep(1); printf(…); }}} Void func( int signo) { return; } Problem?

  12. Solutions to Race Condition • By Un-blocking and Blocking SIGALRM sigemptyset(&sig1); sigaddset(&sig1, SIGALRM); signal(SIGALRM, func); while(fgets(…) !=NULL)) sendto(…); alarm(5); for(; ; ){ sigprocmask(SIG_UNBLOCK, &sig1,NULL); n=recvfrom(…); sigprocmask(SIG_BLOCK,&sig1, NULL); if(n<0) { if (errno==EINTR) break; else err_sys(…); } else { recvline[n]=0; printf(…); }}} void func(…) {return;} Signal Generation and Delivery is controlled Window is reduced but the problem still persists

  13. 2. pselect can be used with SIGALRM first blocked and then pselect being called with an empty signal set as it’s last argument. pselect, blocking and unblocking being atomic calls, earlier problem does not persist.

  14. Using non-local goto siglongjmp to jump from signal handler to the caller. signal(SIGALRM, func); while (fgets(…)!=NULL) { sendto(…); alarm(5); for(; ;) { if (sigsetjmp(jmpbuf, 1) != 0) break; n=recvfrom(…); recvline[n]=0; printf(…); } void func(…) { siglongjmp(jmpbuf, 1); }

  15. Using IPC from signal handler to function void dg_cli(…) { setsockopt(…); pipe (pipefd); FD_ZERO(&rset); signal(SIGALRM, func); while(fgets(…)!=NULL){ sendto(…); alarm(5); for(; ;) { FD_SET(sockfd, &rset); FD_SET(pipefd[0],&rset); if(n = select (…) <0) { if (errno==EINTR) continue; else err_sys(…); } if (FD_ISSET(sockfd, &rset) ) { recvfrom(…); printf(…); } if (FD_ISSET(pipefd[0], &rset)) { read(pipefd[0], &n, 1); break; } void func(int signo) { write (pipefd[1], “ ”, 1); return;}

  16. Multicasting • IPv4 Class D addresses are multicast addresses • Range 224.0.0.0 to 239.255.255.255 • 32 bit Class D address is called the group address 0 1 2 3 4 5 6 7 0 1 2 3 4 5 6 7 0 1 2 3 4 5 6 7 0 1 2 3 4 5 6 7 0 NET-ID(7b) HOST-ID (24b) 1 0 NET-ID (12b) HOST-ID (14b) 1 1 0 NET-ID (21b) HOST-ID (8b) 1 1 1 0 GROUP-ID (28b) CLASS A: CLASS B: CLASS C: CLASS D:

  17. A mapping from IPv4 multicast addresses to Ethernet addresses is also defined • High order 24 bits always 01:00:5e • 25th bit is 0 • Low order 23 bits from lowest 23 bits of multicast group address • Not one-to-one, many (32) multicast addresses to a single Ethernet address • Broadcasting is normally limited to LANs, whereas Multicasting can be done in LANs or WANs

  18. multicast address • IPv4 class D address • 224.0.0.0 ~ 239.255.255.255 • (224.0.0.1: all hosts group), (224.0.0.2: all-routers group)

  19. Multicast Addresses Scope

  20. Multicast Session • Especially in the case of streaming multimedia, the combination of an IP multicast address (either IPv4 or IPv6) and a transport-layer port (typically UDP) is referred to as a session. • For example, an audio/video teleconference may comprise two sessions; one for audio and one for video. These sessions almost always use different ports and sometimes also use different groups for flexibility in choice when receiving.

  21. Multicast vs Broadcast Sending Appl Receiving Appl sendto Dest IP: 224.0.1.1 Dest Port: 123 123 Port =123 join 224.0.1.1 UDP UDP UDP Protocol =UDP IPv4 IPv4 IPv4 Perfect sw filtering based on dest IP receive 01:00:5e: 00:01:01 Frame type = 0800 Data Link Data Link Data Link Imperfect hw filtering based on dest Enet 02:60:8c:2f:4e:00 02:60:20:03:f6:42 subnet 128.7.6 Enet hdr IPv4 hdr UDP hdr UDP Data Dest Enet: 01:00:5e:00:01:01 Frame type: 0800 Dest Port: 123 Dest IP: 224.0.1.1 Protocol: UDP

  22. Multicasting on a WAN MR1 MR5 MR2 MR4 MR3

  23. Hosts joining a Multicast Group join group H1 MR1 MR5 MRP MRP MRP MRP MR2 MR4 MR3 H2 H3 H4 H5 join group join group join group join group

  24. Sending packets on a WAN join group H1 MR1 MR5 MR2 MR4 MR3 H2 H3 H4 H5 join group join group join group join group

  25. Multicasting • Specifically note that; • All interested multicast routers receive the packets, MR5 does not receive any since there are no interested hosts in its LAN • Packets are put to the specific LAN only if there are hosts in that LAN to receive those packets, MR3 only forwards • Multicast router MR2 both puts packets on its LAN for hosts H2 & H3, and also makes a copy of the packets and forwards them to MR3. • This behavior is something unique to multicast forwarding.

  26. Source-Specific Multicast • Multicasting on a WAN has been difficult to deploy for several reasons. • The biggest problem is that the MRP; needs to get the data from all the senders, which may be located anywhere in the network, to all the receivers, which may similarly be located anywhere. • Another large problem is multicast address allocation: There are not enough IPv4 multicast addresses to statically assign them to everyone who wants one, as is done with unicast addresses.

  27. Source-Specific Multicast • combines the group address with a system's source address, which solves the problems as follows: • The receivers supply the sender's source address to the routers as part of joining the group. • This removes the rendezvous problem from the network, as the network now knows exactly where the sender is. • However, it retains the scaling properties of not requiring the sender to know who all the receivers are. This simplifies multicast routing protocols immensely. • It redefines the identifier from simply being a multicast group address to being a combination of a unicast source and multicast destination (which SSM now calls a channel. • An SSM session is the combination of source, destination, and port

  28. struct ip_mreq { • struct in_addr imr_multiaddr; /* IPv4 class D multicast addr */ • struct in_addr imr_interface; /* IPv4 addr of local interface */ • }; • struct ipv6_mreq { • struct in6_addr ipv6mr_multiaddr; /* IPv6 multicast addr */ • unsigned int ipv6mr_interface; /* interface index, or 0 */ • }; • struct group_req { • unsigned int gr_interface; /* interface index, or 0 */ • struct sockaddr_storage gr_group; /* IPv4 or IPv6 multicast addr */ • }

  29. struct ip_mreq_source { struct in_addr imr_multiaddr; /* IPv4 class D multicast addr */ struct in_addr imr_sourceaddr; /* IPv4 source addr */ struct in_addr imr_interface; /* IPv4 addr of local interface */ }; struct group_source_req { unsigned int gsr_interface; /* interface index, or 0 */ struct sockaddr_storage gsr_group; /* IPv4 or IPv6 multicast addr */ struct sockaddr_storage gsr_source; /* IPv4 or IPv6 source addr */ }

  30. Multicast Socket Options • Use setsockopt() to modify socket options • IP_ADD_MEMBERSHIP • Join a multicast group on a specified local interface • IP_DROP_MEMBERSHIP • Leave a multicast group • IP_MULTICAST_IF • Specify the interface for outgoing multicast datagrams sent on this socket • IP_MULTICAST_TTL • Set the IPv4 TTL parameter (if not specified, default=1) • IP_MULTICAST_LOOP • Enable or disable local loopback (default is enabled)

More Related