Processes and Interprocess Communications

There are many definitions of the term process in the context of a general-purpose computing system (or host). The following are typical: What is interprocess communications? It occurs when a process sends to and receives information from another process, whether running on the same system or connected by a network.

Typical examples of interprocess communications mechanisms include files (limited to shared filesystems), pipes (only useful where processes share a common parent process), shared memory, named pipes, message passing, and sockets.

The socket abstraction is the usual method of performing network-based interprocess communications in UNIX and many other systems. Sockets provide the interface to the transport layer, TCP, see later.


The TCP Protocol

The dominant transport protocol in the universe is the Transmission Control Protocol (TCP) used in the Internet.

TCP is always implemented in conjunction with IP, the Internet Protocol[1] which provides the necessary network service. It is important to note that IP provides an "unreliable" packet delivery service, and may fail to deliver some packets. Furthermore, it may accidentally duplicate packets, and may even deliver them out of order.

The function of the TCP protocol, then, is to provide a:

reliable
all data is delivered correctly
connection-oriented
the protocol provides procedures for establishing interprocess connections.
byte stream
ie, no visible packetisation so far as the application processes are concerned
end-to-end
...interprocess communications service.

[1] See later.


TCP Operation

In order to provide reliable, connection oriented service, TCP breaks the incoming application byte stream into segments.

The last byte in each segment is identified with a byte count field in the segment header.

[2] The TCP timeout algorithm uses observed round trip times, and measures of their variability, to calculate a continuously updated best estimate of when to resend.


Format of a TCP Segment

TCP transmits data in segments. A segment contains a header and some data, thus:

Note:


Reliable Transmission

We can visualise the transmission of a TCP segment as follows:

If a segment is lost in the network, the sender times out and re-transmits, thus:


TCP Port Numbers

TCP provides an interprocess delivery system, so it needs to identify processes in the two "end systems" which it connects.

To do this, it defines an abstract address called a port number. Two processes can communicate by agreeing on the port numbers they will use for communications. Port numbers are the addresses of the TCP protocol - each segment contains port numbers for each of the sending and receiving processes[3].

In order to set up a TCP connection, a process notifies the TCP software that it is waiting for connections "at" a certain port number. By definition, such a process is called a server. A client process which needs to connect to the server asks its local TCP software to allocate an unused port number and establish the connection. Once the connection is established, the two processes can communicate.

In order to manage TCP connections, a group of port numbers (0 to 1023) have been defined to be used by processes providing well known services. Most UNIX systems provide server processes corresponding to all the well-known services.

[3]* In the second lecture they were referred to as Service Access Points (SAPs)


TCP Servers and Clients

Initially:

Note that the port number is used to name processes. Because the client establishes communication, it does not need a well-known port number, and so an unused one (> 1023) is randomly allocated by the TCP software, eg:


TCP Connection Establishment

The connection phase in TCP uses a 3-way handshake of control segments:

The 3-way handshake is necessary because TCP is layered on the unreliable datagram service provided by IP, so that these control segments can be lost, duplicated or delivered out of order.

This could lead to trouble if original or retransmitted segments arrive while the connection is being established - the handshake used overcomes this problem.

A TCP connection is closed using another (modified) 3-way handshake sequence involving the use of FIN control segments. An interesting consequence of the full-duplex nature of TCP, and the concept of graceful close is that a TCP connection can be half-open if one side closes the connection and the other does not.


This lecture is also available in PostScript format. The tutorial for this lecture is Tutorial #02.
[Previous Lecture] [Lecture Index] [Next Lecture]
Phil Scott