TCP Services PROTOCOL
TCP Services PROTOCOL
21.3
Services provided by the TCP
21.4
Services provided by the TCP
In practice, the TCP may send only a part of data due to the slowness of the receiving
process or congestion in the network.
The buffer at the receiver is divided into two parts as mentioned below:
The part was containing empty locations.
The part was containing the received bytes, which the sending process can consume.
21.5
Bytes and Segments
Buffering is used to handle the difference between the speed of data transmission
and data consumption. But only buffering is not enough.
We need one more step before sending the data on the Internet Protocol (IP) layer as
a TCP service provider. It needs to send data in the form of packets and not as a stream
of bytes.
At the transport layer, TCP groups several bytes into a packet and this is called a
segment. A header is added to each segment to exercise control.
The segment is encapsulated in an IP diagram and then transmitted. The entire
operation is transparent to the receiving process. The segment may be deceived out of
order, lost or corrupted when it receives the receiving end.
Bytes and Segments
The figure given below shows how the segments are created from the bytes in the
buffers:
TCP Services
Full-Duplex Service
TCP offers a full-duplex service where the data can flow in both directions
simultaneously. Each TCP will then have a sending buffer and receiving buffer. The TCP
segments are sent in both directions.
Connection-Oriented Service
We are already aware that the TCP is a connection-oriented protocol. When a process
wants to communicate (send and receive) with another process (process -2), the
sequence of operations is as follows:
TCP of process-1 informs TCP of process-2 and gets its approval.
TCP of process-1 tells TCP of process-2 exchange data in both directions.
After completing the data exchange, when buffers on both sides are empty, the two
TCPs destroy their buffers
TCP Services
The type of connection in TCP is not physical, but it is virtual. The TCP segment
encapsulated in an IP datagram can be sent out of order.
These segments can get lost or corrupted and may have to be resend. Each segment
may take a different path to reach the destination.
Reliable Service
TCP is a reliable transport protocol. It uses an acknowledgment mechanism for
checking the safe and sound arrival of data.
TCP Services
A TCP segment consists of data bytes to be sent and a header that is added to
the data by TCP as shown
21.12
TCP Segment structure
The header of a TCP segment can range from 20-60 bytes. 40 bytes are for options. If
there are no options, a header is 20 bytes else it can be of upmost 60 bytes.
Header fields:
Sequence Number –
A 32-bit field that holds the sequence number, i.e, the byte number of the first byte that
is sent in that particular segment. It is used to reassemble the message at the receiving
end of the segments that are received out of order.
21.13
TCP Segment structure
•Acknowledgement Number –
A 32-bit field that holds the acknowledgement number, i.e, the byte number that the
receiver expects to receive next. It is an acknowledgement for the previous bytes being
received successfully.
Header Length (HLEN) –
This is a 4-bit field that indicates the length of the TCP header by a number of 4-byte
words in the header, i.e if the header is 20 bytes(min length of TCP header), then this
field will hold 5 (because 5 x 4 = 20) and the maximum length: 60 bytes, then it’ll hold
the value 15(because 15 x 4 = 60). Hence, the value of this field is always between 5 and
15
21.14
TCP Segment structure
Control flags –
These are 6 1-bit control bits that control connection establishment, connection
termination, connection abortion, flow control, mode of transfer etc. Their function is:
URG: Urgent pointer is valid
ACK: Acknowledgement number is valid( used in case of cumulative
acknowledgement)
PSH: Request for push
RST: Reset the connection
SYN: Synchronize sequence numbers
FIN: Terminate the connection
Window size –
This field tells the window size of the sending TCP in bytes.
Checksum –
This field holds the checksum for error control. It is mandatory in TCP as opposed to
UDP.
21.15
TCP Segment structure
Urgent pointer –
This field (valid only if the URG control flag is set) is used to point to data that is urgently
required that needs to reach the receiving process at the earliest.
The value of this field is added to the sequence number to get the byte number of the
last urgent byte.
21.16
The TCP Service Model
TCP service is obtained by both the sender and receiver creating end points,
called sockets.
Each socket has a socket number (address) consisting of the IP address of the host and
a 16-bit number local to that host, called a port.
A port is the TCP name for a TSAP.
For TCP service to be obtained, a connection must be explicitly established between a
socket on the sending machine and a socket on the receiving machine.
The socket calls are listed in Fig. 4.24.
A socket may be used for multiple connections at the same time.
Port numbers below 1024 are called well-known ports and are reserved for standard
services.
21.17
The TCP Service Model
•For example, any process wishing to establish a connection to a host to transfer a file
using FTP can connect to the destination host's port 21 to contact its FTP daemon.
•A few of the better known ones are listed in Fig.
21.18