MAC address, IP address, and port number

Source: Internet
Author: User

Looked at many times, just to sort out my understanding of the whole communication process, the following, will continue to learn to supplement the correction:

When communicating using the TCP/IP protocol family, there are three key identifying information: MAC address, IP address, and port number.

    • The MAC address is wrapped in the Ethernet header at the data link layer, which is used primarily to identify different computers in the same link. MAC address is the network card number, each NIC factory, there is a world-wide unique MAC address, the length is 48 bits, usually in 12 hexadecimal digits.
    • IP Address is in the IP header of the network layer, used to identify the network interconnection of the host and router, in fact, mainly to confirm the subnet, through the subnet mask to confirm the subnet of an IP address, and then confirm the MAC address inside the subnet to find the correct user.
    • The port number is included in the TCP/UDP header in the transport layer and is used to identify the application. If you can run multiple programs on a single host, which program is the received message? You need a port number to confirm it.

There are two types of port numbers:

      • Fixed port number, which is a fixed port number used by applications that are widely used in form such as Http,telnet,ftp
      • Dynamically assigned port number, this time the server to determine the listening port number, the client receiving service does not need to determine the port number

The port number is determined by the Transport layer protocol, so the non-transport protocol can use the same port number, so TCP and UDP can use the same port number

For example, when host a sends a message to Host B, the port number of the application that sent the message is included in the TCP head, and the port number of the receiver application is passed to its next layer, and the network layer encapsulates the TCP packet and adds its own head. The IP header contains information such as local IP and receiver IP, which is passed to the data link layer. The data link layer adds an Ethernet header, which contains both MAC addresses. So the other side IP and port number are good, but how to get the MAC address? This time requires the ARP protocol, this is not to say, straight to the known MAC address and IP address port number in the case of how to send a message.

First, the Ethernet packet is broadcast inside its subnet, and if the receiver is within its subnet, the data is received directly after the MAC address. If not in the same subnet, the Ethernet protocol will not be able to achieve data transmission, and because the Ethernet protocol to broadcast the way to send messages, even if not confined to the subnet, if the very large host group broadcast messages is very scary. This time requires an IP address, the IP address is mainly used to differentiate which MAC address on the same subnet. After locating the destination host subnet and then confirming the host according to the MAC address, the IP layer will pass the packet to the corresponding protocol after the Protocol is determined from the IP header, and then the protocol is used to confirm the port number of the program.

MAC address, IP address, and port number

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.