MAC address (Media access control address) is a unique identifier assigned to a network interface controller (NIC). It serves as a network address in a network segment. All hosts with network cards have separate MAC addresses. The address contains a total of 48 bits, occupying 6 bytes of space, and can represent 281,474,976,710,656 network devices. A normal MAC address is represented in the following format, with two hexadecimal digits for each byte:
Because MAC addresses need to be unique, IEEE allocates address segments based on the manufacturer of the device. The first 24 bits of the 48-bit MAC address are the identifier of the device manufacturer[^2], also known as the Organizationally Unique Identifier (OUI), and the remaining 24 bits are the serial number. If each device manufacturer can ensure that all MAC addresses in the same namespace are unique, then all MAC addresses in the world can be guaranteed to be unique. Figure 1 - MAC Address MAC addresses can be represented in two different formats, namely 48-bit EUI-48 and 64-bit EUI-64[^3]. This article will use the EUI-48 format MAC address. EUI-64 is mainly used for IPv6 protocol, which we will not discuss in this article. Under normal circumstances, MAC addresses use 24 bits to represent the organization's serial number, but because many organizations do not produce so many devices, in actual operations, three different sizes of address blocks are divided[^4]: Figure 2 - MA-L, MA-M, MA-S
The prices of these three address blocks of different sizes are completely different. The registration price of MA-L is US$2,995, while the registration price of MA-S is US$755. Interested readers can purchase them from the official website of IEEE[^5]. Ideally, the total value of all addresses is about US$52 trillion. As expected, once the standards are defined and mastered, you can just sit back and wait for others to register and make money. This method of distributing MAC address segments by organizations and ensuring that the addresses are unique by equipment vendors is to ensure that the network addresses of all hardware in the world are unique. However, in actual operation, global uniqueness cannot be guaranteed and we do not need global uniqueness of addresses. This is mainly due to the following two reasons:
Modify address Whether on Linux or macOS, it is very simple to modify the MAC address of a network device. In the Linux operating system, we can use the command ifconfig to modify the MAC address on the device:
As long as we use the above commands, we can easily modify the MAC address of the current network card. However, it is recommended not to use it on a remote Linux machine. It is best to test the relevant commands on the local Linux. After the modification test is completed, it is also best to use the command to change the MAC address back; You can also use the ifconfig command to modify the MAC address on macOS, and the method of use is almost exactly the same as Linux. Because the MAC address is bound to the hardware, this method of modifying the MAC address is actually temporary. Once the operating system is restarted, these changes will be revoked by the system. If you want to make similar changes permanent, you need to execute the corresponding command when the system restarts or modify the corresponding network card configuration file[^6]. LAN communication All computers and terminal devices need to be connected to the local area network through a network adapter. Each adapter has a unique link layer address, also called a LAN address or MAC address. MAC addresses are designed to be a flat structure and will not change depending on the network they are in. When the device's network adapter wants to send a data frame to another adapter, it inserts the destination adapter's MAC address into an Ethernet frame like the following. Each Ethernet frame is similar to an IP datagram, containing a source address and a destination address, except that the address in an Ethernet frame is a MAC address, while the address in an IP datagram is an IP address: Figure 3 - Ethernet frame Data transmission in a LAN is not routed and forwarded through the IP address of the network layer. However, the IP address is generally the only information known by the host sending data. If you want to send data in a LAN, you still need to know their MAC address. When our device wants to send data to other devices, it will first obtain the MAC address corresponding to the destination IP address in the LAN through ARP (Address Resolution Protocol): (1) The source host sends an ARP request to the current LAN. The target MAC address is FF-FF-FF-FF-FF-FF, which means that the current request is a broadcast request. All devices in the LAN will receive the request. (2) Each host that receives an ARP request will check whether the destination IP address is consistent with its own IP address;
(3) After receiving the ARP response, the source host will update the local cache table and continue to send data to the destination host; Figure 4 - Address Resolution Protocol In a LAN, we usually use a hub or switch to connect different network devices. Because in a LAN connected by a hub, all data frames will be broadcast to all hosts in the LAN, so using the same MAC address will generally not cause too many problems; but the switch will learn the MAC addresses of different devices in the LAN and forward the data frames to a specific host, so if the LAN is composed of switches, it will affect the communication of the network. Figure 5 - Hub and switch Assume that there are two network devices A and B in the LAN with the same MAC address, that is, 6e:77:0f:b8:8b:6b. When device A wants to send an Ethernet frame to device B, it will encounter the following situation:
Because of the switch's MAC address learning strategy, we cannot use the same MAC address in the same LAN. However, because the MAC address is a concept in the link layer network, network transmission across LANs needs to go through the IP protocol of the network layer, so there is no similar problem when using the same MAC address in different LANs. Summarize MAC address is an important concept in link layer networks. Ethernet data frames are forwarded through MAC addresses in local area networks. A globally unique MAC address is an ideal situation. However, in actual network scenarios, we do not need to ensure such strong restrictions:
The above conclusion does not mean that the globally unique MAC address is meaningless. On the contrary, we should try our best to ensure the uniqueness of the MAC address, so that when setting up a local area network, we do not need to manually confirm the MAC addresses of all devices, reducing the workload of network engineers. Finally, let's look at some more open related issues. Interested readers can think carefully about the following questions:
|
<<: The challenges of 5G have just begun
The potential of 6G technology will become appare...
DMIT.io has launched a Christmas promotion, inclu...
Today, the online world is slowly transitioning t...
UUUVPS (Sanyou Cloud) has newly launched the AS99...
[[437090]] Let's first look at a set of data....
According to the new research report "Applic...
Frank Scalzo, network director at data center ope...
Recently, my iQiyi membership is about to expire....
edgeNAT has released a special Black Friday packa...
2020 is a critical year for the large-scale const...
The State Council recently issued the "14th ...
Mining is one of the most important industries in...
A sudden epidemic has plunged the whole country i...
The same coverage, the same bandwidth, the same m...
[51CTO.com original article] This morning, Huawei...