Multicasting and broadcasting

Source: Internet
Author: User
Http://www.cnblogs.com/happyhotty/articles/1874720.html* multicast and broadcast are only used for UDP (TCP is connection-oriented)

* Multicast: transmits data frames to multiple hosts in the multicast group on the same network;
Broadcast: transmits data frames to all hosts on the same network.

* The network adapter determines that the destination address is the physical address of the network adapter or the frame of the broadcast or multicast address, and sends it to the driver;

* Multicast address: the lowest location of 1 in the highest byte (Ethernet): 01: 00: 00: 00: 00: 00
Broadcast address: it can be seen as a special case of multicast addresses (Ethernet): FF

* The emergence of multicast reduces the processing load of hosts that are not interested in applications.

==> Broadcast

* Restricted broadcast address: 255.255.255.255.255. This address is used as the destination address of IP datagram during host configuration;

* Broadcast to the entire network: IP address with host no. 1.

* Broadcast pointing to a subnet: the host number is all 1 and has a specific subnet address.

* Broadcast pointing to all subnets: the address with the subnet number and host number all being 1.

==> Application Support for broadcast:

* Ping: in design, network broadcast (returning unknown hosts) is not supported, but subnet broadcast is supported (unix only, which uses low-level sockets)
If the ARP cache of the sending host is empty, the corresponding party (including its own) of the broadcast will send ARP requests to it before the corresponding party.

* TFTP: broadcast is not supported (information cannot be sent to a broadcast address)

* Broadcast forwarding: It is set by the vro (or in the operating system kernel of the computer that acts as the vro)

==> Multicast

* A Class D address is a multicast address (110 + 28 multicast group numbers). A set of hosts that can receive multicast addresses is called a host group, A host group can span multiple networks.

* Multicast address And ethernet address conversion: IANA allocates half of its ethernet address blocks to multicast addresses (00: 00: 5E: 00: 00: 00-00: 00: 5E: 7f: FF: ff). to specify that the multicast address locates the first byte in 01, the ethernet address corresponding to IP multicast ranges from 01: 00: 5E: 00: 00: 00 to 01: 00: 5E: 7f: FF: ff. You can change the bandwidth of an IP address to a value of 23 at the lower of the Ethernet address.
* The conversion from multicast addresses (Class d ip addresses) to Ethernet addresses is not one-to-one, so Nic or driver filtering is also required.

* Single physical Network Multicast is relatively simple: the multicast process specifies the destination IP address as the multicast address, and the device driver converts it to an ethernet address and then sends it out; the receiving processes in the recipient's host must "join a multicast group" (that is, the notification IP layer, which wants to receive the datagram sent to a multicast address ), when the host receives a multicast data report, it sends a copy to the multicast group process. Multiple processes in a host can belong to the same multicast group.

Broadcast and multicast are only used in UDP. They are very important for applications that need to transmit packets to multiple receivers at the same time. TCP is a connection-oriented protocol, which means there is a connection between two processes (identified by the port number) running on two hosts (determined by the IP address.
Consider the shared channel networks that contain multiple hosts, such as Ethernet. Each Ethernet frame contains the ethernet address (48 bit) of the source host and the target host ). Generally, each Ethernet frame is sent only to a single destination host. The destination address specifies a single receiving interface, which is called unicast ). In this way, the communication between any two hosts does not interfere with other hosts in the network (except in the case of competition for shared channels ).
However, sometimes a host sends frames to all other hosts on the Internet, which is broadcast. You can see this process through ARP and RARP. Multicast (Multicast) is between unicast and broadcast: frames are transmitted only to multiple hosts in multicast groups.
To understand broadcast and multicast, you need to understand the filtering process of frames transmitted by channels by the host.
1
Image Attachment: 1.jpg (, 12.68 K)

