Differences between hubs, switches, and Routers

Source: Internet
Author: User

Hubs, switches, and routers, which are known as network hardware, have always been active in the network field. However, many cainiao who are new to the network are annoyed by the fact that, they are not only similar in appearance, but also often stay together. It is a bit difficult to tell who they are! Let's take a look at the differences and relationships between them!

1. Hub

1. What is a hub?

Before you know the hub, you must first understand the repeater. In the network we come into contact with, the simplest thing is that two computers form a "dual-Host Interconnect" through two NICs. Generally, the two NICs act as signal lines by unshielded twisted pair wires. Because the signal power of the twisted pair will gradually decrease when the signal is transmitted, the signal distortion will occur when the signal is reduced to a certain extent. Therefore, while ensuring the signal quality, the maximum transmission distance of twisted pair wires is 100 meters. When the distance between the two computers exceeds 100, in order to achieve dual-host interconnection, People install a "Repeater" between the two computers ", the function of this function is to sort out the incomplete signals that have been degraded, generate a complete signal again, and then transmit it again. A repeater is the predecessor of a general hub. A hub is actually a multi-port repeater. Generally, a hub has a number of RJ45 interfaces, such as 4, 8, 16, 24, and 32. Through these interfaces, the hub can "relay" the corresponding number of computers. Because it is in a "center" position in the network, the hub is also called "Hub ".

2. Working Principle of the hub

The working principle of the hub is very simple. For example, Figure 2 shows a hub with eight ports connected to eight computers. The Hub is in the "center" of the network and forwards signals through the hub. Eight computers can communicate with each other. The specific communication process is as follows: if Computer 1 needs to send a piece of information to computer 8, when computer 1's Nic sends the information to the hub through twisted pair wires, the Hub does not directly send the information to computer 8. It broadcasts the information and sends the information to the eight ports at the same time, when the computer on the eight ports receives the broadcast information, it checks the information. if it finds that the information is sent to itself, it receives the information; otherwise, it ignores it. Because the information is sent from computer 1 to computer 8, computer 8 will eventually receive the information, this information is not received because it is not its own.

3. Features of The Hub

1) shared bandwidth

The bandwidth of a hub is the maximum speed it can achieve during communication. Currently, the hubs used for small and medium-sized LAN mainly include 10 Mbps, 10/100 Mbps, and Mbps adaptive. A hub with a bandwidth of 10 MB can transmit data at a maximum speed of 10 Mbps. Even if the computer connected to the Hub uses a Mbps Nic, the data transmission speed is still 10 Mbps. The 10/100 Mbps adaptive hub can automatically adjust the bandwidth according to the speed of the NIC connected to the port. when connected to a 10 Mbps Nic, the bandwidth is 10 MB. when connected to a Mbps Nic, the bandwidth is 100 mb. Therefore, this type of hub is also called a "dual-speed hub ".

A hub is a "shared" device. The Hub itself cannot identify the destination address. When a host a in the same LAN transmits data to host B, packets are transmitted in a hub-based network in broadcast mode. Each terminal verifies the address information of the data packet header to determine whether to receive the packets.

Since a hub can only transmit one set of information during a clock cycle, if a hub is connected to a large number of machines and multiple machines often need to communicate at the same time, the efficiency of the hub will be poor, such as information congestion and collision.

Why? For example, in Figure 2, when computer 1 sends a message to computer 8 through the hub, if computer 2 also wants to send the information to computer 7 through the hub, when it tries to contact the hub, it finds that the hub is busy with computer 1, so computer 2 will "carry" the data and wait in front of the hub, and always ask the hub to stop computer 1 for help. If computer 2 successfully "grabs" the Hub (because the hub is "shared", it is easy to grab it ), at this time, the data of Computer 1 in the transmission status will be stopped, so computer 1 will also "grab" The Hub ......

It can be seen that the actual speed of each port on the hub is not only related to the bandwidth of the hub, but also the number of devices that work at the same time. For example, if a 10 MB hub is connected to eight computers and the eight computers work at the same time, the actual bandwidth of each computer is 10/8 = 1.25 MB!

2) Half Duplex

Full Duplex: When two devices send and receive data, both parties can send or receive data at the same time. This transmission mode is full duplex. For a half-duplex transmission device, when one device sends data, the other device can only receive the data, but cannot send the data at the same time.

Because the hub transmits information through "broadcast", the hub can only transmit data in half-duplex mode. For example, if Computer 1 and computer 8 need to transmit data to each other, when computer 1 sends data, computer 8 can only receive data sent from computer 1, and only wait for Computer 1 to stop sending and prepare for receiving, it can send its own information to computer 1 or other computers.

