TCP vs UDP – Acronym
- TCP: Transmission Control Protocol
- UDP: User Datagram Protocol
TCP vs UDP – Connection
- TCP: Is a connection-oriented protocol. This means the system is able to send and receive data.
- UDP: Is a connection-less protocol. This means the service can only send packets.
TCP vs UDP – Protocols
- TCP: HTTP, HTTPs, FTP, SMTP, Telnet
- UDP: DNS, DHCP, TFTP, SNMP, RIP, VOIP.
TCP vs UDP – Packet Order
Packets are carried over Internet Protocol (IP), which pays no attention to packet order.
- TCP: Orders the data to be streamed linearly, however, this does not ensure the packets will be received in an ordered fashion. TCP combats this by assigning the data a sequence of numbers, so that as they arrive they may be rearranged or requested if not received.
- UDP: Has no inherent order as all packets are independent of each other. UDP is used when data transmission speed is preferred over packet loss. If ordering is required, it has to be managed by the application layer.
TCP vs UDP – Transmission speed
- TCP: Is slower than UDP, because it requires acknowledgment of packets. However, TCP does provide congestion control, while UDP does not. TCP is smart enough to detect the available bandwidth and moderate packages based on that metric.
- UDP: Is typically the fastest, because is does not require package acknowledgement and can establish a continuous packet stream. Although, if you have a lot of a packets being pushed out at one time they will all compete for the most bandwidth and put a heavy load the system.
TCP vs UDP – Reliability
- TCP: Checks to see if all transmitted data was received, and if not it can recover of segments that get lost, damaged, duplicated or received out of their correct order.
- UDP: There is no guarantee that the messages or packets sent will received at all. 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.
TCP vs UDP – Load
- TCP: High network load. 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 connections monitoring, and no integrity checking.
TCP vs UDP – Data Flow Control
- TCP: Moderate network load. TCP requires three packets to set up a socket connection, before any user data can be sent. TCP handles reliability and congestion control. Because a TCP connection is bidirectional (can send and receive messages), each direction will have to be terminated independently.
- UDP: Sends the packets as fast as possible and, therefore, does not avoid congestion. Congestion control measures must be implemented at the application level.
TCP vs UDP – Troubleshooting Capabilities
- TCP: Performs error checking and error recovery. Corrupted packets are re-transmitted from the source to the destination. Error recovery is possible.
- UDP: Does error checking only when received, and but simply discards corrupt packets. Error recovery is not possible.
TCP vs UDP – Fields
- TCP: 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
- UDP: 1. Length, 2. Source port, 3. Destination port, 4. Check Sum
TCP vs UDP – Handshake
- TCP: SYN, SYN-ACK, ACK
- UDP: No handshake (connectionless protocol)