Ports are used to identify processes running in the applications on a host.
Let's assume we have two applications running on one PC that require TCP/IP communications. Assume one is a web browser and the other is an email client.
Both applications send and receive packets with the same IP address, so how does the Transport layer differentiate a web browser packet from an email packet?
The answer is port numbers.
TCP/IP "Well-Known" Ports
“Well-Known" ports are port numbers that have been reserved for common applications, typically server applications. The port numbers assigned to these server applications have to be known by the client’s Transport layer, so they can add the correct destination port number to messages. Clients know that servers will be listening for their requests at these reserved port numbers. This graphic shows some examples of these Well-Known port numbers.
The well known port numbers are assigned by IANA which is the Internet Assigned Numbers Authority. IANA is the same group that manages the DNS Root and IP addresses.
Client side port numbers are generated and assigned by the Transport layer. They could be any number from 1024 to 65535. These port numbers are typically allocated for short term use and are referred to as “Ephemeral or Dynamic Ports”.