What is TCP Services?
The services offered by TCP to the processes at the application layer are as follows:
TCP provides process-to-process communication using port numbers.
Stream delivery services:
TCP, unlike UDP, is a stream-oriented protocol. TCP, on the other hand, allows the sending process to deliver data as a stream of bytes and allows the receiving process to obtain data as a stream of bytes. TCP creates an environment in which the two processes seem to be connected by an imaginary “tube” that carries their data across the internet. This imaginary environment is depicted in the following figure. The sending process produces (writes to) the stream of bytes, and the receiving process consumes (reads from) them.
Sending and Receiving Buffers:
Because the sending and the receiving processes may not write or read data at the same speed, TCP needs buffers for storage. There are two buffers, the sending buffer and the receiving buffer, one for each direction and these buffers are also necessary for flow and error control mechanisms used by TCP. One way to implement a buffer is to use a circular array of 1-byte locations.
The buffering handles the disparity between the speed of the producing and consuming process, we need one more step before we can send data. The IP layer, as a service provider for TCP, needs to send data in packets, not as a stream of bytes. At the transport layer, TCP groups a number of bytes together into a packet called segment. TCP adds a header to each segment and delivers the segment to the IP for transmission.
The segment is encapsulated in IP datagram and transmitted. This entire operation is transparent to the receiving process. The segments may be received out of order, lost, or corrupted and resent. All these are handled by TCP with the receiving process unaware of any activities.
TCP offers full-duplex service, in which data can flow in both directions at the same time. Each TCP then has a sending and receiving buffer, and segments move in both directions. Connection-oriented service:
TCP, unlike UDP, is a connection-oriented protocol. When a process at the site a wants to send and receive data from another process at site B, the following occurs:
The two TCP establishes a connection between them.
Data are exchanged in both directions.
The connection is terminated.
The TCP segment is encapsulated in an IP datagram and can be sent out of order, or lost, or corrupted, and then resent. Each may use a different path to reach the destination. There is no physical connection. TCP creates a stream-oriented environment in which it accepts the responsibility of delivering the bytes in order to the other site.
TCP is a reliable transport protocol. It uses an acknowledgment mechanism to check the safe and sound arrival of data. We will discuss this feature further in the section on error control.