laitimes

With an IP address, why use a MAC address?

author:IP Data Cloud

MAC address

The MAC address is equivalent to the recipient's name on the courier package.

MAC addresses exist more often to confirm each other's information. Just as a courier crosses several cities to come to you, the courier needs to confirm with you that the recipient is correct before handing you the package.

With an IP address, why use a MAC address?

IP66 online check IP address location: https://www.ip66.net/?utm-source=LJ&utm-keyword=?1146

With an IP address, why use a MAC address?

Here we simulate a scenario, for example, in the same class in the school, everyone knows each other, and they do not need to use the student number (here abstracted into IP address) to communicate with each other, and directly shout the name. "Hey, who is that, let me copy your homework."

With an IP address, why use a MAC address?

This process can correspond to LAN communication with the same switch or hub in the network. Communication in a local area network requires communication via MAC address. When the data is encapsulated into frames, the source MAC address and destination MAC address are inserted (if the other MAC address is not known, an ARP broadcast packet is sent to obtain the MAC address of the other party). Ethernet frame structure:

With an IP address, why use a MAC address?

Then, the frame structure adds the IP header information again.

With an IP address, why use a MAC address?

Although there is an IP address here, it does not work in a local area network because ARP is used for addressing in the network, and all hosts in the local area network are visible to each other. (In addition, the IP address in the LAN is at most used as the basis for determining whether it is the destination host when the host receiving the packet is unpacked, and thus chooses whether to respond to the ARP response).

With an IP address, why use a MAC address?

The conditions for the use of IP addresses are after crossing the network. Communication between two networks requires a medium because hosts inside the network cannot locate a host outside the network, even if they are separated by only one network segment. (Welcome to pay attention to the public number: network engineer Along) And the medium of cross-network segment is the router, as long as the IP address is told to it, he can find the network where the other party is.

It's like I'm a Class of 2020 Computer Science Class 1 student xx (student number 202015162, 15 refers to the major computer science major, 62 refers to the student number of "me" in this class), I now want to find the class of 2022 junior YY (student number 2022... )。 We don't know each other, but I can find an intermediary to deliver the letter for me.

With an IP address, why use a MAC address?

This middleman is the LAN gateway, which is the router. Their function is to relay my message and send it to the next "middleman" by destination IP address, and finally to "yy".

Here's the love-hate entanglement about MAC addresses vs IP addresses... The following is borrowed from the article: "Flash Sun (Low Concurrency Programming): If You Were Designing a Network"

First of all, we need to make it clear that MAC addresses were born before IP addresses. At the beginning of computer design, devices used MAC addresses to confirm each other's identities, because the network topology at that time was not large, and we could let two computers send data to each other. If there are 5 hosts that need to communicate with each other, then its topology might look like this:

With an IP address, why use a MAC address?

If this is the case, we don't really need a MAC address, because each NIC corresponds to a specific host. In fact, a computer needs to spend more money to configure so many network cards, and you don't want to buy a computer and then buy an additional dozen network cards.

Therefore, it is more convenient that we can use a hub to gather all computers together through network cables.

With an IP address, why use a MAC address?

Each host needs to carry its own and the other party's destination MAC address before sending data, because the hub hub only sends all data out of other interfaces, and it leaves the host to judge whether to receive data.

With an IP address, why use a MAC address?

The hub is just brainless to do data sending, so we think of it as a data link layer device.

The hub is so stupid that it sends every communication to all hosts, which can cause network congestion or even paralysis when there is frequent communication between hosts, so we upgraded and used switch equipment.

The switch maintains a table of MAC addresses internally that records the relationship between MAC addresses and the ports of the switch, so that there is no need to send all data to the LAN. Cisco's Cisco packet tracer emulation software can see the MAC address table of the switch.

With an IP address, why use a MAC address?

In this way, when PC0 (192.168.1) pings PC3 (192.168.4), the switch checks its MAC table and finds that the exit of the Ethernet FA0/4 interface corresponds to the MAC address of the destination host, and the switch forwards its own data packet from the FA0/4 interface. At the same time, PC3 receives a data packet from PC0.

The switch is relative to the hub and has the function of deciding which port of the switch the data is forwarded from, so we think of the switch as at the data link layer (deciding which link the data is forwarded to).

The above hubs and switches are all local area network access, and no IP address is required. As the network expands, LAN rules are no longer suitable.

Many local area networks like the one described above make up one big Internet. They are connected to each other and communicate with each other.

With an IP address, why use a MAC address?

If materials shared with a research institution are accessed within the school network, this is cross-network access. This is where the IP address comes in handy. The IP address gives a hierarchical number address, which is like a mind map that can efficiently find the one we want by giving the address.

When a network connects to the Internet, assign it an IP address, so that these IP addresses can determine the location of the other network (or device) in the Internet for access.

With an IP address, why use a MAC address?

The IP connected to the Internet can be a single device, such as a server, a webcam, etc., or a local area network, such as the school's campus network, the company's internal network, etc. (LAN and public network communication using NAT, PAT and other methods, or intranet penetration and other technologies).

In order to realize access across network segments in the network, a new device called router is born. It can decide which network to forward the packet to based on the built-in routing entries, which can eventually reach the destination network.

With an IP address, why use a MAC address?

It should be noted that the router is the middleman of multiple networks, and it has many ports in different networks (each port of the router has an independent MAC address and IP address), so that it can forward "information from network A to network B, because the router's interface is connected to these networks at the same time".

With an IP address, why use a MAC address?

Routers allow data to communicate across networks in a network, so we think of routers as devices at the network layer.

Finally, we have sorted out the relationship between the entire IP and MAC. To summarize:

  • When transferring data between devices, you need to use the MAC address to determine the identity of the other party (scenario: jump between two routers, host communication in the local area network).
  • The passage between various networks requires the use of IP addresses, mainly to locate the location of the destination address https://www.ip66.net/?utm-source=LJ&utm-keyword=?1146, and deduce a path from the source IP to the destination IP through the IP segmentation mechanism, and then the data is delivered by the packet through this path.