The origin of the transport layer includes the MAC address and IP address. We can establish communication between any two hosts on the Internet. Many programs on the same host need to use the network. For example, you can browse the Web page and chat with friends online. When a packet is sent from the Internet, how do you know whether it indicates the content of the webpage or the content of online chat? That is to say, we also need a parameter to indicate which program (process) the data packet is used. This parameter is called "port", which is actually the number of each program using the NIC. Each packet is sent to a specific port of the host, so different programs can obtain the data they need. "Port" is an integer between 0 and 65535, exactly 16 binary digits. Ports 0 to 1023 are occupied by the system. You can only use ports greater than 1023. The application selects a random port for browsing the Web page or chatting online, and then contacts the corresponding port of the server.
The function of "Transport Layer" is to establish "port-to-port" communication. In contrast, the "Network Layer" function is to establish "Host-to-host" communication. As long as the host and port are determined, we can implement communication between programs. Therefore, the Unix system calls host + port "socket ). With it, you can develop network applications.