How the MAC layer works

There is something called a Hub, which is a hub. This device has multiple ports and can connect multiple computers in the dormitory. However, unlike a switch, a hub has no brain and works entirely at the physical layer. It will copy every byte it receives to other ports. This is the first physical layer connectivity solution.

The full name of MAC is Medium Access Control, which is media access control. Control what? In fact, it is a matter of controlling who sends data first and who sends it last when sending data to the media. Prevent confusion. This solves the second problem. The rule in this question is called multiple access.

  • Method 1: Divide into multiple lanes. Each car has one lane, you go in yours and I go in mine. This is called channel partitioning in computer networks ;
  • Method 2: Travel on an odd number today and an even number tomorrow, take turns. This is called a round-robin protocol in computer networks ;
  • Method 3: No matter what happens, if you have something to do, go out first. If you find it's really blocked, go back. Miss the peak and come out again. We call it random access protocol . The famous Ethernet uses this method.

For Ethernet, the last layer of the second layer is CRC, which is cyclic redundancy detection. The XOR algorithm is used to calculate whether an error occurred during the sending process of the entire packet, which mainly solves the third problem.

There are N machines connected to a broadcast network. How do I know who each MAC address is? This is the ARP protocol, which is a protocol for finding a MAC address based on a known IP address.

A MAC1 computer sends a packet to another MAC2 computer. When the packet reaches the switch, the switch does not know which port the MAC2 computer is at first, so it has no choice but to forward the packet to the other computer. All other mouths except that mouth. However, at this time, the switch will do a very smart thing, that is, the switch will remember that MAC1 comes from a clear port. In the future, if the destination address of a packet is MAC1, it can be sent directly to this port.

First, the MAC layer is used to solve the traffic jam problem of multi-access; second, ARP searches for the target MAC address by roaring, and remembers it for a period of time after roaring; this is called caching; third, the switch It has the ability to learn MAC addresses. After learning it, it will know who is where and there is no need to broadcast.

This article is a study note for Day 5 in September. The content comes from Geek Time's "Internet Protocol". This course is recommended.

Guess you like

Origin blog.csdn.net/key_3_feng/article/details/132698949