Principles Digital Communication System & Computer Networks (Charles River Media Computer Engineering)

 < Day Day Up > 


22.2 TRANSMISSION CONTROL PROTOCOL

Transmission Control Protocol (TCP) is a connection-oriented protocol that provides reliable communication across an internet. TCP is equivalent to ISO transport layer protocol.

The units of data exchanged between two end systems are called TCP segments. Ordinarily, TCP waits for sufficient data to be accumulated to create a TCP segment. This TCP segment is given to the IP layer. The TCP user (the application layer) can request the TCP to transmit data with a push flag. At the receiving end, TCP will deliver the data in the same manner. This mechanism is known as data stream push.

When urgent data is to be transmitted, urgent data signaling is used, which is a means of informing the destination TCP user that urgent data is being transmitted. It is up to the destination user to determine appropriate action. In the TCP segment, there is a field called urgent pointer to indicate that the data is urgent.

When a TCP connection is to be established between two end systems, commands are used from the TCP user (the higher layer protocol), which are known as TCP service request primitives. Responses, which are known as TCP service response primitives, are sent from the TCP to the TCP user.

The TCP service request primitives are:

The TCP service response primitives (issued by TCP to local TCP user) are:

Whenever a connection has to be established, the service request primitives are sent to the TCP, and the TCP sends the service response primitives. If there are no errors, a connection is established with the other TCP peer running on another machine, and data transfer takes place. After successful transfer of data, the application layer is informed by the TCP layer that the data has been successfully transferred.

The TCP layer provides a connection-oriented service. A TCP connection is established between two end systems, and a series of service request primitives and service response primitives is exchanged for connection management, data transfer, and error reporting.

22.2.1 Virtual Circuit Connection

Before two end systems transfer data, a TCP connection is established. This is a virtual circuit connection. A connection is established between the TCP protocol ports, which identify the ultimate destination within the machines. This connection is full duplex, so the data flows in both directions. Note that the TCP connection is only an abstraction; it is not a real connection because the IP datagrams take different routes to reach the destination.

Each connection is identified by a pair of end points. Each end point is defined by the host number and the port number. The host number is the IP address, and the port number is a predefined small integer. The port number is a process ID running on end systems—there will be no physical port. For instance, a connection can be represented by the two end points

A TCP connection is identified by a pair of end points. Each end point is defined by the IP address (host number) and the port number. Port number is a predefined small integer.

(125.34.5.7, 25) and (230.16.4.23, 53)

It is possible to establish multiple connections between two end points as shown in Figure 22.1. For instance, one of the above end points can have another connection such as

(125.34.5.7, 25) and (240.5.4.2, 53)

Figure 22.1: Multiple TCP connections.

Hence, a given TCP port number can be shared by multiple connections.

22.2.2 TCP Segment Format

The TCP segment consists of the TCP header and protocol data unit (PDU) data. The format of the TCP header is shown in Figure 22.2. The minimum header length is 20 bytes.

Figure 22.2: TCP segment format.

Source port address (16 bits): The port number that identifies the application program of the source.

Destination port address (16 bits): The port number that identifies the application program of the destination.

Sequence number (32 bits): The sequence number of the TCP segment.

Acknowledgement number (32 bits): The number of the octet that the source

Header length (4 bits): The length of the header in 32-bit words. This is required because the header length varies due to the presence of the options field.

Reserved (6 bits): Reserved for future use.

Code bits (6 bits): Specify the purpose and content of the segment. The six bits are URG, ACK, PSH, RST, SYN and FIN. If these bits are set, the following information is conveyed:

URG

Urgent pointer field is valid.

ACK

Acknowledgment field is valid.

PSH

The segment requests a push.

RST

Reset the connection.

SYN

Synchronize the sequence numbers.

FIN

Sender has reached end of its byte stream.

Window (16 bits): Specifies the buffer size, which indicates how much data it is ready to accept, beginning with the byte indicated in ACK field. This is flow control information.

Checksum (16 bits): Checksum is calculated from the header fields and the data fields. For checksum computation, the pseudoheader is used. The pseudoheader consists of 96 bits—32 bits of source IP address, 32 bits of destination IP address, 8 bits of zeros, 8 bits of protocol, and 16 bits of TCP length. This data is obtained from the IP layer software, and checksum is calculated using the same one's complement of 16-bit words and taking the one's complement of the result. The protocol field is to specify which underlying protocol is used; for IP, the value is 6.

The TCP segment header consists of the following fields: source port address, destination port address, sequence number, acknowledgement number, header length, reserved bits, code bits, window size, checksum, urgent pointer and options. The minimum header length is 20 bytes.

Urgent pointer (16 bits): This field is used to indicate that the data segment is urgent. The destination has to process this segment even if there are other segments to be processed. This is required in such applications as remote login, when the user has to abort a program without waiting any further.

Options, if any (variable): This field is used to negotiate the maximum TCP segment size. The TCP software can indicate the maximum segment size (MSS) in this field. Otherwise, a segment size of 536 bytes is used. This value is 576 bytes of default IP datagram minus the TCP and IP header lengths.

Padding (8 bits): Padding for making the TCP segment complete.

Data (variable): User data, which is of variable length.

22.2.3 TCP Mechanism

For data transfer, there will be three phases: connection establishment, data transfer, and connection termination.

Connection Establishment

The connection is determined by the source and destination ports. Some of the important currently assigned TCP port numbers are given in the following table:

Port number

Application

Description

21

FTP

File Transfer Protocol

23

Telnet

remote login

25

SMTP

Simple Mail Transfer Protocol

37

time

time

42

nameserver

hostname server

53

domain

Domain Name Server

79

Finger

Finger

80

HTTP

World Wide Web

103

x400

X.400 messaging service

113

auth

authentication service

Only one TCP connection is established between a pair of ports. However, one port can support multiple connections, each with a different partner port as shown in Figure 22.1. Handshaking is used for establishing the connection using the following procedure:

Data Transfer

The data is transferred in segments but viewed as a byte stream. Every byte is numbered using modulo 232. Each segment contains the sequence number of the first byte in the data field. Flow control is specified in the number of bytes. Data is buffered by the sender and the receiver, and when to construct a segment is at the discretion of the TCP (except when push flag is used). For priority data, an urgent flag is used. If a segment arrives at a host and the segment is not meant for it, an rst flag is set.

Connection Termination

Each TCP user issues a close primitive. TCP sets the fin flag on the last segment. If the user issues an abort primitive, abrupt termination is done. All data in buffers is discarded and an rst segment is sent.

To implement the TCP, there are a few implementation options, which are briefly discussed.

Send policy: When does the TCP layer start sending the data to the layer below? One option is to buffer the data and construct the TCP segment. The other option is not to buffer the data and construct the TCP segment when some data is available to be sent to the layer below.

Delivery policy: After the data is received from the layer below, when to transfer the data to the upper layer (the TCP user) is another issue. One option is to buffer the TCP segment and send to the TCP user. The other option is to send without buffering. When to deliver is a performance consideration.

A TCP connection is established between two TCP ports on two end systems. Only one connection can be established between a pair of ports. However, one port can support multiple connections, each with a different partner port.

Accept policy: If segments are received out of sequence, there are two options:

Retransmit policy: Three retransmission strategies are possible.

Acknowledgement policy: There are two options here.

Note 

The port number is a predefined integer for each application that runs above the TCP layer. Some important port numbers are: 21 for FTP, 25 for SMTP, and 80 for HTTP.


 < Day Day Up > 

Категории