Introduction
In Chapter 1st, we mentioned three IP addresses: unicast address, broadcast address, and multicast address. This chapter introduces broadcast and multicast in more detail.
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. Figure 12-1 illustrates this process.
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: 00: 00 in hexadecimal format: 00 (the Ethernet broadcast address FF: FF can be considered as a special case of the 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. These 30 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.
12.2 Broadcast
In Figure 3-9, four IP address broadcast addresses are available.
12.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. However, routed (see section 10.3) 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.
12.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.
12.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.
12.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 by 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] It is considered that 4.2bsd uses an unstandard 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.
12.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 binary IP addresses of 32bit. 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 (Chapter 1). 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 IP address 255.255.255.255 is found in the routing table, 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 (see the preceding figure) and receive responses from all hosts on the Ethernet. Each interface associated with the subnet broadcast address is the value of the command ifconfig (see section 3.8. If we ping the address, the expected result is:
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.
As mentioned in section 6.3, this broadcast type receives all hosts, including the sending host, in the LAN. Therefore, you can see that, apart from receiving replies from other hosts in the network, you also receive a response 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. In section 4.5, we introduce the recipient of an ARP request (sun in this example, add the IP address and physical address of the request host to the ARP cache. This is based on the assumption that 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? (TFTP will be detailed in chapter 15th .)
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 a UDP datagram 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 (see Appendix E ).
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.
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 ICMP Echo Request) is forwarded by each vro on the path like a normal datagram. They do not know that the transmitted data is actually broadcast data. 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.
12.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)
The customer's request to the server. For example, the diskless workstation needs to determine to start the boot server. Currently, this service is provided through broadcast (just as BOOTP in chapter 16th), but using Multicast can reduce the burden of not providing this service host.
12.4.1 multicast group address
Figure 1 2-2 shows the format of class d ip addresses.
Unlike the other three types of IP addresses (A, B, and C) shown in Figure 1-5, the allocated 28bits are used as multicast group numbers instead of other IP addresses.
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 RFC allocated numbers. 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 the subnet", and 224.0.0.2 represents "All router groups in the 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 (see section 10.5), and 224.0.1.2 is used as the dogfight application of SGI.
12.4.2 conversion from multicast addresses to Ethernet addresses
Iana has an ethernet address block, that is, the high 24-bit value is 00: 00: 5E (expressed in hexadecimal notation), which means that the address block has the address range from 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 12-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.
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 "multiclass cast (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 addresses to 48-bit hardware addresses 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 notify their IP layer of 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 "joining a multicast group" (the reason for using the "receiving process" in the plural form is that for a specific multicast information, 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), which is introduced in the next chapter.
12.4.3 The process of ing the same D-class IP address to a 48-bit FDDI address in the multicast FDDI network of the fddi and the Lingling ring network [Katz 1990]. The wildcard ring network usually uses different address ing methods because of the restrictions in most Token control.
Broadcast is to send a datagram to all hosts on the Network (usually a local network), while multicast is to send the datagram to a host group on the network. The basic points of these two concepts are that different types of filters are used when data frames are received and sent to the previous protocol stack. Each protocol layer can discard the datagram for different reasons.
Currently, there are four types of broadcast addresses: Restricted broadcast, network broadcast, subnet broadcast, and all subnet broadcast. The most commonly used broadcast is to point to the subnet. Restricted broadcasts are generally used only when the system is initially started.
It is often because the router does not understand the subnet mask of the destination network. The results are related to a variety of factors, such as the broadcast address type and configuration parameters.
Class d ip addresses are called Multicast Group addresses. By ing its low-position 23bit to the corresponding ethernet address, you can convert multicast addresses to Ethernet addresses. Because address ing is not unique, other protocols are required to implement additional datagram filtering.