First, the network adapter checks the frame transmitted by the channel and determines whether to receive the frame. if it receives the frame, it is transmitted to the device driver. Generally, the network adapter only receives frames whose destination address is the physical address or broadcast address of the network adapter. In addition, most interfaces are set to the hybrid mode, which can receive a copy of each frame. For example, tcpdump uses this mode.
Currently, most NICs are configured to receive frames from multicast addresses or some subnet multicast addresses. For Ethernet, when the maximum byte of the address is set to 1, it indicates that the address is a multicast address, which can be expressed as 01: 00: 00: 00 in hexadecimal format: 00: 00 (Ethernet broadcast address FF: FF can be considered as a special case of Ethernet multicast address ).
If the network adapter receives a frame, the frame is sent to the device driver (if the frame is checked and incorrect, the network adapter discards the frame ). The device driver filters additional frames. First, you must specify the protocol (IP address, ARP, etc.) to be used in the frame type ). Then, perform multicast filtering to check whether the host belongs to the multicast group with the multicast address description.
The device driver then transmits the data frame to the next layer. For example, when the frame type is specified as IP data report, the data is transmitted to the IP layer. The IP address performs more filtering checks based on the source address and destination address in the IP address. If normal, the datagram is transmitted to the next layer (such as TCP or UDP ).
Each time UDP receives a datagram sent by an IP address, it filters the datagram based on the destination port number and sometimes the source port number. If no process uses the destination port number, the datagram is discarded and an ICMP inaccessibility packet is generated (TCP filters the destination port number similarly ). If the UDP datagram has a check and error, it will be discarded.
The problem with broadcast is that it increases the processing load of hosts that are not interested in broadcast data. Take a UDP broadcast application as an example. If there are 50 hosts in the network, but only 20 are involved in the application, each time one of the 20 hosts sends UDP broadcast data, the other 30 hosts have to process these broadcast datagram. The UDP broadcast datagram received will not be discarded until the UDP layer. The three 0 hosts discard UDP broadcast datagram because these hosts do not use this destination port.
The emergence of multicast reduces the processing load of hosts that are not interested in applications. With multicast, the host can join one or more multicast groups. In this way, the network adapter will know which multicast group the host belongs to, and then only receive those multicast frames in the multicast group where the host is located.
1.2 Broadcast
We know four IP address broadcast addresses, which will be described in more detail below.
1.2.1 restricted Broadcast
The restricted broadcast address is 255.255.255.255.255. This address is used for the destination address of the IP datagram during host configuration. At this time, the host may not know the network mask of its network, or even its IP address.
In any case, the vro does not forward a datagram whose destination address is a restricted broadcast address. Such a datagram only appears in the local network.
An unsolved problem is: If a host has multiple interfaces, should a process send a data report to the broadcast address on this site to broadcast the data? If this is not the case, applications that want to broadcast all interfaces on the host must determine all interfaces that support broadcast on the host, and then send a datagram copy to each interface.
Most BSD systems regard zookeeper 255.255 as the broadcast address of the first interface after configuration, and do not provide the ability to transmit data packets to interfaces with broadcast capabilities. No, routed and rwhod (bsdrwho Client Server) are two applications that send UDP datagram to each interface. Both applications use similar startup processes to determine all interfaces on the host and understand which interfaces have broadcast capabilities. At the same time, the broadcast address corresponding to the interface pointing to the network is used as the destination address of the datagram sent to the interface.
Host Requirements RFC does not further involve whether multi-interface hosts should send restricted broadcasts to all interfaces.

1.2.2 broadcast pointing to the network
The broadcast address pointing to the network is the address of host number 1. Class A network broadcast address is netid.0000255, and netid is the network number of Class A network.
A vro must forward the broadcast to the network, but it must also have an option not to forward.

1.2.3 subnet-directed broadcast
The address that points to the subnet's broadcast address. The subnet mask is required for IP addresses that serve as subnet direct broadcast addresses. For example, if the vro receives a datagram sent to 128.1.2.255, when the subnet mask of Class B network 128.1 is 255.255.255.0, this address is the broadcast address pointing to the subnet. However, if the subnet mask is 255.255.254.0, this address is not a broadcast address pointing to the subnet.

