Anda di halaman 1dari 9

Transmission Control Protocol TCP is a transport layer protocol used by applications that require guaranteed delivery.

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

Process-to-Process Communication TCP provides process-to-process communication using port numbers.

Well-known ports used by TCP Stream Delivery Service


TCP provides stream data transfer service, which means the destination process receives the stream of data in exactly the same manner it is sent by the source process. Source TCP accepts a stream of characters from the sending application program as and when they arrive,creates packets,called segments,of appropriate size extracted from the stream ,and sends them across the network. The receiving TCP receives segments,extracts data from them, order them if they have arrived out of order,and delivers them as a stream of characters to the receiving program. For stream delivery, the sending and receiving TCPs use buffers. The sending TCP uses a sending buffer to store the data coming from the sending application program. The sending application program delivers data at the rate it is created. For example,if the user is typing the data on a keyboard, the data is delivered to the sending TCP character by character. If the data is coming from a file, data may be delivered to the sending TCP line by line,or block by block. The sending application program writes data to the buffer of the sending TCP. The receiving TCP receives the segments and stores them in a receiving buffer. The receiving application program uses the read operation to read the data from the receiving buffer,but it does not have to read all of the data contained in one segment in one operation. Since the rate of reading can

be slower than the rate of receiving, the data is kept in the buffer until the receiving application reads if completely.

Stream delivery

Sending and receiving buffers

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

Flow Control Error Control Congestion Control

TCP Header A packet in TCP is called a segment

TCP segment format (1) Source Port Number


This is a 16-bit number which specifies the source port number corresponding to the application which is sending the segment. (2) Destination Port Number It is a 16-bit number which specifies the port number of the application program that is receiving the TCP segments at the destination computer. (3) Sequence Number( 32 bits) It specifies the number assigned to the first byte of the data portion of the TCP segment. Each byte to be transmitted is numbered in an increasing sequence. Since sequence number refers to a byte count rather than a segment count, sequence numbers in contiguous TCP segments are not numbered sequentially. For example: If a file of 5000 bytes is transferred using TCP connection and the first byte is numbered a 20002 and data is divided into 5 segments of 1000 bytes, then the sequence numbers assigned to various segments are as under: Segment Segment Segment Segment Segment 1Sequence number: 20002 2 Sequence number: 21002(20002+1000) 3Sequence number: 22002(21002+1000) 4Sequence number: 23002(22002+1000) 5Sequence number: 24002(23002+1000)

(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).

Anda mungkin juga menyukai