detailed answer What are the primary differences between TCP
detailed answer: What are the primary differences between TCP and UDP. Would you recommend UDP or TCP for a voice over IP phone call? Justify your choice.
Solution
There are two types of Internet Protocol (IP) traffic. They are TCP or Transmission Control Protocol and UDP or User Datagram Protocol. TCP is connection oriented – once a connection is established, data can be sent bidirectional. UDPl is a simpler, connectionless Internet protocol. Multiple messages are sent as packets in chunks using UDP.
1) Connection
TCP is a connection-oriented protocol.
User Datagram Protocol or Universal Datagram Protocol.
2) Function
TCP:- As a message makes its way across the internetfrom one computer to another. This is connection based.
UDP:- 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.
3) Usage
TCP is suited for applications that require high reliability, and transmission time is relatively less critical.
UDP is suitable for applications that need fast, efficient transmission, such as games. UDP\'s stateless nature is also useful for servers that answer small queries from huge numbers of clients.
4) Use by other protocols
TCP:- HTTP, HTTPs, FTP, SMTP, Telnet
UDP:- DNS, DHCP, TFTP, SNMP, RIP, VOIP.
5) Ordering of data packets
TCP 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.
6) Speed of transfer
The speed for TCP is slower than UDP.
UDP is faster because error recovery is not attempted. It is a \"best effort\" protocol.
7) Reliability
There 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.
8) Header Size
TCP header size is 20 bytes
UDP Header size is 8 bytes.
9) Common Header Fields
TCP:- Source port, Destination port, Check Sum
UDP:- Source port, Destination port, Check Sum
10) Streaming of data
TCP:- Data is read as a byte stream, no distinguishing indications are transmitted to signal message (segment) boundaries
UDP:- 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.
11) Weight
TCP is heavy-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 connections, etc. It is a small transport layer designed on top of IP.
12) Data Flow Control
TCP 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
13) Error Checking
TCP does error checking and error recovery. Erroneous packets are retransmitted from the source to the destination.
UDP does error checking but simply discards erroneous packets. Error recovery is not attempted.
VoIP needs to be on UDP.
This is because TCP has packet recovery, and this would mean that your VoIP lines would be very garbled due to the packets trying to recover them selves.
In that case the packet that had \"name\" probably got lost, and TCP is recovering it. And with TCP you would have to most likely wait between each other to make sure the packets have all arrived.
UDP is just sending packets, and they get there if they get there. UDP will not recover any lost packets, and all the user would hear is a slight slip in words. UDP is real time, so there is no delay in sound.

