Current location - Quotes Website - Team slogan - How TCP protocol uses port number to identify application process
How TCP protocol uses port number to identify application process
Port numbers reserved for various public * * * services range from 1 to 1023. The TCP/IP protocol number and port are similar to the parallel port or serial port of PC, and can also be imagined as the intersection of traffic. Programmers use TCP/IP protocol numbers and ports in the upper layers of TCP/IP to select paths for user data packets, but the protocol numbers are used to identify the protocols in the transport layer and the ports are used to identify the program processes in the application layer. 1 TCP/IP protocol number TCP/IP protocol number is an 8-bit value defined by network experts. When the IP datagram arrives at the correct IP address, the network interconnection layer must transmit the datagram to the transport layer, and the protocol of the transport layer is not unique, including at least two main protocols: TCP and UDP. In order to determine which protocol receives lower-layer datagram (or upper-layer user datagram), TCP/IP protocol number must be used. For this reason, the header of IP packet specially opens a "window" for protocol number-protocol domain. The protocol number works as follows: At the sender, the protocol number is used to indicate which protocol is used to encapsulate user data packets. For example, when the protocol number is 6, the network software will use TCP format to encapsulate the data in a data packet. At the information receiver, the network software passes the IP datagram to the protocol corresponding to the protocol number by checking the protocol number. For example, if the protocol number is 17, the datagram is passed to the UDP protocol. The commonly used protocol numbers are shown in the following table 1: protocol name protocol number. This book describes IP0 Internet protocol ICMP 1 Internet message protocol GGP3 gateway-gateway protocol TCP6 transmission control protocol EGP8 external gateway protocol UDP 17 user datagram protocol Xns_IDP22Xerox NS IDPrdp27 reliable data flow protocol rvd66MI. T Remote virtual disk table 1: After the data is transmitted to the transport layer by the IP protocol of the TCP/IP port number network interconnection layer, the transmission protocol should deliver the data to the correct application process. To identify which process it is, you need to use the port number. The port number is a 16 bit value, which is used to distinguish and identify the application process, and it is also specified in the header of the IP datagram. Includes two port numbers: the source port number-representing the process of sending data; Destination Port Number-Represents the process of receiving data. Every application, whether server or client, has a unique port number. In particular, network programs (widely used applications, such as FTP, Telnet and email) specially designed to accomplish specific tasks should use the well-known port numbers as shown in Table 2. Port number keyword base Description 7 Echo Echo 9 Discard11Users Active User 13Daytime Date 15Netstat Network Status 2 1ftp File Transfer Protocol 23Telnet Remote Login 25SMTP email 37Time 43Nicname Alias. Query 69TFTP Universal File Transfer Protocol 79Finger User Information Query 10 1HostnameNIC Hostname Service Table 2: Port Number of Private Programs Users are not allowed to change their own port numbers when using private programs, which is a rule that must be observed. However, the newly developed network communication application can set its own port number, but it cannot conflict with the port number used as public service. Generally speaking, all port numbers less than 255 are reserved for public services (programs), and other regulations should depend on the operating system you use. TCP/IP port is like the house number of every resident. If you want to visit a family, you need to know not only the country, city, community and street where the family is located, but also its house number to get there correctly. The transport layer protocols of TCP/IP (mainly TCP and UDP) have to deal with all kinds of ports directly, especially the connectionless UDP protocol, which focuses on the ports when transmitting data. Of course, the connection-oriented TCP protocol focuses on the connection, not the port, when transmitting data. Applications using TCP can open multiple connections for the same port, and the transmission can still be carried out correctly. In other words, UDP communication is like ordinary mail service. The postman (UDP) only puts the mail (data) into the correct mailbox (port) at home or work, and does not inform the recipient (application) that the mail has arrived. On the other hand, TCP is more like the telephone service of the postal system. Only after the call (connection) is established can the telephone (port) be used for dialogue (data exchange). It should be noted that when writing the sender's application, it is generally not necessary to care about the port number used by the program, but the receiver must know it. Every time the sender transmits a message, the transport layer automatically inserts the correct port number into the source port field of the packet header.