This solution requires a suitable mechanism for picking an initial sequence number and a slightly involved handshake to exchange the ISNs. The synchronization requires each side to send its own initial sequence number and to receive a confirmation of exchange in an acknowledgment (ACK) from the other side. Each side must also receive the INS from the other side and send a confirming ACK. The sequence is as follows:
  1. A→B SYN—(A) initial sequence number is X, ACK number is 0, SYN bit is set, but ACK bit is not set.
  2. B→A ACK—(A) sequence number is X + 1, (B) initial sequence number is Y, and SYN and ACK bit are set.
  3. A→B ACK—(B) sequence number is Y + 1, (A) sequence number is X + 1, the ACK bit is set, but the SYN bit is not set.
This exchange is called the three-way handshake. A three-way handshake is necessary because sequence numbers are not tied to a global clock in the network and TCP protocols may have different mechanisms for picking the ISN. The receiver of the first SYN has no way of knowing whether the segment was an old delayed one, unless it remembers the last sequence number used on the connection. Recalling that number is not always possible Therefore, the receiver must ask the sender to verify this SYN. Web Links 3-Way Handshake http://www.cs.panam.edu/~meng/Course/ CS6345/Notes/ chpt-6/node8.html
Content 11.1 TCP/IP Transport Layer 11.1.5 Windowing Data packets must be delivered to the recipient in the same order in which they were transmitted to have a reliable, connection-oriented data transfer. The protocol fails if any data packets are lost, damaged, duplicated, or received in a different order. An easy solution is to have a recipient acknowledge the receipt of each packet before the next packet is sent. If the sender must wait for an acknowledgment after sending each packet, throughput would be low. Therefore, most connection-oriented, reliable protocols allow more than one packet to be outstanding on the network at one time. Because time is available after the sender finishes transmitting the data packet and before the sender finishes processing any received acknowledgment, this interval is used for transmitting more data. The number of data packets the sender is allowed to have outstanding without having received an acknowledgment is known as the window size, or window.

TCP uses expectational acknowledgments. Expectational acknowledgements mean that the acknowledgment number refers to the packet that is next expected. Windowing refers to the fact that the window size is negotiated dynamically during the TCP session. Windowing is a flow-control mechanism. Windowing requires that the source device receive an acknowledgment from the destination after transmitting a certain amount of data. The receiving TCP process reports a “window” to the sending TCP. This window specifies the number of packets, starting with the acknowledgment number, that the receiving TCP process is currently prepared to receive.

With a window size of three, the source device can send three packets to the destination. The source device must then wait for an acknowledgment. If the destination receives the three packets, it sends an acknowledgment to the source device, which can now transmit three more packets. If the destination does not receive the three packets, because of overflowing buffers, it does not send an acknowledgment. Because the source does not receive an acknowledgment, it knows that the packets should be retransmitted, and that the transmission rate should be slowed.

TCP window sizes are variable during the lifetime of a connection. Each acknowledgement contains a window advertisement that indicates the number of bytes the receiver can accept. TCP also maintains a congestion-control window. This window is normally the same size as the window of the receiver. However, this window is cut in half when a packet is lost, perhaps as a result of network congestion. This approach permits the window to be expanded or contracted as necessary to manage buffer space and processing. A larger window size allows more data to be processed.

As shown in Figure , the sender sends three packets before expecting an ACK. If the receiver can handle a window size of only two packets, the window drops packet three, specifies three as the next packet, and specifies a new window size of two. The sender sends the next two packets, but still specifies a window size of three. This means that the sender will still expect a three packet acknowledgement from the receiver. The receiver replies by requesting packet five and again specifying a window size of two. Web Links Transport Layer - OSI Model http://cs.nmhu.edu/osimodel/transport
Content 11.1 TCP/IP Transport Layer 11.1.6 Acknowledgment Reliable delivery guarantees that a stream of data sent from one device is delivered through a data link to another device without duplication or data loss. Positive acknowledgment with retransmission is one technique that guarantees reliable delivery of data. Positive acknowledgment requires a recipient to communicate with the source and send back an acknowledgment message when the data is received. The sender keeps a record of each data packet (TCP segment), that it sends and expects an acknowledgment. The sender also starts a timer when it sends a segment and will retransmit a segment if the timer expires before an acknowledgment arrives. Figure shows the sender transmitting data packets 1, 2, and 3. The receiver acknowledges receipt of the packets by requesting packet 4. Upon receiving the acknowledgment, the sender sends packets 4, 5, and 6. If packet 5 does not arrive at the destination, the receiver acknowledges with a request to resend packet 5. The sender resends packet 5 and then receives an acknowledgment to continue with the transmission of packet 7. TCP provides sequencing of segments with a forward reference acknowledgment. Each datagram is numbered before transmission. At the receiving station, TCP reassembles the segments into a complete message. If a sequence number is missing in the series, that segment is retransmitted. Segments that are not acknowledged within a given time period will result in a retransmission.
Content 11.1 TCP/IP Transport Layer 11.1.7 Transmission Control Protocol (TCP) Transmission Control Protocol (TCP) is a connection-oriented Layer 4 protocol that provides reliable full-duplex data transmission. TCP is part of the TCP/IP protocol stack. In a connection-oriented environment, a connection is established between both ends before the transfer of information can begin. TCP is responsible for breaking messages into segments, reassembling them at the destination station, resending anything that is not received, and reassembling messages from the segments. TCP supplies a virtual circuit between end-user applications. The protocols that use TCP include: The following are the definitions of the fields in the TCP segment: Web