In a network, the data packet from the source has to finds its way to
- Destination network
- Destination host
- Destination application
The logical address like the IP address locates the network and host. The physical delivery of the packet happens using the MAC address of the host. On the located host there may be many applications running. To identify the right application to which the packet should be delivered, it’s required one more identification at the Layer 4 of the OSI stack.
The Layer 4 protocols such as TCP & UDP facilitates in locating the right application by associating each application a port number so that multiple applications’ data can be multiplexed and demultiplexed without ambiguity. This application identification using port numbers is what I call Layer 4 addressing. Strictly speaking its not an address like IP address or MAC address, however does the same job as them by locating the application running on the host.
The port number is a 16-bit unsigned integer which means it can take the value in the range 0-65535. In other words, 65536 running applications(processes) can be uniquely identified on the remote host at any given time. That’s far too many in a typical computing environment. The port numbers fall in 2 categories.
- Well-known or privileged ports : [ 0 – 1023 ]
- Random or unprivileged ports : [ 1024 – 65535 ]
The well-known ports are also called server ports, meaning they are the ports the services listen on for incoming requests. Well-known ports are standard and constant for every service, and no application can use them, which is why they are also known as reserved ports. Well-known ports are the packet’s destination port which requests service running on the server.
The random, unprivileged and non-standard ports are used in the source port field of the TCP/UDP header. Random ports are available for application developers and vendors to provide their services. Even in random port space many ports are standard offering specific services and we should be aware of them.
Below is a list of major TCP and UDP ports worth memorizing: