Saturday, 24 November 2018

TCP and UDP


Difference Between TCP and UDP

TRANSMISSION CONTROL PROTOCOL (TCP)
USER DATAGRAM PROTOCOL (UDP)
TCP is a connection-oriented protocol. Connection-orientation means that the communicating devices should establish a connection before transmitting data and should close the connection after transmitting the data.
UDP is the Datagram oriented protocol. This is because there is no overhead for opening a connection, maintaining a connection, and terminating a connection. UDP is efficient for broadcast and multicast type of network transmission.
TCP is reliable as it guarantees delivery of data to the destination router.
The delivery of data to the destination cannot be guaranteed in UDP.
TCP provides extensive error checking mechanisms. It is because it provides flow control and acknowledgment of data.
UDP has only the basic error checking mechanism using checksums.
Sequencing of data is a feature of Transmission Control Protocol (TCP). this means that packets arrive in-order at the receiver.
There is no sequencing of data in UDP. If ordering is required, it has to be managed by the application layer.
TCP is comparatively slower than UDP.
UDP is faster, simpler and more efficient than TCP.
Retransmission of lost packets is possible in TCP, but not in UDP.
There is no retransmission of lost packets in User Datagram Protocol (UDP).
TCP header size is 20 bytes.
UDP Header size is 8 bytes.
TCP is heavy-weight.
UDP is lightweight.
TCP is used by HTTP, HTTPs, FTP, SMTP and Telnet
UDP is used by DNS, DHCP, TFTP, SNMP, RIP, and VoIP.

Let us consider the HTTP as you TCP Processing for our presentation.

1. Now, that HTTP means the Hypertext Transfer Protocol. HTTP is an asymmetric request-response client-server protocol as illustrated.  An HTTP client sends a request message to an HTTP server.  The server, in turn, returns a response message.  In other words, HTTP is a pull protocol, the client pulls information from the server (instead of server pushes information down to the client).

2. Let us consider we are hitting the google.com from the browser and then it DNS server where all the TCP IP for each URL’s will saved.

3. Why this DNS comes into picture because the text of the URL will be changed frequently by the user but it has to hit the same server. so, for this all the TCP IP with matched URL's will be present at the DNS.

4. From the DNS it will hit the actual server using the TCP IP, where this will processed by the IIS in the server which is linked with the application scripts.

5. This application scripts will process the request and return the response and this IIS (Internet Information Services) will make the response into small packets of each 20 bytes and send it.

6. So, the information will be received in the form of the packets to client (means the browser), where it will display the data.  

7. Now, what is the packet? A packet is the unit of data that is routed between an origin and a destination on the Internet.

8. Most network packets are split into three parts. They are i) Header ii) Payload and iii) Footer (Trailer)

9. Header: The header contains instructions about the data carried by the packet. These instructions may include:


  •  Length of packet (some networks have fixed-length packets, while others rely on the header to contain this information)

  • Synchronization (a few bits that help the packet match up to the network)

  •  Packet number (which packet this is in a sequence of packets)

  •  Protocol (on networks that carry multiple types of information, the protocol defines what type of packet is being transmitted: e-mail, Web page, streaming video)

  • Destination address (where the packet is going

  • Originating address (where the packet came from)

10. Payload - Also called the body or data of a packet. This is the actual data that the packet is delivering to the destination. If a packet is fixed-length, then the payload may be padded with blank information to make it the right size.

11. Footer (Trailer) - The trailer, sometimes called the footer, typically contains a couple of bits that tell the receiving device that it has reached the end of the packet. It may also have some type of error checking. The most common error checking used in packets is Cyclic Redundancy Check (CRC). CRC is pretty neat. Here is how it works in certain computer networks: It takes the sum of all the 1s in the payload and adds them together. The result is stored as a hexadecimal value in the trailer. The receiving device adds up the 1s in the payload and compares the result to the value stored in the trailer. If the values match, the packet is good. But if the values do not match, the receiving device sends a request to the originating device to resend the packet.


Example:

let's look at how an e-mail message might get broken into packets. Let's say that you send an e-mail to a friend. The e-mail is about 3,500 bits (3.5 kilobits) in size. The network you send it over uses fixed-length packets of 1,024 bits (1 kilobit). The header of each packet is 96 bits long and the trailer is 32 bits long, leaving 896 bits for the payload. To break the 3,500 bits of message into packets, you will need four packets (divide 3,500 by 896). Three packets will contain 896 bits of payload and the fourth will have 812 bits. Here is what one of the four packets would contain:

Each packet's header will contain the proper protocols, the originating address (the IP address of your computer), the destination address (the IP address of the computer where you are sending the e-mail) and the packet number (1, 2, 3 or 4 since there are 4 packets). Routers in the network will look at the destination address in the header and compare it to their lookup table to find out where to send the packet. Once the packet arrives at its destination, your friend's computer will strip the header and trailer off each packet and reassemble the e-mail based on the numbered sequence of the packets.


: