Introduction to TCP, UDP, and port numbers

TCP and UDP protocols

TCP (Transmission Control Protocol) and UDP (User Datagram Protocol) 

  • The IP protocol is responsible for connecting multiple packet-switched networks and managing the protocol for communicating IP source and destination addresses.
  • TCP and UDP protocols are important protocols located between the application layer and the IP layer and are responsible for information transmission between them.

Characteristics of TCP and UDP

 We can see from the above that if it is a basic service function, it is best to use the TCP protocol to ensure the reliability of the service. To ensure that every network packet reaches its destination correctly during the process. Compared with UDP, programmers need to further handle packet loss and byte transmission order by themselves.

Ports and their characteristics

        The port number is part of the transmission protocol, so we can say that the data is sent to the specified device through the IP address, and the data is sent to the specified service or program through the port number. 

        The program generally not only listens to the specified port number, but also identifies the corresponding transmission protocol. Therefore, when we transmit data, we must specify both the corresponding port number and the corresponding communication protocol. Many people will just say: Program A listens to port 33001. This is incorrect, at least not completely correct. . Correspondingly, we should say this: Program A uses TCP protocol and listens on port 33001. Of course, you can also say: Program A uses UDP protocol and listens on port 33001.

       The obvious benefit of specifying the transmission protocol and port is that when we perform port forwarding or build a network firewall, we can easily isolate by protocol and port. To prevent unforeseen accidents. For computers, this method can prevent various unnecessary data from the external network from entering the local LAN.

       With so many port numbers, if everyone uses the same one, wouldn't there be a conflict? Yes, this requires a specialized organization to manage them, IANA (Internet Assigned Numbers Authority), which is responsible for managing port registrations. Most mainstream programs have a clear registered port, such as the common FTP listening port 20, 21, and the HTTP service listening port 80, etc. If a program wants to register a port, IANA will first check whether the port has been registered. If it has been registered, it will reject the application.

Port numbers are divided into three types based on range

    1.Well-Known Ports (well-known port numbers)

It is some well-known port numbers, which are fixedly assigned to some services. The HTTP service, FTP service, etc. we mentioned above all belong to this category. The range of well-known port numbers is: 0-1023

    2.Registered Ports (registered ports)

It is a segment of ports that cannot be dynamically adjusted. These ports do not clearly define which specific objects they serve. Different programs can be defined according to their own needs. The range of registered port numbers is: 1024-49151

    3.Dynamic, private or ephemeral ports (i.e. dynamic, private or temporary port numbers)

As the name implies, these port numbers cannot be registered. The ports in this section are used for some private or customized services. Of course, they can also be used for dynamic port services. The range of this section is: 49152–65535

       

Supongo que te gusta

Origin blog.csdn.net/2302_78587828/article/details/132780812
Recomendado
Clasificación