The use of ports
Many TCP/IP programs
can be executed simultaneously over the Internet (you can for example open several browsers simultaneously or browse HTML pages while downloading a file via FTP). Each of these programs works with a protocol, sometimes the computer must be able to distinguish the different data sources.
So, to facilitate this process, each of these applications can allocate a unique address to the machine, coded in 16 bits: a port (the combination of IP address + port is therefore a unique address in the world and is called a socket).
The IP address therefore serves to uniquely identify a computer on the network while the port number specifies the application for which data is intended. In this way, when the computer receives information intended for a port, the data is sent to the related application. If it is a request sent to the application, the application is called a server application. If it is a response, we then talk about a client application.
The multiplexing function
The process which consists of being able to send information from various applications over a connection is called multiplexing. In the same way the matter of managing to compare (thus share among the various applications) the data flow is called demultiplexing.
These operations are carried out thanks to the port, i.e. a number linked to an application type which, when combined with an IP address, makes it possible to uniquely determine an application which is running on a given machine.
There are thousands of ports (these are coded over 16 bits, therefore there are 65536 possibilities) that is why a standard application has been developed by IANA (Internet Assigned Numbers Authority), to help with network configurations.
- Ports 0 to 1023 are the "well known ports" or reserved ports. Generally speaking, they are reserved for system processes (daemons) or programs executed by privileged users. A network administrator can nevertheless link services to the ports of his choice.
- Ports 1024 to 49151 are the "registered ports".
- Ports 49152 to 65535 are the "dynamic and/or private ports".
Here are some of the most commonly used well known ports:
So, a server (a computer that is contacted and which offers services such as FTP, Telnet, etc.) has fixed port numbers to which the network administrator links
the services. So, server ports are generally between 0 and 1023 (value range linked to known services).
On the client side, the port is chosen randomly by the operating system from among those available. So, client ports will never include ports between 0 and 1023 because this value range represents the well known ports.