Get the App
SLTechnology News&Howtos  ›  Servers  › 

What is the relationship between ports and processes in the transport layer of the server

Shulou Source: shulou.com Published: 2022-06-02 00:21:32 09月15日 Update

This article will explain in detail the relationship between ports and processes in the transport layer of the server. The editor thinks it is very practical, so I share it with you as a reference. I hope you can get something after reading this article.

Interprocess communication

The transport layer, also known as the transport layer, is a special layer. On the one hand, it belongs to the highest level of communication, on the other hand, it is the lowest level of user functions. The transport layer is for communication between processes of different hosts. For routers that carry out packet forwarding, it only has the functions of the lower three layers and does not need the transport layer and the upper layer.

Process, that is, the program that runs. In linux, when a program runs, the operating system assigns a process number to the process. You can view all processes with the command ps aux.

# ps aux USER PID% CPU% MEM VSZ RSS TTY STAT START TIME COMMANDroot 1 0.0 0.1 51744 2808? Ss Jul31 16:06 / usr/lib/systemd/systemd-switched-root-system-deserialize 22.

Port

The transport layer of TCP/IP marks a port with a 16-bit port number, so a host can have 65535 ports. Those who have done web open must know some common port numbers, such as: 80 of web server, 3306 of mysql service, and so on. The processes between the two hosts communicate through their respective port numbers, so the process must also have the ability to listen on the port. In linux, the command to view the listening port is netstat-tlunp

# netstat-tulnpActive Internet connections (only servers) Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name tcp 0 0 0.0.0.0 only servers 80 0.0.0.0 only servers * LISTEN 2449/nginx: worker tcp 00 0.0.0.015 21 0.0.0 0 LISTEN 1010/pure-ftpd (SER tcp 0 0. 0. 0. 0. 0. 0. 0. LISTEN 1819/sshd. 22. 0. 0. 0. 0.

The port also has the function of multiplexing and demultiplexing, which means that multiple application processes of the host can communicate with the same port number, while the Datagram obtained from the IP layer can be given to different application processes through the port number.

TCP and UDP

There are only two protocols in the transport layer: the transmission control protocol TCP and the user Datagram protocol UDP. The two protocols have their own characteristics and some scenarios of their own applications.

TCP is a connection-oriented protocol. Before transferring data, a connection must be established, and if there is no need for data transmission, it needs to be disconnected. TCP is a complex protocol and many factors need to be considered. It can provide reliable end-to-end transmission, but does not support one-to-many and many-to-many communications. The common TCP protocols are HTTP protocol, ftp protocol, telnet protocol and so on.

UDP is message-oriented, it is relatively simple, it is the best effort rather than reliable transmission. It can communicate one-to-one, one-to-many and many-to-many. The common protocols that use UDP protocol are DHCP, DNS and RIP.

There is an example to illustrate their characteristics: TCP is like making a phone call, and a connection must be established before making a call. While UDP is like sending a text message, you don't need to know the status of the other party's host before sending the message, and you don't know whether the message is sent or not.

This is the end of the article on "what is the relationship between ports and processes in the transport layer of the server". I hope the above content can be helpful to you, so that you can learn more knowledge. If you think the article is good, please share it for more people to see.

Tags: Process transport port communication host slogan between service function data server two SMS article application different only command common more Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno NVidia OPPO Reno Shulou Information Redmi Linux