The Internet uses port numbers to provide reliable host to host communication. Ports are also used in electronic hardware, but this page is only concerned with ports in relation to the Internet and the Internet Protocol Suite (TCP/IP) (the software that the Internet runs upon). The use of port numbers predates the Internet, they were first used on ARPANET, when they were referred to as socket numbers. The process of cataloging socket numbers began in 1972 - by Vint Cerf and Jon Postel - and led to the present day catalog of port numbers that is maintained by IANA. Socket numbers were then a part of the Network Control Program (NCP); which was replaced by TCP/IP in 1983, and were eventually referred to as port numbers. Why the word 'port'? it is more applicable to the function than the word 'socket', port numbers work in a similar manner to a real world port, boats needing to be directed to a specific berth number, and Internet data needing to be directed to a specific host location.
The Internet Protocol Suite is a set of protocols that are placed within a four layer (application, transport, internet and link) model. The main protocol that creates a data format and address system is the Internet Protocol (IP), it however, creates datagrams that are unreliable, but they do include an IP address to identify a computer or device on the Internet. Many application layer protocols, like HTTP (World Wide Web) require a reliable transmission of data and this is where transport layer protocols come into play. The networking software of operating systems - on the source end of the communication - are responsible for transmitting outgoing data from the correct application port and clients at the destination end of the communication listen (ephemeral port) for service requests.
Internet Protocol (IP) datagrams encapsulate transport layer data segments, such as UDP and TCP, and each data segment includes a header. UDP and TCP headers include a field for a source port number and destination port number. TCP and UDP port numbers are assigned to specific Internet application protocols; file transfer, email, web etc. Port numbers ensure that the data is sent to the correct host location. TCP headers include more fields: TCP is more reliable than UDP, but does so at a cost of speed. Port numbers are a 16-bit integer number and there is a total of 65,535 UDP Ports and 65,535 TCP ports. In conclusion: IP delivers the data, and UDP and TCP check that the data is being sent correctly. This is achieved through the combination of the following fields in the IP datagram: port number in the transport layer data segment headers; transport layer protocol number (TCP or UDP etc) field; and a source and destination IP address.
Port numbers have been assigned historically by the Internet Assigned Numbers Authority (IANA), and in RFC 1340 Jon Postel (who managed IANA) stated "If you are developing a protocol or application that will require the use of a link, socket, port, protocol, etc., please contact the IANA to receive a number assignment."
Popular Port Numbers