The difference between a switch and a router

1 Preface

Computer networks are often made up of many different types of networks interconnected. If several computer networks are only physically connected and cannot communicate with each other, then there is no practical meaning to this “interconnection”. Therefore, usually when talking about “interconnection”, it is already implied that these interconnected computers can communicate, that is, functionally and logically, these computer networks have formed a large computer network, or interconnection network, can also be referred to as the Internet, interconnection network.

To connect networks to each other, some intermediate devices (or intermediate systems) are used, which are called relay systems in ISO terminology. Depending on the level at which the relay system is located, there are five types of relay systems as follows.

1. Physical layer (i.e., often referred to as the first layer, layer L1) relay system, i.e., transponder (repeater).

2. Data link layer (i.e. layer 2, layer L2), i.e. bridge or bridges (bridge).

3. Network layer (layer 3, layer L3) relay system, i.e. router (router).

4. Bridge and router mixture bridge (brouter) both bridge and router functions.

5. Relay systems above the network layer, i.e. gateways.

When a relay system is a transponder, it is generally not called a network interconnection because it simply expands a network, which is still a network. High-level gateways are less commonly used today because they are more complex. Therefore the general discussion of network interconnection refers to networks that are interconnected with switches and routers. This article focuses on switches and routers and their differences.

2 Switches and Routers

“Switching” is one of the most frequently used words in today’s network, from bridging to routing to ATM to telephone systems, no matter what the occasion can be applied to it, confused about what is the real switch. In fact, the term switching first appeared in the telephone system, specifically to achieve the exchange of voice signals between two different telephones, to complete the work of the equipment is the telephone exchange. So in the original sense, the exchange is just a technical concept, that is, to complete the signal from the device entrance to the exit of the forwarding. Therefore, as long as the definition of all devices and meet the definition can be called switching equipment. It can be seen that “switching” is a broad term, when it is used to describe the equipment of the second layer of the data network, actually refers to a bridging device; and when it is used to describe the equipment of the third layer of the data network, and refers to a routing device.

What we often refer to as an Ethernet switch is actually a multi-port Layer 2 network device based on bridge technology, which provides a low-latency, low-overhead path for data frames to be forwarded from one port to any other.

It follows that there should be a switch matrix at the internal core of the switch to provide a path for communication between any two ports, or a fast switching bus to enable data frames received by any port to be sent out from other ports. In real devices, the function of the switching matrix is often performed by a dedicated chip (ASIC). In addition, Ethernet switches are designed with the important assumption that the switching core is so fast that the usual high volume of data traffic does not cause congestion, in other words, the switching capacity is infinite relative to the amount of information being transmitted (in contrast, ATM switches are designed with the idea that the switching capacity is limited relative to the amount of information being transmitted).

Although Ethernet Layer 2 switches are based on multi-port bridges, after all, switching has its richer features that make it not only the best way to get more bandwidth, but also to make the network easier to manage.

While a router is a packet switching device (or network layer relay device) in the network layer of the OSI protocol model, the basic function of a router is to deliver data (IP messages) to the correct network, including.

1. Forwarding of IP datagrams, including pathfinding and transmission of datagrams.

2. subnet isolation and suppression of broadcast storms.

3. maintain routing tables and exchange routing information with other routers, which is the basis for IP message forwarding.

4. error handling of IP datagrams and simple congestion control.

5. Implement filtering and accounting for IP datagrams.

For networks of different sizes, the role of routers has a different focus.

On a backbone network, the main role of a router is routing. Routers on the backbone network must know the paths to all lower layer networks. This requires maintaining large routing tables and reacting as quickly as possible to changes in connection status. A router failure will cause serious information transfer problems.

In a regional network, the main role of routers is network connectivity and routing, i.e., connecting various lower-level grassroots network units – the campus network – while being responsible for data forwarding between lower-level networks.

Within the campus network, the primary role of the router is to separate subnets. The early base unit of the interconnection network was the local area network (LAN), in which all hosts were in the same logical network. As the network grew in size, the LAN evolved into a campus network consisting of multiple subnets connected by a high-speed backbone and routers. In this network, each subnet is logically independent, and the router is the only device that can separate them. It is responsible for message forwarding and broadcast isolation between subnets, and the router at the boundary is responsible for the connection to the upper layer network.

3 Differences between Layer 2 Switches and Routers

The legacy switch evolved from the bridge and is an OSI layer 2, or data link layer, device. It addresses based on MAC addresses and selects routes through station tables, the creation and maintenance of which are performed automatically by the switch. The router belongs to OSI layer 3, the network layer device, which is addressed based on IP addresses and generated through routing table routing protocols. The biggest benefit of the switch is that it is fast. Since the switch only has to identify the MAC address in the frame and generate the selection of the forwarding port directly based on the MAC address the algorithm is simple and easy to implement by ASIC, so the forwarding speed is extremely high. However, the working mechanism of the switch also poses some problems.

