How data is directed to the correct application on a host.
While an IP address gets a packet from a source host to a destination host, it doesn't specify which application on the destination host should receive the data. This is the job of port numbers. A port is a 16-bit number (from 0 to 65535) that acts as an endpoint for communication, identifying a specific process or service. For example, a web server typically 'listens' for incoming HTTP requests on port 80. When your browser sends a request to a web server, the request packet includes the server's IP address and the destination port number 80. This allows the server's operating system to deliver the packet to the web server process, not the email server process that might be running on the same machine. Ports are categorized into three ranges. Well-known ports (0-1023) are reserved for standard services (e.g., FTP on 21, SSH on 22, HTTP on 80, HTTPS on 443). Registered ports (1024-49151) are for specific applications registered with IANA. Dynamic or private ports (49152-65535) are used for temporary, outbound connections. For instance, when your browser connects to a web server, it uses a dynamic port as its source port. The combination of an IP address and a port number is called a socket. A connection between two hosts is uniquely identified by the pair of sockets: (source IP, source port) and (destination IP, destination port).