1.2.4 broadcast pointing to all subnets
To broadcast to all subnets, you also need to understand the subnet mask of the destination network to distinguish it from the broadcast address that points to the network. The subnet number pointing to the broadcast address of all subnets and the host number is all 1. For example, if the destination subnet mask is 255.255.255.0, the IP address 128.1.255.255 is a broadcast address pointing to all subnets. However, if the network is not divided into subnets, This is a broadcast pointing to the network.
In the current opinion, [almsource 1993] Is that this broadcast is outdated. A better way is to use multicast instead of broadcasting all subnets.
[Almsource 1993] indicates that RFC 922 requires that a broadcast pointing to all subnets be sent to all subnets, but the current Router does not. This is lucky because a host with no subnet mask due to misconfiguration will transmit its local broadcast to all subnets. For example, if a host whose IP address is 128.1.2.3 does not have a subnet mask set, its broadcast address defaults to 128.1.255.255 under normal conditions. However, if the subnet mask is set to 255.255.255.0, the broadcast sent from the misconfigured host points to all subnets.
4.2bsd, which came out in 1983, is the first widely influential TCP/IP implementation. It uses the host number 0 as the wide address. Ien 212 [gurwitz and Hinden 1982] was the first to mention broadcast IP addresses. It uses 1 bits in the host number to represent IP broadcast addresses (Iens is an Internet Test note, it is basically the predecessor of RFC ). RFC 894 [Hornig 1984] considers that 4.2bsd uses an nonstandard broadcast address, but RFC 906 [Finlayson 1984] notices that there is no Internet standard for broadcast addresses. The RFC editor adds a footer in RFC 906 to acknowledge that a standard broadcast address is missing and it is strongly recommended that host number 1 be used as the broadcast address. Although BSD used host number full 1 to represent broadcast addresses, the operating system (known as SunOS 4.x) continued to use non-standard broadcast addresses until the early S.