Ii. vswitches

1. What is a vswitch?

A switch is also called a switch-type hub. It re-generates information and forwards it to a specified port after internal processing. It can automatically address and exchange information, the switch sends each information packet independently from the source port to the destination port based on the destination address of the information packet to avoid collision with other ports. A vswitch in the broad sense is a device that implements information exchange in a communication system.

2. How the vswitch works

In a computer network system, switches are designed to address the weakness of the shared working mode. A hub is represented by a shared working mode. If a hub is compared to a postman, the postman is an unliterate "dumb"-asking him to send a mail, he doesn't know how to send the mail to the recipient directly based on the address on the letter. Instead, he only delivers the mail to all the recipients, and then asks the recipient to determine whether the recipient is his own Based on the address information! The switch is a "smart" postman-the switch has a high-bandwidth back bus and an internal switching matrix. All the ports of the switch are attached to the back bus. When the control circuit receives the data packet, the processing port searches for the address table in the memory to determine the target MAC address (the hardware address of the NIC) the port on which the NIC is attached, and data packets are quickly transmitted to the destination port through the internal switching matrix. If the target Mac does not exist, the switch broadcasts all the ports. After receiving the port response, the switch "learns" the new address and adds it to the internal address table.

It can be seen that when receiving a "letter" from a network card, the switch will quickly send the letter to the recipient based on the above address information and its "resident residence booklet. In case the recipient's address is not in the "user register", the switch will distribute the email to all people like a hub, and then find the recipient. After finding the receiver, the switch will immediately register the information of the receiver to the "user register", so that the mail can be delivered quickly when serving the customer.

3. vswitch performance characteristics

1) dedicated bandwidth

Because the switch can intelligently send data to the destination based on the address information, it does not "Disturb" non-recipients when transmitting data like the hub. In this way, the switch can transmit data between multiple port groups at the same time. In addition, each port can be considered as an independent network segment, and both parties that communicate with each other enjoy all the bandwidth, without competing with other devices. For example, when host a sends data to host D, host B can send data to host C at the same time, the two transmissions all enjoy the bandwidth of the network. Assume that they use a 10 MB switch, then the total traffic of the switch is 2*10 MB = 20 mb.

2) Full Duplex

When two ports on a vswitch are communicating, they can implement full-duplex communication because the channels between them are relatively independent.

Iii. vro

1. What is a router?

A router is a group exchange device (or network layer Relay Device) in the network layer of the OSI protocol model. The basic function of a router is to transmit data (IP packets) to the correct network.

2. How routers work

The main task of a vro is to receive data packets from a network interface and decide to forward data packets to the next destination address based on the destination address. Therefore, the router first needs to find its destination address in the forwarding route table. If the destination address is found, add the next MAC address before the frame of the packet, at the same time, the TTL (time to live) domain of the IP data packet header also starts to be reduced, and the checksum is re-calculated. When a data packet is sent to the output port, it needs to wait in order to be transmitted to the output link.

3. router performance characteristics

1) Forward IP data packets, including path finding and transmission of data packets;
2) subnet isolation to prevent broadcast storms;
3) maintain the route table and exchange route information with other routers. This is the basis for IP packet forwarding.
4) IP datagram error handling and simple congestion control;
5) filters and bills IP data packets.
Iv. Differences between hubs and switches

According to the working principle of the two, the switch and the hub are very different. First, from the perspective of the OSI architecture, the hub belongs to the first layer of the OSI physical layer device, and the switch belongs to the second layer of the OSI data link layer device.

Second, from the perspective of working methods, the hub adopts a "broadcast" mode, so it is easy to generate a "broadcast storm". When the network scale is large, the performance will be greatly affected. When a vswitch works, only the requested port and the destination port respond to each other without affecting other ports, therefore, vswitches can isolate conflicting domains to a certain extent and effectively suppress the emergence of "broadcast storms.

In addition, from the bandwidth perspective, no matter how many ports the hub has, all ports share a bandwidth. At the same time, only two ports can be used to transmit data, while other ports can only wait, at the same time, the hub can only work in half duplex mode. For a vswitch, each port has an exclusive bandwidth. When the two ports work, other ports are not affected, at the same time, the switch can not only work in half duplex mode, but also in full duplex mode.

