This section introduces the concepts of the port and socket, which are needed to determine which local process at a given host actually communicates with which process, at which remote host, using which protocol. If this sounds confusing, consider the following points:
· An application process is assigned a process identifier number (process ID), which is likely to be different each time that process is started.
· Process IDs differ between operating system platforms, thus they are not uniform.
· A server process can have multiple connections to multiple clients at a time, thus simple connection identifiers are not unique.
The concept of ports and sockets provide a way to uniformly and uniquely identify connections and the programs and hosts that are engaged in them, irrespective of specific process IDs.
· An application process is assigned a process identifier number (process ID), which is likely to be different each time that process is started.
· Process IDs differ between operating system platforms, thus they are not uniform.
· A server process can have multiple connections to multiple clients at a time, thus simple connection identifiers are not unique.
The concept of ports and sockets provide a way to uniformly and uniquely identify connections and the programs and hosts that are engaged in them, irrespective of specific process IDs.
Ports
Each process that wants to communicate with another process identifies itself to the TCP/IP protocol suite by one or more ports. A port is a 16-bit number used by the host-to-host protocol to identify to which higher-level protocol or application program (process) it must deliver incoming messages. There are two types of ports:
1. Well-Known: Well-known ports belong to standard servers, for example, Telnet uses port 23. Wellknown port numbers range between 1 and 1023 (prior to 1992, the range between 256 and 1023 was
used for UNIX-specific servers). Well-known port numbers are typically odd, because early systems using the port concept required an odd/even pair of ports for duplex operations. Most servers require only a single port. Exceptions are the BOOTP server, which uses two: 67 and 68 and the FTP server, which uses two: 20 and 21. The well-known ports are controlled and assigned by the Internet Assigned Number Authority (IANA) and on most systems can only be used by system processes or by programs executed by privileged users. Well-known ports allow clients to find servers without configuration information. The well-known port numbers are defined in STD 2 – Assigned Internet Numbers.
2. Ephemeral: Some clients do not need well-known port numbers because they initiate communication with servers, and the port number they are using is contained in the UDP/TCP datagrams sent to the server. Each client process is allocated a port number, for as long as it needs, by the host on which it is running. Ephemeral port numbers have values greater than 1023, normally in the range of 1024 to 65535. Ephemeral ports are not controlled by IANA and can be used by ordinary user-developed programs on most systems. Confusion, due to two different applications trying to use the same port numbers on one host, is avoided by writing those applications to request an available port from TCP/IP. Because this port number is dynamically assigned, it can differ from one invocation of an application to the next. UDP, TCP, and ISO TP-4 all use the same port principle. To the best possible extent, the same port numbers are used for the same services on top of UDP, TCP, and ISO TP-4.
Sockets
The socket interface is one of several application programming interfaces to the communication protocols. Designed to be a generic communication programming interface, socket APIs were first introduced by Berkeley Software Distribution (BSD). Although it has not been standardized, Berkeley socket API has become a de facto industry standard abstraction for network TCP/IP socket implementation. Consider the following terminologies:
· A socket is a special type of file handle, which is used by a process to request network services from the operating system.
· A socket address is the triple: <protocol, local-address, local port> For example, in the TCP/IP (version 4) suite: <tcp, 192.168.14.234, 8080>
· A conversation is the communication link between two processes.
· An association is the 5-tuple that completely specifies the two processes that comprise a connection:
<protocol, local-address, local-port, foreign-address, foreign-port>
In the TCP/IP (version 4) suite, the following could be a valid association:
<tcp, 192.168.14.234, 1500, 192.168.44, 22>
· A half-association is either one of the following, which each specify half of a connection:
<protocol, local-address, local-process>
Or:
<protocol, foreign-address, foreign-process>
The half-association is also called a socket or a transport address. That is, a socket is an endpoint for communication that can be named and addressed in a network. Two processes communicate through TCP sockets. The socket model provides a process with a full-duplex byte stream connection to another process. The application need not concern itself with the management of this stream; these facilities are provided by TCP. TCP uses the same port principle as UDP to provide multiplexing. Like UDP, TCP uses well-known and ephemeral ports. Each side of a TCP connection has a socket that can be identified by the triple <TCP, IP address, port number>. If two processes are communicating over TCP, they have a logical connection that is uniquely identifiable by the two sockets involved, that is, by the combination <TCP, local IP address, local port, remote IP address, remote port>. Server processes are able to manage multiple conversations through a single port.
Explain Ports and Sockets.
Reviewed by enakta13
on
October 02, 2012
Rating: