The Transport Layer protocols, such as the Transmission Control Protocol (TCP) and the User Datagram Protocol (UDP), are the primary users of TCP/IP ports. The sockets created by each host that is used in the communication session are known as socket pairs or endpoint pairs. These sockets or endpoints allow hosts to create more than one session to allow for multiple communication channels to be active at any given time between various hosts.
Port Ranges
There are clearly defined port numbers for every popular or well-known TCP/IP application. A port number is a 16-bit value between 0 and 65,535. Within this range of ports, some port numbers are established for specific services, some are reserved for certain applications, and others are available for temporary use by applications. Web servers, for example, use port number 80 because client browsers are developed to connect to web servers using the HTTP protocol on port 80. Port numbers from 0 to 1023 are called well-known ports and are reserved for specific TCP/IP application services. The range of port numbers from 1024 to 49151 are the Registered, also known as User ports. These ports are assigned by IANA for specific services upon application by a requesting entity. The range from 49152 to 65535 are above the registered ports. This range is reserved for the Dynamic and/or Private ports that cannot be registered with IANA. This range is used for custom or temporary purposes and for automatic allocation of ephemeral ports.
Well-Known Ports
The port numbers in the range from 0 to 1023 are the well-known, also known as System ports. They are used by system processes that provide widely-used types of network services. Examples of some of the most commonwell-known ports are: If we take the example of a host system trying to access a web server, the source system will craft a packet to send to the destination IP address on port 80. Since port 80 is a well-known port for HTTP, in most cases, if you wanted to host a web server, you would not change the web server’s default port. If you did configure the web server to run on a different port, you would have to communicate this information to your users since the client applications that they are using (web browsers) are expecting to connect to the web server on port 80. In this scenario, the client that established this connection with the web server will use a port in the Private/Dynamic range. For example, the source IP:source port may be 192.168.1.1:50125 for the client. When the web server sends back a packet to the client it will send it back to this IP and port (socket/endpoint). For more information about port numbers or to get a complete listing of reserved and registered ports, please visit the Service Name and Transport Protocol Port Number Registry.