TCP-IP and the DATA Flow....

In this post, I am not going to discuss in details about how a packet flow through network using TCP-IP layered protocol. My aim here is to share what I understand as to how TCP-IP protocol stack modifies a data and helps it to reach final destination. Please do comment and share, if my knowledge needs modification anywhere. Read on….. 
 As in my some earlier blog, I have already told that each layer of TCPIP protocol suite does some exercise on the data packet to make it actually deliverable over the network. Let us try to understand this by one simple example. Please refer to the flash play below for the example.


 Let say, the green Computer (of the network at the left) with IP address 162.103.1.103 is the source, which wishes to send a data to the yellow Computer with IP address 175.95.1.52 (of the network at the right) which is the destination over a Ethernet network, consisting of switches and routers. Let us now examine what layers are involved and what activities are involved at each node, from source to destination. 
 Source PC with IP address 162.103.1.103 :
  Application layer: This layer will form the data intended to be actually read by the destination PC and this layer also defines the application and format the data accordingly. For example, if the sender PC uses a web-browser to communicate with PC at the destination, then it will use the application layer protocol “HTTP” (Hyper text transfer protocol), if it intends to send mail, it will use protocol “SMTP” (Simple mail transfer protocol). There are lot of protocols here, but to keep it simple, let us under stand that this layer in the source PC will define application, the data format and the actual data, intended to be read only by the destination PC.   
         
DATA

Transport Layer: This layer helps to identify the application for which the data belongs and hence provides end to end data transfer. The identifier of the application is known as the “Port Number”, which is of 16 bits. For example when you are browsing web, the destination port number will be 80. There are specific port numbers for specific standard application. For a newbie, it suffices to understand that port numbers help to identify and differentiate among different processes in one computer. Essentially, this layer adds one header to the original data; which carry certain information needed to deliver correctly to the right application properly. This header is one of the two type’s viz. TCP (Transmission Control Protocol) or UDP (User Datagram protocol). The application decides on the type of Transport layer header.
TCP or UDP
DATA   

---> Known as the Segment
 Each of the type of header has the most important entries of source and destination port numbers each of 16 bits along with some other information. Just have a look at the TCP and UDP headers, to understand the difference.
TCP header has got certain extra information like Sequence number and acknowledgement number, which guarantees the receipt of the data by the recipient application, whereas UDP header has no such field. Thus, TCP provides end to end reliable data connection and therefore called connection oriented protocol. UDP does not provide such reliability, but as the header is small, and there is no wastage of time in receiving acknowledgement and sending subsequent data, the delivery is faster. Therefore, it can be interpreted that applications like e-mail, File transfer protocol which need reliability uses TCP header and applications requiring faster delivery and can do without reliability like VoIP(Voice over Internet Protocol), DNS query(converting domain names to IP address) uses UDP. 
 Internet/Network Layer: Whereas Transport layer helps to identify the process or application, Network layer helps to identify the source and destination PC over the network. This layer again adds one header to the segment carrying certain more information, to make data find its route to the destination computer. The mostly used routed protocol here is the IP header. (IPversion4 in particular; work and implementation is going on for IPversion6)
IPv4 Header
TCP or UDP
DATA   
 Known as the Datagram. 

Whatever is the case, this header gives identification to the computers involved and some other information, helping it’s to find its path to the destination in this wide network.Just have a look at the IPv4 header. It is of minimum 40 bytes and 60 bytes in size.
The most important fields in the IP header are the Source IP address and the Destination IP address. In our example those fields will be 162.103.1.103(the source IP) and 175.95.1.52(the destination IP). 
Network Interface Layer: This layer encompasses the Data link and Physical layers of OSI model. This layer is a liaison between the software layers above and the media below. In our example of Ethernet link, this layer adds one header and one trailer.
Preamble
Start Frame Delimiter
Destination MAC
Source MAC
Type
IPv4 Header
TCP or UDP
DATA   
Frame Check Sequence
   7 bytes         1 byte           6 bytes            6 bytes      2byte <-------Payload------------->   2bytes ---
  <-----------------------------Known as Frame-------------------------------------------------------->
The most important information being carried over here are the hardware addresses, i.e. the MAC(media access control) addresses. Here these MAC addresses will be point to point. In our example the Source MAC address will be of the source computer and the destination MAC address will be of the Router, which it gets from its ARP (Address resolution protocol) table, which maps IP address to MAC address. Finally all this information after being converted to electrical signal will be received by the router-A via the switch.
  Router-A : - 
Let us see what happens at Router-A after the receipt of the frame. Router-A will tear the Frame and look into the IP header. Then it will look at the destination IP address and then looks into its routing table. The routing table consists of Next HOP router address for a Destination IP address, so basically it answers a question of the IP packet---For a given destination IP address, where should the packet be forwarded next? In the real scenario the router-A may be connected to many routers. Routing tables are built either manually or dynamically using certain routing protocols. In our example, the router –A decides to forward the packet next to Router-C. So, Network layer at Router-A decides the next hop, recalculates IP header likewise, with same source and destination address. The Network Interface layer at Router-A then re-frames the packet with Source MAC address of router-A and destination MAC address of router-C. It is then sent to router-C.

 Router-C: 
Router C will again strip off the frame header and trailer and looks into the IP header; decides the next hop router, which is router-F. Reframe the packet likewise and the packet reaches router-F.

 Router-F: Router-F will strip off frame header and trailer, to find that the destination IP address lies in its network only. So, it will frame the packet with source MAC address of itself and destination MAC of the destination computer (67:E6:32:77:FA:CC) and finally the frame will reach the destination computer.


Destination Computer with IP address175.95.1.52 : - 
The destination computer will strip off frame header and trailer and look into the IP header. Eureka! It discovers that the packet is meant for it only. It now has the explicit right to strip off the Network/IP header and look further into Transport layer header and see into the port address, to identify the application for which the data is meant for ( Different web-pages in a same computer are also differentiated by port numbers). Finally the transport layer header (TCP or UDP) is stripped off and the data is sent to the relevant application for final processing. 
 From this explanation, I hope it is clear that the information in lower two layers of TCP/IP model i.e. the Network Interface and Network/Internet layers are meant for all the devices along the path. Therefore they are known as the point to point layers. The information in the upper two layers of TCPIP model viz. the Transport layer and the Application layer, are meant only for the final host. The intermediate devices, has nothing to do with the information carried on these layers, and therefore they are known as host to host layers. That’s it !

6 comments:

  1. Very good and clear explanation....

    ReplyDelete
  2. Need further explanation of the headers.

    ReplyDelete
  3. Flash video was very helpful-sagnik

    ReplyDelete
  4. Awesome blog, very helpful to understand the basic :)

    ReplyDelete
  5. Great work....
    Clear and through the point explanation.......... Waiting for more such stuff . Thank you

    ReplyDelete
  6. can u please post animation of ospf protocol working

    ReplyDelete