Basic network knowledge 1: hub, bridge, switch

Source: Internet
Author: User

Recently, I have been looking at something about the network. First, I would like to summarize the basic things. Note: The following concepts are not necessarily accurate now, because the hardware development is quite rapid, the integration of integrated circuits is getting higher and higher. Taking vswitches as an example, what is now commonly known as vswitches already have certain vro functions. In some cases, many concepts have been mixed up. The content below is the most basic concept. It may be different from what you can see now, but the idea is the same.The following is my summary of the materials I have recently read. If you have any mistakes, please note:>

1. Hub

HUB, which is working inPhysical Layer DeviceBecause it only works on the physical layer of the device, it does not care about or care about the layers involved in the OSI. Its Working Process is: when a port receives a packet, the packet will be forwarded once on another port because it does not know and cannot know who the packet is sent to (physical layer devices only care about the physical concepts of voltage), and it can only broadcast to everyone (This is different from the meaning of the word broadcast mentioned below and the meaning of the broadcast when ARP requests are sent. The broadcast here means that the broadcast caused by the use of physical layer forwarding devices, such as HUB, it can be said that this broadcast is forced because of device problems! It is a broadcast caused by a device forwarding packet! The ARP request broadcast is self-requested and active, because the IP address of the ARP request packet is 255.255.255.255, but the ARP request broadcast involves the knowledge of the IP layer, it is not in the scope of this article, so the broadcast mentioned here, unless otherwise stated, is the first meaning, that is, "broadcast caused by device packet forwarding"), Let them handle it by themselves.

As a result, there will be a lot of problems. The data you send has been received by others, and private hiding does not exist! You can listen to your information as needed! So session hijacking was quite easy in that age (I remember that when I first came into contact with the concept of session hijacking, it was still 2, that was 2001 ~ 2002. At that time, hubs were still quite common ).

Another serious problem is that if a large local area network, such as 500 machines, is connected to all the HUB machines, what will happen ?? Very slow, with poor network efficiency! Why? If 500 machines send a packet, each machine needs to receive about 499 useless packets... and if you need a response ...... useless data packets will flood the entire LAN. This is the legendary broadcast storm!

To reduce the number of broadcast storms, bridges are generated (note that "decrease" is not "put an end", but only "decrease" is used here! If we only use a bridge to prevent a broadcast storm, I personally think it is not very accurate. Later, the emergence of a switch can be said to completely prevent the occurrence of a broadcast storm )!

Before introducing the bridge, I would like to briefly introduce another physical layer device: "Repeater", which is used to enlarge the signal transmitted by the physical layer. Due to the long-distance transmission, there will be a certain amount of loss in the signal. This is the main solution of this kind of equipment. The difference between it and HUB is that the HUB is mainly used to forward data on the physical layer, so it does not care about the voltage value or enlarge the physical signal; the purpose of the repeater is to enlarge the signal. SO .....

Ii. Bridge:

A Bridge is also called a Bridge. Its English name is Network Bridge,Data link layer device. It is also a device that forwards data packets, but unlike the HUB, it works on the data link layer. The HUB can only understand what is on the physical layer (such as a physical signal ), the bridge can understand some frame information (after encapsulating the data passed above on the link layer, the encapsulated data is the frame, however, here I use a wildcard like "data packet" to replace the term "frame ). On the LAN constructed by Ethernet, the final addressing is identified by the MAC address of the data link layer (that is, a unique machine can be found on the LAN Using the MAC address ), the bridge can extract MAC information from the sent packets and forward the packets purposefully Based on the MAC information, instead of broadcasting, which can reduce the appearance of broadcast storms, to improve the efficiency of the entire network, I would like to introduce the switch before I elaborate on the Net Bridge.

Iii. vswitches:

Switch, a data link layer device that forwards data packets. Like a bridge, it also recognizes the MAC address in the frame and then forwards the specified port.

4. What are the working principles and differences between bridges and switches?

Before answering the difference between a bridge and a switch, let's take a look at the two pictures (this is taken from Chapter 4 of "Computer Network (version 4)":> ):

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 (a link layer device with only two input/output ports, and now the bridge is already a relatively advanced device), and then they divided 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 destination MAC address from the packet. At the beginning, table A and table B are empty and there is no record. In this case, the bridge will forward the data packet to the B network and add A MAC address in Table (In the source MAC address record table), It indicates that the host with this MAC address is A subnet. Similarly, when subnet B sends data packets to port B, the bridge will also recordSource MAC addressTo table B. When the bridge works for A while, table A basically records the MAC addresses of all machines in subnet A. The same is true for table B, when another packet is sent from subnet A to the bridge, the bridge will first look at it.The destination MAC address of the packet belongs to subnet A or subnet B. If the corresponding address is found in Table A, the packet is discarded. If not, the packet is 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), Unlike the bridge, the bridge table is one-to-many (one port number for multiple MAC addresses), but the switch CAM table is one-to-one, if a PORT has a new MAC address, it does not add a new MAC-PORT record, but changes the original record, for example: Now there is a switch record table: MAC1-Port1, if Port 1 has another packet at the moment, the source MAC address inside is MAC2, at this time, the switch will refresh the switch record table: MAC1-Port1 record is modified to MAC2-Port1, because the MAC address of the computer that the switch considers as Port 1 has changed, if Port 1 is connected to a physical machine, the MAC address is generally not changed. If it is connected to another switch, the port record will change frequently (for example, Port12, which is an external interface and 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.

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. Here we need to compare the cache of the bridge and switch. In general, the cache volume of the bridge is larger than that of the switch, because the bridge is born to connect two networks, when two network bridges are used, the amount of data to be processed is much larger than that of the general switch. Therefore, the cache of the bridge is generally larger than that of the switch.

Notes:

1) Does the bridge need software assistance?

