The relationship between MAC address and IP address

Source: Internet
Author: User

Simply put: The IP address is the service provider to you, the MAC address is the physical address of your network card.

First, IP address

For IP addresses, I believe everyone is familiar with the 32-bit address assigned to the host using the TCP/IP protocol. The IP address is composed of 4 88-bit groups separated by dots, such as 192.168.0.1 is an IP address, which is called dotted decimal format. The IP address consists of the network address and the host address, and the number of bits assigned to the two parts varies with the address class (Class A, Class B, Class C, and so on). The network address is used for routing, and the host address is used to find a separate host within the network or subnet. An IP address makes it possible for future data from source addresses to be routed to the destination address.

Second, MAC address

For MAC address, because we do not directly contact with it, so people are not necessarily familiar. In the OSI (Open System interconnection, open systems interconnect) 7-Layer Network Protocol (physical layer, Data link layer, network layer, transport layer, Session layer, presentation layer, Application layer) Reference Model, the second layer is the data link layer. It contains two sub-layers, the previous layer is the logical link control (llc:logical link controls), the next layer is the MAC (media access control) layer we mentioned earlier, that is, the media access controls layer. The so-called medium (Media), refers to the transmission of the signal through a variety of physical environment. Commonly used network media including cables (such as: twisted pair, coaxial cable, optical fiber), as well as microwave, laser, infrared, etc., sometimes referred to as physical media. The MAC address is also called the physical address, hardware address, or link address, which is written by the network device manufacturer when it is produced inside the hardware. This address is not related to the network, that is, regardless of the hardware with this address (such as network cards, hubs, routers, etc.) access to the network where, it has the same MAC address, MAC address is generally immutable, can not be set by the user.

Third, the length of the MAC address, the representation method, the allocation method and its uniqueness

The length of the MAC address is 48 bits (6 bytes), usually expressed as 12 16 decimal digits, separated by a colon for every 2 16 digits, such as: 08:00:20:0A:8C:6D is a MAC address, where the first 6 bits of 16 binary 08:00:20 represent the network hardware manufacturer's number, It is assigned by the IEEE (Istitute of Electrical and Electronics Engineers, Electrical and Electronics Engineers Association), and the subsequent 3-bit 16-digit 0A:8C:6D represents the serial number of a network product (such as a NIC) manufactured by the manufacturer. Each network manufacturer must ensure that each Ethernet device it manufactures has the same first three bytes and a different last three bytes. This ensures that every Ethernet device in the world has a unique MAC address.

Four, the role of IP address and MAC address in the interconnection network

Since each Ethernet device has a unique MAC address at the factory, why do you need to allocate an IP address for each host? Or why is it that every host is assigned a unique IP address, and why should a unique MAC address be embedded in the production of network devices such as NICs, hubs, routers, etc.? The main reasons are as follows: (1) The allocation of IP addresses is based on the topology of the network, not on who created the network settings. It is not feasible to build efficient routing schemes on the basis of equipment manufacturers rather than on the topological locations where the network is located. (2) The device is easier to move and repair when there is an additional layer address addressing. For example, if an Ethernet card is broken, it can be replaced without having to obtain a new IP address. If an IP host moves from one network to another, it can give it a new IP address without having to change a new network card. (3) The communication between the local area network and the computer in the wide area network, the end result is that the packet from the initial node of some form of link, from one node to another node, and eventually transferred to the destination node. The movement of packets between these nodes is done by the ARP (address Resolution Protocol: Addresses resolution Protocol) that maps the IP address to the MAC address. Let's look at an example of how IP addresses and MAC addresses are combined to transmit packets.

Suppose the network is going to send a packet (named PAC) to a host in Beijing (called the A,ip address of the Ip_a,mac address of mac_a) to one of the hosts in Washington (with the name B,IP address Ip_b,mac address mac_b). The two hosts can not be directly connected, so the packet is passed through a lot of intermediate nodes (such as routers, servers, etc.), we assume in the transmission process through C1, C2, C3 (its MAC address is m1,m2,m3) three nodes. A before the PAC is emitted, send an ARP request to find the MAC address M1 of the First intermediate node C1 that it must go through to reach ip_b, and then encapsulate (encapsulation) These addresses in their packets: ip_a, Ip_b,mac_a, and M1. When the PAC is passed to C1, it is ip_b by ARP according to its destination IP address, finds the MAC address M2 of the Second intermediate node C2 it is going through, and then transmits the packet with M2 to C2. So and so on, until finally found the address of the Host B with the IP address of ip_b Mac_b, eventually transmitted to host B. During transmission, ip_a, ip_b, and mac_a are unchanged, while the MAC address of the intermediate node is constantly changing through ARP (M1,M2,M3) until the destination address is mac_b.


As described above, we can conclude that the IP address and MAC address are the same point is they are unique, different features are mainly:

1. For a device on the network, such as a computer or a router, its IP address is variable (but must be unique), and the MAC address is immutable. We can assign an arbitrary IP address to a host as needed, as we can assign an IP address of 192.168.0.112 to a computer on the LAN or change it to 192.168.0.200. and any network device (such as network card, router) once produced, its MAC address is always unique and can not be changed by the user.

2. Different lengths. The IP address is 32 bits and the MAC address is 48 bits.

3. The distribution basis is different. The allocation of IP addresses is based on network topology, and the allocation of MAC addresses is based on the manufacturer.

4. The Addressing protocol layer is different. The IP address is applied to the third layer of the OSI, the network layer, while the MAC address is applied to the second layer of the OSI, the data link layer. The Data Link layer protocol enables data to be passed from one node to another on the same link (via MAC address), while the Network layer protocol enables data to be passed from one network to another (ARP locates the MAC address of the intermediary node based on the destination IP address, and transmits it through the intermediate node, thus finally reaching the destination!).
Reprinted from: Http://www.cnblogs.com/hnrainll/archive/2012/11/23/2783697.html:Leo Chin Thinking's Blog

The relationship between MAC address and IP address

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.