Got it

Differences between Layer 2 and Layer 3

Latest reply: Feb 18, 2022 07:56:52 405 18 9 0 0

This article briefly introduces the difference between layer 2 and layer 3.

There are two and three levels of communication. So what is the difference between the second and third floors? Generally speaking, the second layer realizes forwarding by checking the MAC table, and the third layer realizes forwarding by checking the routing table. Today, I will discuss in detail the difference between the second and third floors.


Let me talk about the second layer of communication. Layer 2 switches are devices at the data link layer. When the Layer 2 switch receives a data packet, it will forward it through the following steps.


1. It first needs to know where the data packet comes from, so it first reads the source MAC address of the packet header and knows which port the data packet comes from.

2. Then it needs to know where the data packet is going, so it needs to read the destination MAC address of the packet header.

3. Then look up the MAC table. If the MAC address and the corresponding port are in the table, the Layer 2 switch will copy the data packet to the corresponding port.

4. If the corresponding port cannot be found, the data packet will be broadcast to all ports.

5. When the destination device responds to the source device, it will copy the data packet to the corresponding port. At the same time, a learned correspondence will be added to the MAC table.


layer 2


In this network topology, the communication between PC1 and PC2 belongs to Layer 2 communication. Let's capture the G0/0/3 of the switch LSW3 and take a look at the data packet.


packet

The source and destination MAC addresses are 54:89:98:09:42:11, which is the MAC address of PC1, and the destination MAC address is 54:89:98:09:42:22, which is the MAC address of PC2. The switch searches the MAC address table to find the peer end and forwards the data packet.


So, what about Layer 3 communication? Assume that device A sends a data packet to device B. Perform an AND operation on the subnet masks of the two subnet masks to determine whether the two subnet masks are in the same network segment. If the destination IP addresses are in the same network segment, Layer 2 communication is used. If not, the interworking between A and B must be implemented. It sends the packet to the gateway and sends an ARP request to find the destination IP address. The Layer 3 switch searches the routing table. If the routing table contains the routing information, Layer 3 switch forwards the data according to the routing information. If not, it broadcasts an ARP request to find the route to the destination IP address.

layer 3


The figure shown is a three-layer communication model. We capture the G0/0/1 of LSW8 and analyze its data packets.

packet

It can be seen that the source MAC address and destination MAC address are no longer the MAC addresses of PC1 and PC2. It can be seen that the routing table is checked in the third layer, and the second layer switch sends ARP to the gateway. Please "where is the destination IP address", search the routing table and find it The corresponding routing information can be forwarded; if not, broadcast ARP to find the corresponding routing information.


Layer 2 communication is mostly used in small local area networks and has the advantages of mature technology, multi-port access, and low price. The third layer is suitable for routing between large-scale networks, with powerful functions and powerful routing functions. The best route can be selected to achieve load sharing.


  • x
  • convention:

wissal
wissal Created Dec 30, 2021 08:00:40 (0) (0)
Thank you, my friend  
Very important to know, learned
View more
  • x
  • convention:

jason_hu
jason_hu Created Dec 30, 2021 09:51:55 (0) (0)
Thank you! my bro.  
hemin88
Moderator Author Created Dec 30, 2021 08:01:38

Thank you for sharing this! :).
View more
  • x
  • convention:

jason_hu
jason_hu Created Dec 30, 2021 09:52:07 (0) (0)
Thank you!  
Layer 2 of the OSI model is known as the data link layer. The Layer 2 protocol you're likely most familiar with is Ethernet.
Layer 3 is the network layer and its protocol is the Internet Protocol or IP. Devices in an IP network are identified by an IP address, which can be dynamically assigned and may change over time.
View more
  • x
  • convention:

jason_hu
jason_hu Created Dec 30, 2021 09:52:42 (0) (0)
 
Vlada85
MVE Author Created Dec 30, 2021 17:33:38

Thank you
View more
  • x
  • convention:

jason_hu
jason_hu Created Jan 4, 2022 06:02:52 (0) (0)
 
Helpful post! thank you for sharing!
View more
  • x
  • convention:

jason_hu
jason_hu Created Jan 4, 2022 06:02:58 (0) (0)
 
Thanks.
View more
  • x
  • convention:

Good share
View more
  • x
  • convention:

Excellent comparrison post. As always, keep up the good work!

View more
  • x
  • convention:

12
Back to list

Comment

You need to log in to comment to the post Login | Register
Comment

Notice: To protect the legitimate rights and interests of you, the community, and third parties, do not release content that may bring legal risks to all parties, including but are not limited to the following:
  • Politically sensitive content
  • Content concerning pornography, gambling, and drug abuse
  • Content that may disclose or infringe upon others ' commercial secrets, intellectual properties, including trade marks, copyrights, and patents, and personal privacy
Do not share your account and password with others. All operations performed using your account will be regarded as your own actions and all consequences arising therefrom will be borne by you. For details, see " User Agreement."

My Followers

Login and enjoy all the member benefits

Login

Block
Are you sure to block this user?
Users on your blacklist cannot comment on your post,cannot mention you, cannot send you private messages.
Reminder
Please bind your phone number to obtain invitation bonus.