To answer this question, first look at the original bridge. In computer network (version 4), there is a saying like this: Traditionally, bridges usually contain a CPU, "forwarding-storage" is implemented by software. Oh,The previous bridge was like this.But now, due to the improvement of the hardware level, bridges and switches all contain special, Integrated Circuit Used for forwarding. Now, both bridges and switches do not need software assistance! By the way, software that simulates the bridge function is now available.

2) is the bridge used to connect different network segments? (Find an answer when searching Baidu)

First, what isNetwork SegmentAlas, this concept is an article! It involves a series of topics such as subnet masks ....

Here I think it should be clear that,The bridge is not used to connect different network segments.!!! At the beginning, I was miserable by this problem. I had more than N pieces of data, but it was a bit rewarding:>, communication between different network segments requires help from the gateway, it is generally a network-layer device such as a router. A bridge or switch is a link layer device. The network segment is an IP-related concept and belongs to the network layer. Bridges and switches are incapable of handling network-layer things! If you have to say that using a bridge and a switch to connect two networks in different CIDR blocks does not work, but it does not work, because machines in different CIDR blocks cannot access each other and bridges cannot act as gateways! I have already mentioned the origin of the bridge. It aims to reduce the broadcast of the HUB and improve the lan network performance. The bridge connects only two sub-LAN networks, and the sub-lan mentioned here must be homogeneous (homogeneous means: If it is Ethernet, the two subnets connected by the bridge must be Ethernet, I always think that the Ethernet feature leads to the emergence of bridges because broadcast is an important feature of Ethernet, other constructed networks may not exist (Ah ~ Here I guess, I can't help but say-_-! On the networks of other structures -_-!), To optimize the performance of the Ethernet, the bridge appears ~ SoOther network structures do not seem to require the use of bridges.This stuff! In fact, I continued to look at wireless networks with this idea and found that this idea should be wrong,The nature of a bridge should be: connecting two homogeneous NetworksOn the Ethernet, the HUB can be used as a device to connect two networks. However, due to the disadvantages of the HUB, people have developed bridges working on the Link Layer (as described in this article ), in addition to the ability to connect two networks, it also has the ability to optimize network performance. In other constructed networks, there is also a bridge device, but its function may be to connect only two networks without the function of optimizing network performance (or according to network characteristics, it has new features ).

  Here, we will summarize the bridges and switches.:

Bridge and switch usersSplit conflicting DomainsThat is, there can be fewer bridges and switches.Forced broadcast (caused by hub),Cannot separate broadcast domains. Not strictly speaking, a switch can be regarded as a bridge highly integrated.

  Conflict domain: In general,A conflict domain is a collection of All workstations connected to the same wire, or a collection of all nodes in the same physical network segment, or a collection of nodes competing for the same bandwidth over Ethernet.. HUB devices cannot be separated into conflicting domains.

  Broadcast domain: A collection of all devices that can receive broadcast frames from any device in the network.

All the ports of the HUB are in the same broadcast domain and conflict with each other.
All the ports of the Switch are in the same broadcast domain, and each port is a conflict domain.
Each port of the Router belongs to a different broadcast domain.

Okay ~ Summarize so much, and write again next time ~

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.