Home Internet What is differences between TCP and UDP

What is differences between TCP and UDP

1353

What-is-differences-between-TCP-and-UDPWhat is differences between TCP and UDP?

In my previous article i wrote about What is Transmission Control Protocol (TCP ) and The OSI Model’s Seven Layers Defined and Functions Explained. Today i am going to show you What is UDP ? and what is differences between TCP and UDP ?

What is User Datagram Protocol ( UDP) :-

User Datagram protocol is a protocol that is used at the Transport layer for connectionless , non-guaranteed communications. Unlike TCP, UDP does not setup a connection and does not use acknowledgments. UDP is given the Internet Protocol number of 17 and is defined in RFC 768 .

UDP uses 16-bit port numbers similar TCP. When a UDP packet is sent to a port that is not listening, it will respond with an ICMP port unreachable message to the packet sender.

What-is-differences-between-TCP-and-UDP

Common network applications that use UDP include Domain Name System (DNS) , Streaming Media Applications , Voice over IP , Trival File Transfer Protocol ( TFTP) and online Games .

UDP Header Format :-

What-is-differences-between-TCP-and-UDP1

The UDP header consists of four 16-bit fields ( 4 * 16), which makes a total of 8-bytes in total length. The UDP header comes immediately after the IP header. Th details of individual fields are as follows :-

Source Port :- A 16-bit field whose values can range from 0 to 65,535 specifying the source port.

Destination Port :- A 16-bit field whose values can range from 0 to 65,535 specifying the destination port.

Length :- A 16-bit field whose values can range from 0 to 65,535. it is the length of the UDP header and the UDP data in bytes. The minimum value for this field is 8 bytes.

UDP Checksum :- A 16-bit field whose values can range from 0 to 65,535. The UDP checksum covers the UDP header and the UDP data. With UDP the checksum is optional, while the TCP it is mandatory.

 Differences between TCP and UDP :-

TCPUDP
SequencedUnsequenced
ReliableUnreliable
Connection-orientedConnectionless
Virtual CircuitLow Overhead
AcknowledgmentsNo Acknowledgments
Windowing flow controlNo Windowing of flow control

Brief Explanation of Differences between TCP and UDP :-

AttributesTCPUDP
Acronym forTransmission Control ProtocolUser Datagram Protocol or Universal Datagram Protocol
FunctionAs a message makes its way across the internet from one computer to another. This is connection based.UDP is also a protocol used in message transport or transfer. This is not connection based which means that one program can send a load of packets to another and that would be the end of the relationship.
UsageTCP is used in case of non-time critical applications.UDP is used for games or applications that require fast transmission of data. UDP’s stateless nature is also useful for servers that answer small queries from huge numbers of clients.
ExamplesHTTP, HTTPs, FTP, SMTP Telnet etc…DNS, DHCP, TFTP, SNMP, RIP, VOIP etc…
Ordering of data packetsTCP rearranges data packets in the order specified.UDP has no inherent order as all packets are independent of each other. If ordering is required, it has to be managed by the application layer.
Speed of transferThe speed for TCP is slower than UDP.UDP is faster because there is no error-checking for packets.
ReliabilityThere is absolute guarantee 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.
Header SizeTCP header size is 20 bytesUDP Header size is 8 bytes.
Common Header FieldsSource port, Destination port, Check SumSource port, Destination port, Check Sum
Streaming of dataData 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 which are honored upon receipt, meaning a read operation at the receiver socket will yield an entire message as it was originally sent.
WeightTCP 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 connections, etc. It is a small transport layer designed on top of IP.
Data Flow ControlTCP does Flow Control. TCP requires three packets to set up a socket connection, before any user data can be sent. TCP handles reliability and congestion control.UDP does not have an option for flow control
Error CheckingTCP does error checkingUDP does error checking, but no recovery options.
Fields1. 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 port1. Length, 2. Source port, 3. Destination port, 4. Check Sum
AcknowledgementAcknowledgement segmentsNo Acknowledgment

Source for brief Explanation :- http://www.diffen.com/difference/TCP_vs_UDP

Popular Protocols that are  supporting both TCP and UDP :-

DNS :-  DNS uses TCP for Zone excahnges between server and UDP when a clients is trying to resolve a hostname to an IP-address.

 LDAP :- LDAP always uses TCP – this is true and why not UDP because a secure connection is established between client and server to send the data and this can be done only using TCP not UDP. UDP is only used when finding a domain controller (Kerberos) for authentication. For example, a domain client finding a domain controller using DNS.

List of TCP and UDP port numbers

Hope you like my post.What is differences between TCP and UDP. please Share with others.