Saturday 31 May 2014

TCP(Transmission Control Protocol)

Transmission Control Protocol (TCP)


         Transmission Control Protocol (TCP) takes large blocks of information from an application and breaks them into segments. It numbers and sequences each segment so that the destination’s TCP stack can put the segments back into the order the application intended. After these
segments are sent, TCP (on the transmitting host) waits for an acknowledgment of the receiving end’s TCP virtual circuit session, transmitting those that aren't acknowledged.
Before a transmitting host starts to send segments down the model, the sender’s TCP stack contacts the destination’s TCP stack to establish a connection. What is created is known as a virtual circuit. This type of communication is called connection-oriented. During this initial handshake,
the two TCP layers also agree on the amount of information that’s going to be sent before the recipient’s TCP sends back an acknowledgment.
With everything agreed upon in advance, the path is paved for reliable communication to take place.
TCP is a full-duplex, connection-oriented, reliable, and accurate protocol, but establishing all these terms and conditions, in addition to error checking, is no small task. TCP is very complicated and, not surprisingly, costly in terms of network overhead. And since today’s networks are much more reliable than those of yore, this added reliability is often unnecessary. Most programmers use TCP because it removes a lot of programming work; however, real-time video and VoIP use UDP because they can’t afford the overhead.

TCP Segment Format
Since the upper layers just send a data stream to the protocols in the Transport layers, I’ll demonstrate how TCP segments a data stream and
prepares it for the Internet layer. When the Internet layer receives the data stream, it routes the segments as packets through an inter network. The
segments are handed to the receiving host’s Host-to-Host layer protocol, which rebuilds the data stream to hand to the upper-layer applications or
protocols.
Source port The port number of the application on the host sending the data. (Port numbers will be explained a little later in this section.)
Destination port The port number of the application requested on the destination host.
Sequence number A number used by TCP that puts the data back in the correct order or retransmits missing or damaged data, a process
called sequencing.
Acknowledgment number The TCP octet that is expected next.
Header length The number of 32-bit words in the TCP header. This indicates where the data begins. The TCP header (even one including
options) is an integral number of 32 bits in length.
Reserved Always set to zero.
Code bits/flags Control functions used to set up and terminate a session.
Window The window size the sender is willing to accept, in octets.
Checksum The cyclic redundancy check (CRC), because TCP doesn’t trust the lower layers and checks everything. The CRC checks the
header and data fields.
Urgent A valid field only if the Urgent pointer in the code bits is set. If so, this value indicates the offset from the current sequence number, in
octets, where the segment of non-urgent data begins.
Options May be 0 or a multiple of 32 bits, if any. What this means is that no options have to be present (option size of 0). However, if any
options are used that do not cause the option field to total a multiple of 32 bits, padding of 0s must be used to make sure the data begins on a
32-bit boundary.
Data Handed down to the TCP protocol at the Transport layer, which includes the upper-layer headers.