If the difference between a vswitch and a hub is described in the simplest language, it should be the difference between intelligence and non-intelligence. To put it bluntly, a hub is only a network device connected to multiple computers. It can only play a role in signal amplification and transmission, and cannot process fragments in the signal. Therefore, it is prone to errors during transmission. A switch can be seen as an intelligent hub. In addition to all the features of the hub, it also has the functions of automatic addressing, switching, and processing. In addition, in the data transmission process, the sender and receiver work independently and do not have a relationship with other ports, so as to prevent data loss and improve throughput.

V. Differences between vswitches and vrouters on the second layer

Traditional switches are developed from bridges and belong to the OSI Layer 2 (data link layer device. It selects routes from the station table based on MAC address addressing. The establishment and maintenance of the station table is automatically implemented by the switch. A router is a layer-3 network-layer device of OSI. It is addressing based on IP addresses and is generated through the route table routing protocol. The biggest advantage of a vswitch is that it is fast. Because the vswitch only needs to identify the MAC address in the frame, the selection of forwarding Port Based on the MAC address is simple, Which is easy for ASIC implementation. Therefore, the forwarding speed is extremely high. However, the working mechanism of vswitches also brings about some problems.
1) loop: Based on the vswitch address learning algorithm and the station table, no loop is allowed between vswitches. Once a loop exists, the Spanning Tree Algorithm must be enabled to block the ports that generate the loop. The router routing protocol does not solve this problem. There are multiple channels between routers to balance the load and improve reliability.
2) centralized load: only one channel is available between switches, so that information is concentrated on one communication link and cannot be dynamically allocated to balance the load. The router routing protocol algorithm can avoid this. The OSPF routing protocol algorithm can not only generate multiple routes, but also select different optimal routes for different network applications.
3) broadcast control: A vswitch can only narrow down the conflicted domain, but not the broadcast domain. The entire exchange network is a large broadcast domain, where broadcast packets are scattered across the entire exchange network. Vrouters can isolate broadcast domains, and broadcast packets cannot be broadcast through vrouters.
4) subnet division: The switch can only recognize MAC addresses. The MAC address is a physical address and uses a flat address structure. Therefore, you cannot divide subnets Based on the MAC address. Vro identifies IP addresses. IP addresses are allocated by network administrators. They are logical addresses and IP addresses have hierarchies. They are divided into network numbers and host numbers, which can be easily used to divide subnets, the main function of a vro is to connect to different networks.
5) Confidentiality: although the switch can also filter Frames Based on the source MAC address, target MAC address, and content in other frames, however, the vro filters packets based on the source IP address, destination IP address, and TCP port address of the packets, making them more intuitive and convenient.
6) media-related: A switch can also be used as a bridge device to complete the conversion between the link layer and the physical layer. However, this conversion process is complicated and is not suitable for ASIC implementation. This will inevitably reduce the forwarding speed of the switch. Therefore, currently, vswitches primarily Interconnect Networks with the same or similar physical media and link protocols, instead of connecting networks with different physical media and link layer protocols. Different routers are used for interconnection between different networks, so they can connect networks with different physical media, link layer protocols, and network layer protocols. Although a vro has a functional advantage, it is expensive and has a low packet forwarding speed.
In recent years, vswitches have made many improvements to improve performance. The most prominent improvement is the virtual network and layer-3 switching. Dividing subnets can narrow the broadcast domain and reduce the impact of broadcast storms on the network. Each vro interface is connected to a subnet. broadcast packets cannot be broadcast by the vro. The subnets connected to different vro interfaces belong to different subnets. The subnet ranges are physically divided by the vro. For a vswitch, each port corresponds to a CIDR block. Because the subnet consists of several CIDR blocks, you can logically divide subnets by combining vswitch ports. Broadcast packets can only be broadcast within the subnet and cannot be spread to another subnet. By rationally dividing the logical subnet, broadcast can be controlled. Because logical subnets are composed of vswitch ports and have no physical correlation, they are called virtual subnets or virtual networks. The virtual network technology eliminates the need for routers to isolate broadcast packets, and the virtual network INTRANET segment has nothing to do with its physical location, that is, the adjacent network segment can belong to different virtual networks, however, the two CIDR blocks that are far from each other may belong to different virtual networks, while the two CIDR blocks that are far from each other may belong to the same virtual network. Terminals in different virtual networks cannot communicate with each other, enhancing access control over network data.
Vswitches and vrouters are the contradiction between performance and functions. The switch exchange speed is fast, but the control function is weak, the vro control performance is strong, but the packet forwarding speed is slow. The latest technology to resolve this conflict is layer-3 switching, which provides both the ability to forward packets at the wire speed of the switch and the good control function of the router.

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.