1.3 broadcast example
How is broadcast transmitted? What about routers and hosts? Unfortunately, this is a difficult question to answer because it depends on the broadcast type, application type, TCP/IP implementation method, and vro configurations.
First, the application must support broadcasting. If
Sun % Ping 255.255.255.255.255
/Usr/etc/Ping: Unknown host has 255.255.255
Broadcast on the local cable. However, it cannot be implemented because there is a program design problem in the application (PING. After receiving an IP address or host name in dotted decimal format, most applications call the inet_addr (3) function to convert the IP addresses into 32-bit binary IP addresses. Assume that the conversion is a host name. If the conversion fails, the database function returns-1 to indicate an error (for example, a character rather than a number or a decimal point in the string ). However, the broadcast address (255.255.255.255) on this website is also treated as an error and-1 is returned. Most programs assume that the received string is the host name, and then look for the DNS. After the failure, an error message is output, such as "unknown host ".
If we fix this deficiency in the Ping program, the results are not always satisfactory. In the test of six different systems, only one broadcast datagram is generated as expected. In most cases, the router table finds the IP address 255.255.255.255, which is used as the default router address. Therefore, a datagram is unicast to the default router. The datagram is discarded.
Broadcast pointing to the subnet should be used. In section 6.3, we send a datagram to the ethernet with the IP address 140.252.13.63 in the test network and receive responses from all the hosts on the Ethernet. Each interface associated with the subnet broadcast address is the value of ifconfig. If we ping the address, the expected result is:

2

Image Attachment: 2.jpg (, 37.41 K)

The IP address is determined by the destination address (140.252.13.63), which is the broadcast address pointing to the subnet and then sends the datagram to the broadcast address at the link layer.
This type of broadcast recipient is all hosts in the LAN, including the sending host. Therefore, you can see that in addition to receiving replies from other hosts in the network, you also receive replies from the sending host (Sun.
In this example, we also show the ARP cache content before and after the ping broadcast address. This shows the interaction between broadcast and ARP. Before the ping command is executed, the ARP cache is empty, and the execution is full (that is, there is an entry in the ARP cache for each host in the network that responds to the echo request ). How does the broadcast address (0 x ffffffff) that we mentioned when the Ethernet data frame is transmitted to the link layer? ARP is not required for data frames sent by the sun host.
If you use tcpdump to observe the ping execution process, you can see that the receiver of the broadcast data frame generates an ARP request to the Sun host before sending its response, because its response is unicast. The recipient of an ARP request (sun in this example) usually adds the IP address and physical address of the request host to the ARP cache in addition to sending an ARP response. This is based on a false assumption: If the requester sends us a datagram, we may also want to send back something to it.
The Ping program we use is special because it uses programming interfaces (in most UNIX implementations, It is a low-level plug-in (rawsocket) that generally allow sending a datagram to a broadcast address. What if I use an application that does not support broadcasting, such as TFTP?

Bsdi % TFTP start customer Program
TFTP> connect 140.252.13.63 indicates the IP address of the server.
TFTP> Get temp. Foo tries to get a file from the server or
TFTP: sendto: Permission denied
TFTP> q u I t terminate the customer Program
In this example, the program immediately produces an error, but does not send any information to the network. The reason for this is that the application interface API provided by the plug-in allows UDP datagram to be sent to the broadcast address only when the process explicitly intends to broadcast. This is mainly to Prevent Users From mistakenly using broadcast addresses (as in this example), but applications do not intend to broadcast.
Before broadcasting UDP datagram, you must set the so_broadcast plug-in option for the application that uses APIs in the plug-in.
Not all systems force this restriction. In some systems, UDP datagram can be broadcast without process instructions. Some systems have more restrictions, and processes with Super User Permissions can be broadcast.
The next question is whether to forward broadcast data. Some system kernels and routers have the option to allow or disable this feature.
If you enable vrobbsdi to forward broadcast data and run the Ping program on the host slip, you can observe the subnet broadcast datagram forwarded by vrobbsdi. Forwarding broadcast datagram means that the router receives broadcast data, determines which interface the destination address broadcasts, and then uses the link layer broadcast to forward the datagram to the corresponding network.

3

Image Attachment: 3.jpg (, 31.78 K)

We can see that the Ping program in the BSD system checks the repeated datagram serial number. DUP is displayed if the datagram with the duplicate serial number appears !, This means that a datagram already exists somewhere, but it is exactly what we expect, because we are sending data to a broadcast address.
We can also perform this experiment from hosts on the network that the broadcast points. Run the Ping program on the host angogh.cx.berkeley.edu (14 hops from our network). If the router sun is set to be able to forward the broadcast to, it will still work normally. In this case, the IP datagram (send an ICMP Echo Request) is forwarded by each vro in the path like a normal datagram, they do not know that broadcast data is actually transmitted. Then, when the last vronetnetb sees host number 63, it forwards it to the vrosun sun. When sun detects that the destination IP address is actually a broadcast address on the connected subnet interface, the data is reported to the corresponding network as a link layer broadcast.
Broadcast is a function that should be used with caution. In many cases, IP multicast has proved to be a better solution.

1.4 Multicast
IP multicast provides two types of services:
1) send data to multiple destination addresses. There are many applications for transmitting information to multiple recipients, such as interactive conference systems and sending emails or news to multiple recipients. If multicasting is not used, most of these applications currently use TCP (send a separate data copy to each destination address ). However, even if multicast is used, some applications may continue to adopt TCP to ensure its reliability.
2) customer requests to the server. For example, the diskless workstation needs to determine to start the boot server. Currently, this service is provided through broadcast, but the use of Multicast can reduce the burden on hosts that do not provide this service.
1.4.1 multicast group address
4. The format of class d ip address is displayed.

Image Attachment: 4.jpg (, 8.53 K)

Multicast Group addresses include up to 4-bit and multicast group numbers with a value of 111 0. They can usually be expressed as the dot decimal number, ranging from 224.0.0.0 to 239.20.255.
A host group is a set of hosts that can receive data sent to a specific multicast group address ). A host group can span multiple networks. Members in the Host group can join or leave the Host group at any time. There is no limit on the number of hosts in the Host group, and hosts that do not belong to a host group can send information to this group.
Some Multicast Group addresses are identified by IANA as well-known addresses. They are also treated as permanent host groups, similar to the well-known ports in TCP and UDP. Similarly, these well-known multicast addresses are listed in the latest allocated numbers of r f c. Note that these multicast addresses represent permanent groups, but their group members are not permanent.
For example, 224.0.0.1 represents "all system groups in this subnet", and 224.0.0. 2 represents "All router groups in this subnet ".
The multicast address 224.0.1.1 is used as the Network Time Protocol NTP, 224.0.0.9 is used as rip-2, and 224.0.1.2 is used as the dogfight application of SGI.
1.4.2 converting multicast addresses to Ethernet addresses
Iana has an ethernet address block, that is, the 24-bit high is 00: 00: 5E (in hexadecimal notation), which means that the address block has an address range of 00: 00: 5E: 00: 00: 00 to 00: 00: 5E: FF: ff. Iana allocates half of them to multicast addresses. To specify a multicast address, the first byte of any ethernet address must be 01, which means that the ethernet address corresponding to IP multicast ranges from 01: 00: 5E: 00: 00: 00 to 01: 00: 5E: 7f: FF: ff.
Here, CSMA/CD or the token network uses the standard Internet bit sequence, which is the same as the bit sequence in the memory. This is also the sequence used by most programmers and system administrators. IEEE documents use this bit Transmission sequence. The assigned numbers RFC provides the differences between these representations.
This address allocation will map 23 bits in the Ethernet multicast address to the IP multicast group number by ing the 23 bits in the multicast group number to the 23 bits in the ethernet address, this process is shown in 12-3.
Since the top 5 bits in the multicast group number are ignored during the ing process, the multicast group corresponding to each Ethernet multicast address is not unique. 32 different multicast group numbers are mapped to an ethernet address. For example, the multicast address 224.128.64.32 (hexadecimal e0.80.40.20) and
224.0.64.32 (hexadecimal e0.00.40.20) are mapped to the same ethernet address 01: 00: 5E: 00: 40: 20.
Since address ing is not unique, the device driver or IP layer (see Figure 1) must filter the datagram. Because the NIC may receive multicast data frames that the host does not want to receive. In addition, if the NIC does not provide sufficient multicast data frame Filtering functions, the device driver must receive all multicast data frames and then filter them.

