Do you understand the principle of Ethernet data transmission?

Do you understand the principle of Ethernet data transmission?

[[276059]]

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.

<<:  A brief discussion of the TCP protocol, finally understand what it does

>>:  Huawei releases next-generation CloudLink video conferencing solution

Recommend

A brief analysis of RoCE network technology

In the era of data being king, people have more s...

Meituan second interview: TCP's four waves, can it be reduced to three?

Hello everyone, I am Xiaolin. I have posted this ...

ZTE Chief Scientist Talks About the Current Status of 5G

[51CTO.com original article] The Internet of Thin...

Let's talk about TPC

[[403151]] In recent days, the PR publicity of Oc...

What is a Bluetooth gateway and how to use it?

What is a Bluetooth Gateway? A Bluetooth gateway ...

Wi-Fi Alliance: Wi-Fi 6E is the most significant upgrade in 20 years

With the rapid development of mobile devices, the...

How should NFV be deployed today?

Network Function Virtualization is maturing among...

From "4G+5G" to "5G+5G": Dual SIM dual standby evolves quickly

Driven by market demand and the country's &qu...

Have you already moved to SDN network?

Today's networks are constantly changing and ...