BridgeAndVswitchBefore describing the differences, let's take a look at the two images:
1. The connection mode of the bridge: (HUB in the red dot)
2. Switch Connection Mode:
As you can see, the bridge only has two input/output ports, and the switch has eight. Well, yes. At the beginning (there was only a HUB device at that time), people wanted to improve LAN efficiency and reduce the appearance of broadcast storms because the hardware level was not very developed, they produced a bridge layer device with only two input/output ports, and the bridge is already a relatively advanced device). Then they divide a LAN into two, connect with A bridge in the middle, so that the data sent by A to BCD will not be broadcast to EFGH (the bridge finds that if the data packet is not forwarded to the following subnet, it will automatically discard this packet ), only data packets sent from A to EFGH can be sent to another subnet through the bridge (the bridge finds that if the data packet is forwarded to the following subnet, it will forward the packet to this subnet ).
In this way, unnecessary transmission is reduced, and the efficiency of the entire network is also improved! People have found that bridges are really a good thing. With the development of hardware, there are four link layer devices with eight ports. This is a switch, because vswitches can make the network more secure (data is not easily listened to, because data is no longer broadcast. Note: It's just not easy, but you can still do it ), higher network efficiency (or because data is no longer broadcast !), Switches gradually replace the HUB and become an important device for establishing a LAN.
Therefore, bridges and switches are basically the same. Well, they are basically the same, but they are still somewhat different in detail, but before explaining what is different between them, I would like to briefly introduce the working principles of bridges and switches.
3. Working Principle of the bridge:
It is two networks connected by A bridge. Port A of the bridge connects to subnet A and port B connects to subnet B. Why does the bridge know which packets should be forwarded and which packets should not be forwarded? This is because it has two tables, A and B. When A packet enters port A, the bridge extracts the source MAC address and the target MAC address from the packet.
At the beginning, table A and table B were empty and there was no record. In this case, the bridge will forward the data packets to the B network, and add a mac address (in the source MAC address record table) to Table A, which indicates that the host of the MAC address is A subnet. Similarly, when subnet B sends data packets to port B, the bridge also records the source MAC address to table B.
After the bridge works for A while, table A basically records the MAC addresses of all machines in subnet A. Similarly, table B sends another packet to the bridge from subnet, the bridge will first check whether the destination MAC address of the data packet belongs to subnet A or subnet B. If the corresponding MAC address is found in Table A, the packet will be discarded. If not, the packet will be forwarded to subnet B, check whether the source MAC address already exists in the table. If not, add A record in table.
Oh, maybe you will ask now, why do we need two tables? Can't we have one ?? Hmm ~ The table was split into two for ease of understanding. In fact, the real net bridge should store a table (of course, it may be for speed-up or other reasons, it may also store the information in multiple tables. It depends on how it is implemented ~), For a table, the table records MAC-PortNum.
4. The vswitch is somewhat different,
The vswitch also has a MAC-PORT table (the name of this table is CAM), which is different from that of the bridge, the bridge table is one-to-many (one port number is for multiple MAC addresses), but the CAM table of the switch is one-to-one. If a port has a new MAC address, it does not add MAC-PORT records, but modifies the original records.
For example: Now there is a switch record table: MAC1-Port1, if at the moment Port 1 has a packet, the source MAC address inside is MAC2, at this time, the switch will refresh the switch record table: the MAC1-Port1 record is modified to the MAC2-Port1, because the switch thinks the MAC address of the computer on Port 1 has changed, if Port 1 is connected to a physical machine, MAC is generally not changed, if another vswitch is connected, the port record changes frequently (for example, Port12, which is an external interface and is connected to a LAN). In addition, if no record corresponding to the destination MAC address of the data packet is found in the CAM table, the switch broadcasts the data packet and sends it to each port of the vswitch.
Cache comparison between bridges and switches
In addition to using a CAM table to guide data packet forwarding, bridges and switches have different characteristics: caching! Yes, both the bridge and the switch have a certain amount of caching. Because the bridge and switch require some additional operations to forward data packets, it may take some time. In order to avoid the delay in data forwarding, when a large amount of data is lost, the bridge and switch cache.
Of course, the cache is not omnipotent. When the bridge or switch cannot process and the cache is used up, data will be lost later. Another reason for caching a bridge is that it bridges two local networks with different transmission rates. For example, the transfer rate of 802.3 is 10 mb/s, but it is not actually 10 Mb/s, but 802.4 (almost) it is indeed 10 Mb/s, but the two LAN bridging must be at the same rate, otherwise there will be packet loss, and the cache can be used for network connection at different rates.
The cache volume of the bridge is greater than the cache volume of the switch. Because the bridge is designed to connect two networks, the amount of data to be processed during the bridge is much larger than the amount of data to be processed by the General switch, therefore, the cache of the bridge is generally larger than that of the switch.