TCP ports

We have seen that the IP address is used to deliver a packet to network and then a host within the network. But, the host will typically be running several applications. Which application is the data intended for? Each TCP segment header has a 16-bit port field which identifies the destination application program. The application programs are said to be "listening" on the specified port.

RFC 1700 assigns many well-known ports. The ports for some of the protocols we have discussed are:

echo          7   for Ping
ftp          20   file transfer (data)
ftp          21   file transfer (control)
telnet       23   establish a connection and log on to remote system
smtp         25   send mail
http         80   World Wide Web
pop3        110   Post Office Protocol - Version 3 (read mail)

The well-known ports are those from 0 through 1023.

Client programs assume that well-known ports are used by default, so, for example, if you give a Web client the URL:

http://som.csudh.edu/
The request will be sent to port 80 on som.csudh.edu.

Default port assignments may be overridden by system administrators. If, for example, a system administrator changed the setup of the Web server running on som.csudh.edu to listen on port 8080, its URL would become:

http://som.csudh.edu:8080/
Some of the port numbers in the range 1024-49151 are also "registered." Many of those are for company-specific protocols, but others, like the following, are not:
http-alt   8008   http alternative
http-alt   8080   http alternative
Ports from 49152 through 65535 are dynamic and may be used by applications in any way.

Firewalls may screen out packets to or from certain ports. You can also override standard ports for testing or security purposes. For example, you might decide to have your development Web server listen on a different port than 80.

Some routing protocols can look "into" packets to see the port number, and, if it is associated with a high-priority application, push the packet to the head of the outgoing queue.

Finally, you can use the netstat command with the -a option to see active connections and the ports they are using as well as the ports that programs are listening to.

In summary, we see that the combination of an IP address plus a port number gets a packet to its final destination -- the IP address identifies the host and the port tells which of the applications the host is running should receive the packet. This combination of an IP address plus a port is called a socket.


Disclaimer: The views and opinions expressed on unofficial pages of California State University, Dominguez Hills faculty, staff or students are strictly those of the page authors. The content of these pages has not been reviewed or approved by California State University, Dominguez Hills.