25-04-2012, 04:21 PM
TCP-IP
02-TCP-IP.doc (Size: 291 KB / Downloads: 35)
Synchronization or 3-way handshake
TCP is a connection-oriented protocol. Prior to data transmission, the two communicating hosts go through a synchronization process to establish a virtual connection. This synchronization process insures that both sides are ready for data transmission and allows the devices to determine the initial sequence numbers. This process is known as a three-way handshake. This is a three-step process that establishes the virtual connection between the two devices.
=> First, one host initiates a connection by sending a synchronization (SYN) packet indicating its initial sequence number of x with a certain bit in the header set to indicate a connection request. This bit is set in the acknowledgment number field of the TCP header (also referred to as the code field).
=> Second, the other host receives the packet, records the sequence number of x, replies with an acknowledgment of x + 1, and includes its own initial sequence number of y. The acknowledgment number of x + 1 means the host has received all octets up to and including x, and is expecting x + 1 next.
=> Finally, the initiating host responds with a simple acknowledgment (ACK) of y + 1 (host B’s sequence number + 1), indicating it received the previous ACK which finalizes the connection process.
It is important to understand that sequence numbers are a part of initiating communication between the two devices. They act as reference starting numbers between the two devices. The sequence numbers give each host a way to ACK the SYN so that the receiver knows the sender is responding to the proper connection request.
Windowing and Window Size:
The amount of data that needs to be transmitted is often too large to be sent in a single data segment. In this case, the data must be broken into smaller pieces to allow for proper data transmission. TCP is responsible for breaking data into segments. This is similar to feeding a child. Since most small children cannot eat extremely large bites the person feeding a child will often cut their food into smaller pieces that the child's mouth can accommodate. Additionally, receiving machines may not be able to receive data as quickly as the source can send data, perhaps because the receiving device is busy with other tasks or perhaps the sender is simply a more robust device.
Once the data is segmented, it must be transmitted to the destination device. One of the services provided by TCP is flow control, which regulates how much data is sent during a given transmission period. The process of flow control is known as windowing.
Window size determines the amount of data that can be transmitted at one time before receiving an acknowledgment from the destination. After a host transmits the window-sized number of bytes, the host must receive an acknowledgment that the data has been received before it can send any more data. For example, with a window size of 1, each individual segment must be acknowledged before sending the next segment.
TCP utilizes a sliding window when determining transmission size. A sliding window allows for devices to negotiate a window size to allow for more than one byte to be sent during a single transmission. This sliding window also allows the destination device to indicate to the source a need to decrease or increase the amount of data being sent because it is incapable at that time of dealing with that much data.
TCP Sequence and Acknowledge numbers:
TCP breaks data into segments. The data segments are then transported from sender to receiver, following the synchronization process and the negotiation of a window size that dictates the number of bytes that can be transmitted at any one time. The data segments being transmitted must be reassembled once all the data is received. There is no guarantee that the data will arrive in the order it was transmitted. TCP applies sequence numbers to the data segments it is transmitting so that the receiver will be able to properly reassemble the bytes in their original order. If TCP segments arrive out of order, the segments may be reassembled incorrectly. Sequencing numbers indicate to the destination device the correct order in which to put the bytes when they are received.
These sequencing numbers also act as reference numbers so that the receiver will know if it has received all of the data. They also identify the missing data pieces to the sender so it can retransmit the missing data. This offers increased efficiency since the sender only needs to re-transmit the missing segments instead of the entire set of data.
Each TCP segment is numbered before transmission. Notice that following the destination port in the segment format is the sequence number portion. At the receiving station, TCP uses the sequence numbers to reassemble the segments into a complete message. If a sequence number is missing in the series, that segment is re-transmitted.
Port Numbering and well known port numbers:
Port numbers are represented by 2 bytes in the header of a TCP or UDP segment. This 16-bit value can result in port numbers ranging from 0 to 65535. These port numbers are divided into three different categories: well-known ports, registered ports, and dynamic or private ports. The first 1023 ports are well-known ports. As the name implies, these ports are used for well-known network services, such as FTP, Telnet, or DNS. Registered ports range from 1024 to 49151. Ports between 49152 and 65535 are defined as dynamic or private ports.