Difference between TCP and UDP
Key Difference: TCP stands for transport control protocol. It is a connection oriented and reliable protocol and is used for transfer of crucial data. On the other hand, UDP stands for User Datagram Protocol. It is an unreliable and connection-less protocol which is used for services that require fast transmission of data.
include("ad4th.php"); ?>We are living in a world full of various types of networks. The most important network consists of computers. We send e-mails to our friends, send them our pictures, listen to a distant radio channel, and many more things. The whole functioning of the network seems to be running seamlessly on a simple platform. However, behind this simple looking network, lies a complex system that has been simplified by use of various protocols. Protocols define the rules, conventions and data structures that govern the data communication.
These protocols are required because a computer network is a heterogeneous mixture of various components. Computers that are interacting with each other may differ in various attributes like hardware, software, specifications etc. Thus, a unifying set of rules is a must that should be followed world wide, in order to communicate the data between various types of computer systems. We can simply say that it is a language that computers use to talk to each other.
include("ad3rd.php"); ?>TCP and UDP are two such protocols. The protocols are placed in a layered hierarchy. Whenever the message is passed from a source to sender, it must pass from each layer of the protocol stack. Today, the networking standards use two main protocol stacks known by Open System Interconnection (OSI) model and the TCP/IP model. OSI is a seven layered architecture, whereas TCP/IP consists of four layers. TCP and UDP both are put under the transport layer.
Let us understand the functioning of TCP Protocol. It stands for Transmission Control Protocol. It is a connection oriented and reliable protocol. It means that first the connection is set up, and then the message is sent across and later after the data transfer, the connection is terminated. Thus, the connection remains open throughout the process of transfer. It is responsible for breaking the data messages into packets that are sent by using internet protocol. TCP is also used in remote login i.e. one can get access to the other computer for maintenance or trouble shooting purposes. It is also used in file transfers.
Another important term that is associated with the TCP is handshaking. It refers to the reliable feature of TCP. How this reliability is achieved? It is achieved with the help of acknowledgements. Firstly, the message that is in bytes (form of 0 and 1) is broken up into chucks which are known as segments.
After receiving the segments, the receiver sends acknowledgements for segments. TCP also maintains a timer. If the acknowledgement is not received in time, then the message is resent. Each byte that is transmitted through TCP protocol contains a sequence number. A TCP segment is made up of a segment header and a data section. The header contains 10 fields that must exist and an optional extension field.
UDP is the name for User Datagram Protocol or Universal Datagram Protocol. It is also a protocol but it greatly differs from the TCP. It is used in place of TCP when the data transfer is not that critical. UDP do not set up end to end connection between the systems. It is also known for its best effort in delivering the data.
However, the reliability is less but it still offers efficient communication. It is also used as a tunneling protocol in which UDP datagrams contain the packets of other protocols and then transmits them to the other end. However, a computer may send UDP packets even before establishing a connection. The UDP header contains four fields and each field is of 2 bytes in terms of its length. The four fields are the source port, destination port, UDP length and UDP checksum. The datagram is carried in a single IP packet and later at the destination the UDP protocol layer receives the packets from IP network layer.
Some of the key differences are listed below in the table:
|
TCP |
UDP |
Stands for: |
Transmission Control Protocol |
User Datagram Protocol or Universal Datagram Protocol |
Type of Connection: |
It is a connection oriented protocol |
It is a connection less protocol |
Usage: |
TCP is used in case of applications in which fast transmission of data is not required |
UDP is preferred in case of the applications which have the priority of sending the data on time and on faster rates |
Examples: |
HTTP, FTP, SMTP Telnet etc |
DNS, DHCP, TFTP, SNMP, RIP, VOIP etc |
Ordering of data packets: |
It rearranges data packets in the order specified |
No inherent ordering, the data packets of same message may be ordered differently |
Speed of transfer: |
Comparatively slow |
Comparatively fast |
Reliability: |
Reliable (defines that data will be definitely sent across) |
Unreliable |
Header Size: |
TCP header size is 20 bytes |
UDP Header size is 8 bytes |
Fields: |
1. Sequence Number, 2. AcK number, 3. Data offset, 4. Reserved, 5. Control bit, 6. Window, 7. Urgent Pointer, 8. Options, 9. Padding, 10. Check Sum, 11. Source port, 12. Destination port. |
1. Length, 2. Source port, 3. Destination port, 4. Check Sum. |
Streaming of data: |
Data is read as a byte stream, thus no distinguishing indications are transmitted to the signal message |
Packets are sent individually and after the arrival the packets are rearranged |
Weight: |
It is heavier as it requires three packets to set up a socket connection, before any user data can be sent. TCP handles reliability and congestion control. |
UDP is lightweight due to no ordering of messages, no tracking connections, etc. |
Data Flow Control: |
TCP controls the flow of data
|
UDP does not have an option for flow control |
Image Courtesy: highteck.net, en.wikibooks.org
Add new comment