Skip to main content

Differences between TCP and UDP



TCP

UDP
Full Form
Transmission Control Protocol
User Datagram Protocol

Function
Connection based protocol which is used to transport message across the internet from one computer to another

Non-Connection based protocol used in message transport or transfer
Working
TCP connection is established via a three way handshake, which is a process of initiating and acknowledging a connection.

UDP uses a simple transmission model without implicit handshaking dialogues for guaranteeing reliability, ordering, or data integrity
Example
HTTP, HTTPS, FTP, SMTP, Telnet, etc.

DNS, DHCP, FTP, SNMP, RIP, VOIP, etc.
Usage
TCP is used in case of non-time critical applications
UDP is used for games or applications that require fast transmission of data

Ordering
TCP rearranges data packets in the order specified
UDP has inherent order as all packets are independent of each other. If ordering is required, it has to be managed by the application layer

Transfer Speed (mbps)
Slower than the speed of UDP
It is faster than TCP because there is no error-checking for packets

Error Checking
TCP does error checking
UDP does error checking, but no recovery options

Reliability
Guarantees that the data transferred remains intact and arrives in the same order in which it was sent

There is no guarantee that the messages or packets sent would reach at all
Connection Reliability
Two way connection reliable

One way Connection Reliable
Weight
TCP 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. There is no ordering of messages, no tracking connection, etc. It is a small transport layer designed on top of IP
Data Flow Control
TCP does Flow Control

No flow control
Header Size
20 bytes

8 bytes
Streaming of Data
Data is read as a byte stream.
No distinguishing indications are transmitted to signal message (segment) boundaries
Packets are sent individually and are checked for integrity only if they arrive.
Packets have definite boundaries

Application
Web browsing, email and file transfer are common application that make use of TCP.
TCP is used to control segment size, rate of data exchange, flow control and network congestion.
TCP is preferred where error connection facilities are required at network interface level
UDP is commonly used in Domain Name System, Voice over IP, Trivial File Transfer Protocol and Online Games.
UDP is largely used by time sensitive applications as well as by servers that answer small queries from huge number of clients.
UDP is compatible with packet broadcast - Sending to all on a network and multicasting – sending to all subscribers.

Comments

Popular posts from this blog

Use Case Diagram for Online Book Store

Linear search & Binary search using Template

Write a program to search an element from a list. Give user the option to perform Linear or Binary search. Use Template functions. #include<iostream> using namespace std; template <class T> void Lsearch(T *a, T item, int n) { int z=0; for(int i=0;i<n;i++) { if(a[i]== item) { z=1; cout<<"\n Item found at position = "<<i+1<<"\n\n"; } else if(z!=1) { z=0; } } if(z==0) cout<<"\n Item not found in the list\n\n"; } template <class T> void Bsearch(T *a, T item, int n) { int beg=0,end=n-1; int mid=beg+end/2; while((a[mid]!=item) && (n>0)) { if(item>a[mid]) beg=mid; else end=mid; mid=(beg+end)/2; n--; } if(a[mid]==item) cout<<"\n Item found at position = "<<mid+1<<"\n\n"; else cout<<"\n Item not found in the list\n\n"; } void main() { int iarr[10] = {2,42,56,86,87,99,323,546,767,886};

Online Movie Ticket Booking Sequence Diagram