First, let's review the basic concept of routing. What is routing? Routing means that when a router (or other three-layer device) receives an IP data packet, the router checks the IP header of the IP data packet, takes the destination IP address in the IP header to the routing table for search, and after finding a matching entry, forwards the data packet according to the next-hop IP address and outbound interface information indicated by the entry.
From the above description we can see several points: Routing is done based on the destination IP address in the IP header of the packet; What is being searched is the routing table. So what is Ethernet Layer 2 switching? In order to interconnect multiple PCs in the intranet and enable them to communicate in the simplest way, we often use an access layer switch to connect the PCs, as shown below: At this time, we say that the PCs connected to this switch belong to a LAN. These PCs all have IP addresses in the same network segment and are also in the same broadcast domain. The so-called broadcast domain refers to the range that a broadcast data frame can flood. For example, if PC1 sends a broadcast frame, all PCs connected to the switch will receive the broadcast data frame and analyze it (even if it may not need the data and will eventually discard the received data frame, the process of checking whether the data is sent to itself will still consume device resources). Now let's analyze what happens when PC1 sends a data packet to PC4. 1. PC1 constructs an IP data packet. The source IP address in the IP message header is its own IP, which is IP1, and the destination IP address is IP2. In order to be transmitted in an Ethernet environment, the above IP data packet needs to be encapsulated with an Ethernet header. In the Ethernet header, the source MAC address is MAC1 and the destination MAC address is MAC2 (here we ignore the ARP process for the time being). 2. This data frame is sent to the switch connected to PC1. We know that routers maintain a routing table for data forwarding, and switches use the MAC address table to perform data exchange. Initially, the MAC table of the switch is empty. So when the switch receives the data frame sent by PC-A, it first learns the source MAC address in the Ethernet header of the data frame into the MAC address table and associates it with the interface and VLAN that received the data frame. As shown in the following figure: 3. Next, the switch will take the destination MAC address in the Ethernet header of the data frame and query the MAC address table. Since there is no entry matching the address MAC2 in the MAC address table at this time, the switch will flood the data frame. Flooding means sending a copy of the data frame from all other interfaces except the interface that received it. The purpose of doing this is actually: "I don't know where you are, so I just send a copy to everyone." 4. All other PCs connected to the switch can receive this data frame. However, after receiving this data frame, other PCs except PC2 frame the bit stream and check the destination MAC in the Ethernet header. They find that the MAC is inconsistent with the local MAC, so they determine that the data frame is not sent to themselves and discard it. When PC2 receives the data frame and checks the destination MAC, it finds that the destination MAC of the data frame is the same as its own MAC. Therefore, it determines that the data frame is sent to itself, so it performs a CRC check. After the check is successful, it decapsulates the Ethernet header and sends the inner IP data to the IP protocol stack for processing. It further checks the IP header and finds that the destination IP address in the IP header is the local IP address, so it decapsulates the IP header and sends the inner payload to the upper layer protocol for processing. In this way, the data sent from PC1 to PC2 completes a one-way transmission. For the switch, there is an entry in the MAC address table. Now, PC2 needs to send data back to PC1. The data structure is shown in the following figure: 5. After receiving the data frame, the switch first checks the source MAC address of the Ethernet header of the data frame, learns the MAC address into the MAC address table, and associates it with the interface 24 that receives the data frame. 6. Next, the switch takes the destination MAC in the Ethernet header of the data frame and checks its MAC address table. It finds that the destination MAC address MAC1 has a matching entry in the MAC address table and is associated with interface 1. The switch then switches the data frame to interface 1. This is called switching. This data frame is finally received by PC-A, thus completing a data exchange process in the Ethernet environment. To summarize: the so-called layer 2 switching in the Ethernet environment (lay2-switching) means that when a layer 2 switch receives a data frame, it analyzes the destination MAC address in the data frame header, and uses the MAC address to search the MAC address table. If there is a match, the data frame is switched out from the interface associated with the match. If there is no match, the data frame is flooded. Therefore: Ethernet layer 2 switching is based on the search for the destination MAC address in the frame header of the data frame; The MAC address table is searched. |
>>: Let's talk about IPv4 to IPv6 tunnel
On March 10, China Mobile announced that by the e...
In most cases, choosing an Ethernet cable is rela...
Recently, CloudCone has released information abou...
After more than three years of stable operation, ...
Changing the rules of the online market It’s safe...
The need for communication is indispensable in ou...
Disaster recovery technology means that when a da...
[[429302]] Japan has once again experienced a maj...
As the digital transformation of enterprises cont...
spinservers has released the latest July promotio...
Automakers are battling in court with Qualcomm, N...
According to foreign media reports, in just a few...
With hundreds or even thousands of parameter comb...
Starting with Bitcoin, the decentralized and data...
After the rapid development in 2020, 2021 is a cr...