Host A begins the connection by sending host B a segment with the "Synchronize sequence numbers" (SYN) bit set and this segment tells host B that A wishes to set up a connection, and it tells B what sequence number host A will use as a starting number for its segments. (Sequence numbers are used to keep data in the proper order.) Host B responds to A with a segment that has the "Acknowledgment" (ACK) and SYN bits set and B's segment acknowledges the receipt of A's segment, and informs A which Sequence Number host B will start with. Finally, host A sends a segment that acknowledges receipt of B's segment, and transfers the first actual data.
After this exchange, host A's TCP has positive evidence that the remote TCP is alive and ready to receive data and then as soon as the connection is established, data can be transferred. When the cooperating modules have concluded the data transfers,to close the connection they will exchange a three-way handshake with segments containing the "No more data from sender" bit (called the FIN bit). It is the end-to-end exchange of data that provides the logical connection between the two system.
TCP also helps to views the data it sends as a continuous stream of bytes, not as independent packets. Therefore, TCP takes care to maintain the sequence in which bytes are received and sent.The Acknowledgment Number and Sequence Number fields in the TCP segment header keep track of the bytes.
The TCP standard does not require that each system start numbering bytes with any specific number and each system chooses the number it will use as a starting point.Each end of the connection must know the other end's initial number to keep track of the data stream correctly. The two ends of the connection synchronize byte-numbering systems by exchanging SYN segments during the handshake and the Sequence Number field in the SYN segment contains the Initial Sequence Number (ISN), which is the starting point for the byte-numbering system. For security reasons the ISN should be the random number, though it is often 0.
Each byte of data is numbered sequentially from the ISN, so the first real byte of data sent has a sequence number of ISN+1 and the Sequence Number in the header of a data segment identifies the sequential position in the data stream of the first data byte in the segment. For example, if the first byte in the data stream was sequence number 1 (ISN=0) and 4000 bytes of data have already been transferred, then the first byte of data in the current segment is byte 4001, and the Sequence Number would be 4001 only.
The Acknowledgment Segment (ACK) performs two functions: flow control and positive acknowledgment. The acknowledgment tells the sender how much data has been received, and how much more the receiver can accept and the Acknowledgment Number is the sequence number of the next byte the receiver expects to receive.For every packet,the standard does not require an individual acknowledgment. The acknowledgment number is a positive acknowledgment of all bytes up to that number. For example, if the first byte sent was numbered 1 and 2000 bytes have been successfully received, the Acknowledgment Number would be 2001.
The Window field contains the number of bytes the remote end is able to accept or the window. If the receiver is capable of accepting 6000 more bytes, the window would be 6000 only. The window indicate to the sender that it can continue sending segments as long as the total number of bytes that it sends is smaller than the window of bytes that the receiver can accept and he receiver controls the flow of bytes from the sender by changing the size of the window. A zero window tells the sender to cease transmission until it receives the non-zero window value.
|