5

Image Attachment: 5.jpg (, 20.19 K)

The LAN Nic tends to be two processing types: one is that the NIC implements multicast Filtering Based on the hash value of the multicast address, which means that it will still receive multicast data that it does not want to receive; the other is that the NIC only receives some fixed number of multicast addresses, which means that when the host wants to receive multicast addresses that exceed the pre-supported multicast addresses of the NIC, you must set the NIC to the multicast promiscuous mode. Therefore, these two types of NICs still need the device driver to check whether the received frame is actually required by the host.
Even if the network adapter implements perfect multicast filtering (based on the 48-bit hardware address), because the ing from Class d ip address to 48-bit hardware address is not one-to-one, the filtering process is still necessary.
Although address ing is incomplete and hardware filtering is required, multicast is still better than broadcast.
Multicast over a single physical network is simple. Multicast processes specify the destination IP address as the multicast address. The device driver converts the IP address to the corresponding ethernet address and then sends the data. These receiving processes must be aware of their IP layer, the datagram they want to receive to a given multicast address, and the device driver must be able to receive these multicast frames. This process is "add to a multicast group" (the reason for using the "receiving process" in the form of replay is that the multicast information is determined, multiple receivers exist on the same host or multiple hosts, Which is why multicast is used first ). When a host receives a multicast data report, it must send a copy to each process in the multicast group. This is different from the UDP that a single process receives a unicast UDP datagram. When multicast is used, multiple processes may belong to the same multicast group on a host.
When you need to forward multicast data through a vro to expand multicast to a single physical network, the complexity increases. A Protocol is required for the multicast router to understand any host in the identified multicast group in the network. This Protocol is the Internet Group Management Protocol (IGMP ).

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.