The layer-3 switch you know works like this. It works like a layer-3 switch.

Source: Internet
Author: User

The layer-3 switch you know works like this. It works like a layer-3 switch.

Why do we say that the L3 forwarding performance of a layer-3 switch is much higher than that of a router? Sometimes it is mentioned in many books that the software of the router is also very powerful and can almost achieve the speed limit forwarding capability. However, it is unlikely that the software can compare with the hardware; the reason why a vswitch forwards data quickly is that the vswitch uses a dedicated ASIC hardware forwarding card and the vro uses a software-based forwarding card.

We are used to saying that the same vlan can communicate with each other in a L2 network, but different VLANs cannot communicate with each other, so what layer-3 switches need to do Is route forwarding. But what is the working principle?

First, what are the differences between layer-3 switches in the same subnet and different subnet environments?

For example, in the Layer 2 environment, the communication between the A---B, A sends A packet to the MAC address is B, when sent to the switch, the switch based on the destination MAC address forwarding, then, you can view your MAC table items and find the corresponding egress. During the process, only the MAC address is searched, without any changes to the data frame, here, I only provide a brief and simple description of second-layer Frame Forwarding. After all, the focus is not on this.

In the layer-3 environment between A---C communication, A sends A packet, the destination MAC address should be the gateway MAC address, that is, the MAC address of the switch SMAC is good here to insert A small episode, someone asked me how to judge whether a vswitch needs layer-3 forwarding. My answer was to check whether the mac address of this data packet is self-contained. If so, it executes layer-3 forwarding, when I came back to study this question, I found that my answer was not rigorous. Why? What does a vswitch do when it receives a packet with its own L2 destination mac address?

In an episode, I saw such a short film two days ago. It said that in a college classroom, two boys especially liked the banhua sitting behind them, then she kept looking at the girl. Suddenly, the girl stood up and was ready to leave. When she passed by them, she gave the boy sitting on the other side a small roll-up paper. Physically, the girl handed the paper to the boy and thought about what the boy would do next? I want to open the paper and check what is written in it! When a layer-3 Switch receives the target mac address, it also needs to encapsulate it in the upper layer, view the layer-3 destination IP address, and then

? At that time, the boy happily took the paper and opened it. It said, "Please hand the paper to the next person." Haha ,,, A layer-3 Switch also looks like this. The original destination IP address is not its own, so it executes the route-layer forwarding. Therefore, if the destination mac address is its own, whether the IP address is your own. If it is your own IP address, you do not need to forward it.

When the switch determines that the destination IP address is not its own, is it sure to view the route table? No, this is the key to the switch. At this time, the switch does not view the route table, arp table, or mac address table. What table does the switch view?

At this time, the switch will view the hardware Forwarding Table integrated into the ASIC hardware forwarding card. What does this hardware Forwarding Table contain?

  • When the first package arrives, it is found that the hardware forwarding table does not have any table items. Therefore, data packets must be processed by the routing process. Once transferred to the cpu, cpu resources will inevitably be consumed, in this case, you will view the route table and find that the IP address is directly connected. Then you can view arp to find the mac address corresponding to the IP address and then forward it.
  • In the process of deciding to forward data, the switch will do at least three things: 1. Modify the ttl value of the IP Address Header; 2. modify the original mac address and change it to the mac address of the outbound interface. 3, create a vswitch hardware forwarding table, including the destination IP address, the mac address corresponding to the destination IP address (Next Hop), the vlan corresponding to the mac address, and the corresponding port (each manufacturer has its own understanding)
  • In this way, when the package comes in, the switch will view the hardware forwarding table and directly forward it without going through the route table query, that is, one route of the switch. The principle of the switch is multiple times.

Each manufacturer has different definitions in this section, but the principle is the same. The cef table is used in cisco, and software-based cef is also integrated in the vro, the cef includes three tables, including FIB, adjacent table (hardware Forwarding Table), and netflow table items.

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: 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.