0- 1023 is a recognized port number, that is, it has been recognized or reserved for the software to be recognized, while 1024-65535 is a port number that has not been defined by public * * *, and users can define the functions of these ports themselves.
So what does the port number do? Please continue reading.
When a computer starts a program that can be accessed remotely by other computers, it must open at least one port number for external access. We can regard a computer without a port number as a sealed room. Of course, a sealed room cannot be accessed by the outside world, so when the system opens a program that can be accessed by the outside world, it is natural to open a window in the room to receive external access. This window is the harbor.
So why do you want to distinguish the ports by numbering them? Since a program has an open port, can't all external information be accessed through this open port? The answer is no, why? Because data uses port numbers to inform which software the transport layer protocol is sent to for processing, data is unwise. If many programs use one port to receive data, when a packet is sent from the outside, the transport layer will not know which software to send to deal with, which will inevitably lead to confusion.
The Layer 4 header of a data segment encapsulated by the OSI Layer 4 transport layer mentioned last time contains two port numbers, namely the source port number and the destination port number. The function of the destination port number has been introduced above. Let us know the original port number.
The source port number is generally a number between 1024-65535 dynamically generated by the system itself. When computer A accesses computer B through the network, if the other party needs to return data, it will also randomly create a port larger than 1023, telling B which port to send data to when returning data, and then the software will start listening to this port and wait for the data to return. B After receiving the data, it will read the source port number and destination port number of the packet, and then record it. When the software creates the data to be returned, it will take the original port number in the original data packet as the destination port number and its own port number as the original port number, that is, it will reverse the original and destination in the received data packet and send it back to A. A will repeat this process until the data transmission is completed. When all data is transmitted, the source port is released, so the same software does not necessarily have the same source port number every time it transmits data.