Monday, March 4, 2013

TCP Overview

TCP and OSI Model

Understanding how each network protocol fits into the OSI Model is important. Transmission Control Protocol (TCP) is placed at the Transport Layer of the OSI Model (Layer 4). Shortly speaking, Transport Layer provides transparent transfer of data between end users, providing reliable data transfer services to the upper layers. 


TCP is a full-featured transport layer protocol. It provides all the functions needed by a typical application for the reliable transportation of data across an arbitrary internetwork. It provides transport-layer addressing for application processes in the form of TCP Ports. TCP allows these ports to be used in establishing connections between machines (TCP is a connection-oriented protocol). Once connections have been created, data can be passed bidirectionally between two devices (full-duplex communication). Applications can send data to TCP as a simple stream of bytes. IP is a packet-based protocol while TCP is stream-based. TCP is built on top of IP, therefore TCP is responsible for breaking the streams of data that come from upper layer protocols to the packets. TCP handles packaging and sending the data as segments. Please note that the TCP segments are packaged into IP datagrams by Network Layer (OSI Layer 3). The receiving device's TCP implementation reverses the process and it passes the stream of data originally sent up to the applicationThe more we dive into TCP, the better you will see how TCP fits OSI Transport Layer.

The diagram below shows where TCP Header is located within a frame that has been generated by a host and sent to the network:


Where and When to use TCP

TCP, as a protocol, is not restricted to any type of network topology. Either in local area network (LAN) or wide area network (WAN), TCP is able to transport data from one location to the other.  

You may probably know that UDP (User Datagram Protocol) is another Transport Layer protocol (well, you learn it now if you haven't known that before). So, when should we use TCP and when should we use UDP?

TCP guarantees packet delivery and thus can be considered as "reliable". On the other hand, UDP is a best-effort service. UDP is "unrealiable", it provides no guarantees for delivery and no protection from duplication. The simplicity of UDP, however, reduces the overhead. A computer may send UDP packets without establishing a connection to the recipient. The computer completes the appropriate fields in the UDP Header (which is more light-weight compared to the TCP header) and forwards the data with the header to the IP Network Layer.

To sum up, TCP is for high-reliability data transmissions and UDP is for low-overhead transmissions. Well, simply, use UDP in applications where reliability is not critical but speed is (video streaming applications or networked gaming applications), and use TCP for the rest.

The Concept Of A Transport Protocol

Well, if you manage to read this post until here, you should have already grasped the idea that TCP is a transport protocol which means it is used to transfer the data of upper layer protocols.

Below, you will see a magically useful diagram which probably is the simplest way to show the concept of a transport protocol:

   


No comments:

Post a Comment