1. Loops: According to the switch address learning and station table building algorithm, loops are not allowed to exist between switches. Once a loop exists, the spanning tree algorithm must be activated to block off the port that created the loop. The router routing protocol does not have this problem, and there can be multiple paths between routers to balance the load and improve reliability.

2. Load concentration: There can be only one path between switches, making information concentrated on one communication link, which cannot be dynamically distributed to balance the load. And routers routing protocol algorithm can avoid this, OSPF routing protocol algorithm can not only generate multiple routes, but also for different network applications to choose their own different best route.

3. Broadcast control: The switch can only reduce the conflict domain, but not the broadcast domain. The whole switched network is a large broadcast domain, and broadcast messages are scattered to the whole switched network. And the router can isolate the broadcast domain, and broadcast messages cannot continue to be broadcast through the router.

The switch can only recognize MAC address, which is a physical address and uses a flat address structure, so it cannot be used to divide subnets based on MAC address. The router recognizes IP addresses, which are assigned by the network administrator, are logical addresses and IP addresses have a hierarchical structure, and are divided into network numbers and host numbers, which can be used to divide subnets very easily.

5. Confidentiality issues: Although the switch can also filter frames based on their source MAC address, destination MAC address and other contents in the frame, it is more intuitive and convenient for the router to filter messages based on their source IP address, destination IP address, TCP port address and other contents.

6. Media-related: switches as bridging devices can also complete the conversion between different link layers and physical layers, but this conversion process is more complex and not suitable for ASIC implementation, which will inevitably reduce the forwarding speed of the switch. Therefore, the switch is mainly used to interconnect networks with the same or similar physical media and link protocols, and will not be used to interconnect networks with very different physical media and link layer protocols. Unlike routers, which are mainly used to interconnect different networks, they can connect networks with different physical media, link layer protocols and network layer protocols. Although routers have the advantage in terms of functionality, they are expensive and have low message forwarding speed.

In recent years, switches have made many improvements to improve performance, the most prominent of which are virtual networking and three-layer switching.

Dividing subnets can narrow the broadcast domain and reduce the impact of broadcast storms on the network. Each interface of the router is connected to a subnet, and broadcast messages cannot be broadcast out through the router. Subnets connected to different interfaces of the router belong to different subnets, and the subnet range is physically divided by the router. For the switch, each port corresponds to a segment, and since the subnet consists of several segments, the subnet can be logically divided by combining the switch ports. Broadcast messages can only be broadcasted within the subnet and cannot be spread to other subnets. By dividing logical subnets rationally, the purpose of broadcast control is achieved. Since logical subnets are made up of any combination of switch ports and have no physical correlation, they are called virtual subnets, or virtual networks. Virtual network technology solves the problem of isolation of broadcast messages without routers, and the segments within a virtual network are independent of their physical locations, i.e., adjacent segments can belong to different virtual networks, while two segments far apart may belong to different virtual networks, and two segments far apart may belong to the same virtual network. Terminals within different virtual networks cannot communicate with each other, which enhances the access control of data within the network.

Switches and routers are a paradox of performance and functionality. Switches are fast in switching but weak in control, and routers are strong in control but slow in message forwarding. The latest technology to solve this contradiction is three-layer switching, which has both the wire-speed forwarding capability of switches and the good control function of routers.

4 Differences between Layer 3 Switches and Routers

Before the advent of Layer 3 switching technology, there was little need to distinguish routing-enabled devices from routers, they were exactly the same: providing routing functionality being the job of a router, however, now Layer 3 switches are fully capable of performing most of the functions of a traditional router. As devices for network interconnection, Layer 3 switches have the following characteristics.

1. forwarding of business flows based on Layer 3 addresses.

2. complete exchange function.

3. special services, such as message filtering or authentication, can be accomplished.

4. Perform or not perform routing processing.

Layer 3 switches have the following advantages over traditional routers.

1. The transmission bandwidth between subnets can be arbitrarily allocated: each interface of a traditional router connects a subnet, and the rate of transmission of subnets through the router is limited by the bandwidth of the interface. Unlike the three-layer switch, which can define multiple ports into a virtual network, the virtual network composed of multiple ports as a virtual network interface, the information in the virtual network can be sent to the three-layer switch through the ports that make up the virtual network, and because the number of ports can be arbitrarily assigned, there is no limit to the transmission bandwidth between subnets.

2. Reasonable allocation of information resources: Since there is no difference between the rate of accessing resources in the subnet and the rate of accessing resources in the global network, it is not meaningful to set up separate servers in the subnet, and by setting up server clusters in the global network not only saves costs, but also allows reasonable allocation of information resources.

3. Cost reduction: The usual network design uses switches to form subnets and routers.

Leave a Reply

Your email address will not be published. Required fields are marked *