


Overview of the transport layer: the relationship between ports and processes
Inter-process communication
The transport layer is also called the transport layer, which is a special layer. On the one hand, it belongs to the highest level of the communication part, and on the other hand, it is the lowest level of user functions. The transport layer is used for communication between processes on different hosts. For routers that forward packets, it only has the functions of the lower three layers and does not use the transport layer and above.
Process, that is, the running program. In Linux, when a program runs, the operating system assigns a process number to the process. You can use the command ps aux to view all processes.
# ps aux USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND root 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 uses a 16-bit port number to mark a port, so a host can have 65535 ports . Those who have done web opening must know some commonly used port numbers, such as: 80 of the web server, 3306 of the mysql service and other ports. The processes between the two hosts communicate through their respective port numbers, so the process must also have the function of listening on the port. In Linux, the command to view the monitored port is netstat -tlunp
# netstat -tulnp Active Internet connections (only servers) Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 2449/nginx: worker tcp 0 0 0.0.0.0:21 0.0.0.0:* LISTEN 1010/pure-ftpd (SER tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 1819/sshd ……
The port also has the function of multiplexing and demultiplexing. Multiplexing means that multiple application processes of the host can use the same port number to communicate. , and splitting means that the datagrams obtained from the IP layer can be handed over to different application processes through port numbers.
TCP and UDP
The transport layer has only two protocols: Transmission Control Protocol TCP and User Datagram Protocol UDP. These two protocols have their own characteristics and some application scenarios.
TCP is a connection-oriented protocol. A connection must be established before data is transmitted. If data transmission is not required, the connection needs to be disconnected. TCP is a relatively complex protocol with many factors to consider. It can provide end-to-end reliable transmission, but does not support one-to-many and many-to-many communications. Commonly used TCP protocols include HTTP protocol, ftp protocol, telnet protocol, etc.
UDP is for packets. It is relatively simple and uses best efforts rather than reliable transmission. It can perform one-to-one, one-to-many and many-to-many communication. Common protocols that use UDP protocol include DHCP, DNS, and RIP protocols.
There is an example to illustrate their characteristics: TCP is like making a phone call. A connection must be established before the call. UDP is like sending a text message. You don't need to know the status of the other party's host before sending the text message. You don't know whether the text message has been sent or not.
The above is the detailed content of Overview of the transport layer: the relationship between ports and processes. For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undress AI Tool
Undress images for free

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Bash scripts handle command line parameters through special variables. Use $1, $2, etc. to get positional parameters, where $0 represents the script name; iterates through "$@" or "$*", the former retains space separation, and the latter is merged into a single string; use getopts to parse options with parameters (such as -a, -b:value), where the option is added to indicate the parameter value; at the same time, pay attention to referring to variables, using shift to move the parameter list, and obtaining the total number of parameters through $#.

The shutdown command of Linux/macOS can be shut down, restarted, and timed operations through parameters. 1. Turn off the machine immediately and use sudoshutdownnow or -h/-P parameters; 2. Use the time or specific time point for the shutdown, cancel the use of -c; 3. Use the -r parameters to restart, support timed restart; 4. Pay attention to the need for sudo permissions, be cautious in remote operation, and avoid data loss.

There are three main ways to add a new APT repository: use the add-apt-repository command to be suitable for common PPAs or officially supported repositories; manually create .list files suitable for fine control or non-supporting the former repository; use .deb lines to write source files directly to specific statements provided by the official website. You also need to pay attention to updating the source list and adding GPG keys to ensure security.

The steps to configure an NTP server include installing services, modifying configuration files, checking synchronization status, and setting up a firewall. 1. Install NTP service: Use sudoapt on Ubuntu/Debian, use sudoyum to install on CentOS/RHEL, start and enable the service after installation; 2. Modify the configuration file /etc/ntp.conf: Add trusted upstream servers such as serverntp.aliyun.comiburst and servertime.windows.comiburst, and set allow access to network segments such as restrict192.168.1.0mask255.255.255.0nomod

To set a group disk quota, 1. Confirm the file system to support and enable the mount option; 2. Remount or restart to make the configuration take effect; 3. Initialize the quota database; 4. Use edquota or xfs_quota to set group restrictions; 5. Enable quota and check the usage regularly. Specific operations include editing /etc/fstab to add usrquota, grpquota parameters, using quotacheck or xfs_quota to generate database files, setting soft and hard limits through edquota-g, running quotaon to enable quota, and viewing reports through repquota or xfs_quota. It is recommended to configure timed tasks to monitor quota status.

If you want to know the network connection on your current computer, you can view it through the command line tool; use netstat-ano on Windows to view all connections and PIDs, use ss-tulnp and lsof-i-P to obtain detailed information, and can also be monitored in real time through graphical interface tools such as resource monitor, nethogs, etc.

To create an LVM volume group, you must first prepare a physical volume (PV) and then create a VG. 1. Use pvcreate to initialize the hard disk or partition into PV, such as pvcreate/dev/sdb1; 2. Use the vgcreate command to combine one or more PVs into VG, such as vgcreatemy_volume_group/dev/sdb1/dev/sdc1; 3. You can customize the PE size through the -s parameter and use vgdisplay to view information; 4. You can dynamically expand VG in the future and add a new PV using vgextend; 5. Before deleting VG, you must confirm that there is no LV and delete it with vgremove.

The steps to configure an NFS server are as follows: 1. Install the nfs-utils or nfs-kernel-server package; 2. Start and enable nfs-server and related RPC services; 3. Edit /etc/exports to configure shared directories and permissions, such as rw, ro, sync, etc.; 4. Execute exportfs-a and open the firewall port; 5. The client uses the mount command to mount or configure fstab to achieve automatic mount; Common problems include permission control, ID mapping, RPC service not being started and configuration not being refreshed, and needs to be checked in conjunction with logs.
