It is a sliding window protocol that provides handling for both timeouts and retransmissions. TCP establishes a full duplex virtual connection between two endpoints. Each endpoint is defined by an IP address and a TCP port number. The operation of TCP is implemented as a finite state machine. The byte stream is transferred in segments. The window size determines the number of bytes of data that can be sent before an acknowledgement from the receiver is necessary.
TCP/IP protocol suite TCP SERVICES Process-to-Process Communication Stream Delivery Service Full-Duplex Communication Connection-Oriented Service Reliable Service
be slower than the rate of receiving, the data is kept in the buffer until the receiving application reads if completely.
Stream delivery
TCP segments Full-Duplex Communication TCP offers full duplex service where data can flow in both direction at the same time. Connection-Oriented Service TCP connection oriented protocol. When a process at site A wants to send to and receive data from another process at site B the following three phases occur: 1. Two TCP establish a virtual connection between them. 2. Data are exchange in both directions. 3. The connection is terminated. Reliable Service TCP is a reliable transport protocol. It uses an acknowledgement mechanism to check the safe and sound arrival of data. TCP FEATURES(detail of this topic preferred hand written notes) TCP has several features Numbering System
Suppose a TCP connection is transferring a file of 5,000 bytes. The first byte is numbered 10,001. What are the sequence numbers for each segment if data are sent in five segments, each carrying 1,000 bytes? Solution The following shows the sequence number for each segment:
o o
(4) Acknowledgment Number (32 bits) This is used by the receiver to acknowledge the received data. It indicates the sequence number of the next byte expected from the sender. For example: On receiving a segment with sequence number X, the receiver sends back X+1 as the acknowledgement number. It defines the sequence number which the receiver is expecting next.
(5) HLEN (Header Length: 4 bits) It indicates the length of the TCP Header. The length of the TCP header can be between 20 bytes to 60 bytes. (6) Reserved (6 bits) It is reserved for future use. The values set in this field must be zero. (7) Control Flags (6 bits) This field contains six different control flags that are used to control certain aspects of the TCP connection such as connection establishment, connection termination and flow control. The flags include: (a) URG (Urgent Pointer): When this control flag is set, the ACK indicates that the current segment contains urgent (or high priority) data and that the urgent pointer field value is valid. (b) ACK (Acknowledgement): When this control flag is set, it indicates that the value contained in the acknowledgement number field is valid. It is usually set, except during the first message during connection establishment. (c) PSH (Push): It is used when the transmitting application want s to force TCO to immediately transmit the data that is currently buffered to the application without waiting for the buffer to fill. (d) RST (Reset): When set, RST immediately terminates the process to process TCP connection. (e) SYN (Synchronize): It is set in initial segments used to establish a connection, when a client sends request to the server by generating sequence number. (f) FIN (Finish): It is set to request normal termination of the TCP connection in the direction this segment is travelling. Complete closure of the connection requires one FIN segment in each direction. (8) Window Size (16 bits) This field is used for flow control the segments. It determines the size of the window of the other party must maintain to receive the segments. It is basically the number of transmitted bytes that the receiver of the segment is willing to accept from the sender. (9) Checksum (16 bits) It provides bit error detection for the segment (including the header and data). (10) Urgent Pointer (16 bits) This field is used in situations when the segment contains urgent data. It indicates the position of the first octet of non-printing data in the segment. (11) Options This field contains 40 bytes of optional information about connection establishment. TCP Connection
TCP is connection-oriented. It establishes a virtual path between the source and destination. All of the segments belonging to a message are then sent over this virtual path. TCP connection is virtual, not physical. TCP operates at a higher level.
TCP uses the services of IP to deliver individual segments to the receiver, but it controls the connection itself. If a segment is lost or corrupted, it is retransmitted. In TCP connection oriented transmission requires three phases: Connection Establishment Data Transfer Connection Termination Connection Reset
Connection Establishment
Three-Way Handshake
1.
The requesting end (normally called the client) sends a SYN segment specifying the port number of the server that the client wants to connect to, and the client's initial sequence number (ISN,8000 in this example). This is segment 1.
2. The server responds with its own SYN segment containing the server's initial sequence number (segment 2). The server also acknowledges the client's SYN by ACKing the client's ISN plus one. A SYN consumes one sequence number. 3. The client must acknowledge this SYN from the server by ACKing the server's ISN plus one (segment 3).