Hub, it is a device working at the physical layer. Since it is only a device working at the physical layer, it does not care and cannot care about the layers involved in the OSI. Its working mechanism flow is: from a When a port receives a data packet, it will forward the packet once on other ports, because it does not know and cannot know to whom the packet is sent (the physical layer device only cares about the physical concepts of voltage), and it can only respond to all People broadcast (note ①) and let them handle it themselves.
Note 1: The meaning of the word broadcast mentioned here and below is somewhat different from the broadcast in the ARP request. The broadcast here means: the broadcast caused by the use of physical layer forwarding equipment, such as Hub, it can be said that this broadcast is forced , because of equipment problems! It is the broadcast caused by the device forwarding the packet!
The broadcast of the ARP request is self-required and active, because the target address I of the ARP request packet is 255.255.255.255, but the broadcast of the ARP request involves knowledge of the IP layer, which is not within the scope of this article, so it is mentioned here. Broadcast, unless otherwise specified, is the first meaning, that is, “broadcast caused by the device forwarding the data packet”.
In this way, there will be many problems. Others will receive the data you send. There is no such thing as privacy! Others can monitor your information at will! So session hijacking was fairly easy in those days.
Another more serious problem is, if a large-scale local area network, such as 500 machines, are all connected by Hub, what will be the consequences? ?
Quite slow and the network is extremely inefficient! Why?
If 500 machines send a packet, that is to say, each machine needs to receive almost 499 useless packets, and if it needs to respond, the useless data packets will flood the entire LAN, which is the legendary broadcast storm !
To reduce broadcast storms, bridges are created!
Before introducing bridges, I would like to briefly introduce another physical layer device: “repeaters”. The function of this device is to amplify the signal transmitted by the physical layer. Due to long-distance transmission, the signal will have a certain loss. This device mainly solves this problem.
The difference between it and Hub is: Hub is mainly for forwarding data on the physical layer, so it does not care about the size of the voltage value, nor does it amplify the physical signal; while the repeater is used to amplify the signal.
Network Bridge, also known as bridge, data link layer device. It is also a device that forwards data packets, but unlike the Hub, it works at the data link layer. The Hub can only understand things on the physical layer (such as a physical signal), but the bridge can understand some frames. Information (at the link layer, after encapsulating the data passed down above, the encapsulated data is the frame, but here I use the general term “data packet” to replace the professional term “frame”).
On the LAN constructed by Ethernet, the final addressing is identified by the MAC address of the data link layer (that is, the MAC address can be used to find a unique machine on the LAN). The MAC information is extracted from the data packet, and the data packets are forwarded purposefully according to the MAC information, instead of using the broadcast method, which can reduce the occurrence of broadcast storms and improve the efficiency of the entire network.
Switch, a data link layer device, is used to forward data packets. Like a bridge, it also identifies the MAC address in the frame and forwards it to a specific port.
The working principle and difference between bridge and switch
Bridges have only 2 in/out ports, while switches have 8.
At the beginning, because the hardware level was not very developed, in order to improve the efficiency of the local area network and reduce the occurrence of broadcast storms, they produced network bridges, and then they divided a local area network into two, and connected them with bridges in the middle, so that A sent to The data of BCD will no longer be broadcast to EFGH. Only the data packets sent from A to EFGH can pass through the bridge and reach another subnet.
In this way, unnecessary transmission is reduced, and the efficiency of the entire network is also improved a lot! With the development of hardware, there are link layer devices with 4 and 8 ports, which are switches. Because switches can make the network safer and more efficient, switches gradually replace the Hub and become an important device for building a local area network.
Therefore, bridges and switches are basically the same, but there are still some differences when you look closely.
- The working principle of the bridge:
the bridge know which packets should be forwarded and which packets should not be forwarded?
That’s because it has two tables A and B , when a packet comes into port A, the bridge extracts the source MAC address and destination MAC address from the packet.
At the beginning, both table A and table B are empty, and there is no record. At this time, the bridge will forward the data packet to network B, and add a MAC address to table A, indicating that the machine with this MAC address is A subnet. Similarly, when subnet B sends a packet to port B, the bridge will also record the source MAC address to table B.
When the bridge works for a period of time, table A basically records the MAC addresses of all the machines in subnet A, and the same is true for table B. When another data packet is sent from subnet A to the bridge, the bridge will look at it first. Check whether the destination MAC address of the data packet belongs to subnet A or subnet B. If the corresponding one is found in the A table, the packet is discarded; if not, it is forwarded to the B subnet, and then the source MAC address is checked to see if it is in the table. already exists; if not, add a record to table A.
Why do you need two tables? Is one table not enough?
I just divided the table into two for easy understanding. In fact, the real bridge should store one table (of course, it may store information as multiple tables for speedup or other reasons. This It depends on how it is implemented), if it is an information table, the record in the table should be: MAC-PortNum.
- The switch is slightly different
The switch also has a MAC-PORT correspondence table (the scientific name of this table is: CAM). Unlike a bridge, the bridge’s table is one-to-many (one port number to multiple MAC addresses), but the switch’s CAM table is one-to-one.
If a port has a new MAC address, it will not add a new MAC-PORT record, but modify the original record.
For example, there is already an entry in the switch record table: MAC1-Port1. If another data packet comes from port 1 at this moment, the source MAC address in it is MAC2. At this time, the switch will refresh the switch record table: MAC1-Port1 record is modified It is MAC2-Port1, because the switch thinks that the MAC address of the computer on port 1 has changed. If a physical machine is connected to port 1, the MAC generally does not change. If it is connected to another switch, the record of this port will be Changes are frequent (such as Port12 in the figure above, which is an external interface and is connected to a local area network).
In addition, if the record corresponding to the destination MAC address of the data packet is not found in the CAM table, the switch will broadcast the data packet and send it to each port of the switch.
In addition to using the CAM table to guide data packet forwarding, bridges and switches are different from Hubs. Bridges and switches have another feature: caching .
to forward data packets, it may take some time. And the switch appeared cache.
Of course, the cache is not a panacea. When the bridge or switch can’t handle it in time and the cache is used up, the data that comes later will still be lost.
Another reason why a bridge needs to be cached is: bridging two LANs with different transmission rates, for example: 802.3’s transmission rate says 10mb/s, but it’s not really 10Mb/s, and 802.4 is (almost) 10Mb/s s, but the speed of the two LANs must be the same when bridging, otherwise there will be packet loss, and the cache can also be used for network connections of different speeds.
Here we need to compare the cache of the bridge and the switch. Generally speaking, the cache of the bridge is larger than the cache of the switch, because the bridge is born to connect two networks, and the amount of data to be processed when the two networks are bridged will be The amount of data that needs to be processed by the general switch is larger, so the buffer of the bridge is generally larger than that of the switch.
Some issues worth noting:
- Does the bridge need software assistance?
To answer this question, we must first look at the original bridge. There is a passage in “Computer Networks (Fourth Edition)”: Traditionally, bridges often contain a CPU, and “forwarding-storing” is implemented by software . Oh, the previous bridge was like this, but now due to the improvement of the hardware level, the bridge and the switch all contain a special integrated circuit part for forwarding. Now the bridge and switch do not need software assistance! By the way, software that simulates the function of a network bridge is also available now.
- Bridges are used to connect different network segments?
First of all, we need to understand what is a network segment, it involves a series of things such as subnet masks.
Here I think it should be clear that bridges are not used to connect different network segments! ! !
Communication between different network segments requires the help of a gateway, which is generally a network layer device such as a router. A bridge or switch is a link layer device, and a network segment is a concept related to IP and belongs to the network layer.
Bridges and switches are simply not capable of handling network layer stuff! If you have to say that it is not impossible to use bridges and switches to connect two networks on different network segments, it is just useless, because machines on different network segments cannot always access each other, and bridges cannot be used as gateways!
I have already mentioned the origin of the bridge. It is to reduce the broadcast of the Hub and improve the performance of the LAN network. The bridge connects only two sub-LANs, and the sub-LANs mentioned here must be isomorphic (isomorphic). Meaning: If it is Ethernet, then both subnets connected by the bridge must be Ethernet, not one is Ethernet and the other is Tokennet).
I have always believed that the characteristics of Ethernet led to the emergence of bridges, because broadcasting is an important characteristic of Ethernet, and other structured networks may not have them. In order to optimize the performance of Ethernet, bridges appeared. So other construction networks don’t seem to need to use bridges!
In fact, I continued to look at the wireless network with this idea, and found that this idea should be wrong. The nature of the bridge should be: connecting two homogeneous networks . On the Ethernet, it happens that the Hub can be used as a device to connect two networks. However, due to various drawbacks of the Hub, people have developed a bridge working on the link layer. In addition to the function of connecting two networks, there are also optimizations. function of network performance. In other constructed networks, there is also a bridge device, but its function may only be to connect two networks, without the function of optimizing network performance (or according to the characteristics of the network, it has a new function).
Here is another summary of bridges and switches:
The bridge and switch users divide the collision domain, that is, the bridge and the switch can be less forced to broadcast (caused by the Hub), but cannot divide the broadcast domain. Loosely speaking, a switch can be seen as a highly integrated bridge.
①Collision domain: In general, the collision domain is the set of all workstations connected on the same wire, or the set of all nodes on the same physical network segment, or the set of nodes competing for the same bandwidth on the Ethernet. A device such as a Hub cannot divide collision domains.
②Broadcast domain: The set of all devices in the network that can receive broadcast frames sent by any device.
All ports of the Hub are in the same broadcast domain, the collision domain.
All ports of the Switch are in the same broadcast domain, and each port is a collision domain.
Each port of the Router belongs to a different broadcast domain.
ThinkMo CCNA Dump exam information exchange group：
CCNA/CCNP/CCIE telegram study group：https://t.me/ccie_ei_lab
ThinkMo CCNA 200-301 Tutorial VIP Exclusive：
The complete EVE_NG file, free learning PDF and PPT that can be used directly, as well as video explaining the technical points are all here!