TCP和UDP的区别

219 篇文章 2 订阅

What are the differences between TCP & UDP

Acronym

  • TCP: Transmission Control Protocol
  • UDP: User Datagram Protocol

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.

Protocols

  • TCP: HTTP, HTTPs, FTP, SMTP, Telnet
  • UDP: DNS, DHCP, TFTP, SNMP, RIP, VOIP.

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 insure 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.

Transmission speed

  • TCP: Is slower than UDP, because it requires acknowledgement 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.

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.

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.

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.

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.

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

Handshake

  • TCP: SYN, SYN-ACK, ACK

  • UDP: No handshake (connectionless protocol)

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值