tcp协议和udp协议区别

TCP and UDP are two protocols that are part of the transport layer in a TCP/IP model of data transmission. Both share the same core function – transmitting data packets from the client to the server and vice versa.

TCP和UDP是两个协议,它们是数据传输的TCP / IP模型中传输层的一部分。 两者共享相同的核心功能-将数据包从客户端传输到服务器,反之亦然。

But it is the difference between TCP and UDP protocols which make them appropriate for specialized requirements. In this tutorial, we will attempt to understand TCP and UDP before proceeding to highlight their differences.

但是正是TCP和UDP协议之间的差异使它们适合于特殊要求。 在本教程中,我们将尝试理解TCP和UDP,然后再着重强调它们之间的区别。

TCP和UDP协议之间的差异 (Differences Between TCP and UDP Protocol)

Both the protocols serve completely different purposes and usually aren’t interchangeable. Though TCP can easily perform all the functionality that the UDP protocol performs at the moment, it will slow down things to an unacceptable level.

两种协议的用途完全不同,通常是不可互换的。 尽管TCP可以轻松执行UDP协议目前执行的所有功能,但它将使事情降到令人无法接受的程度。

For a quick background, think of the online gaming industry where missing out on a single data packet doesn’t make much of a difference. In this case, if TCP is implemented instead of UDP, it will verify the delivery of the packet and resend it if undelivered.

快速了解一下在线游戏行业,在该行业中,丢失单个数据包的影响不大。 在这种情况下,如果实现的是TCP而不是UDP,它将验证数据包的传递并在未传递时重新发送。

But games drop a lot of packets and frames when streamed online and retransfer of dropped packets will make the game unplayable!

但是游戏在在线流式传输时会丢弃大量数据包和框架,并且重新传输丢弃的数据包将使游戏无法玩!

So, when we wish to understand the difference between TCP and UDP protocols, we need to start by learning these TCP/IP protocols one by one.

因此,当我们希望了解TCP和UDP协议之间的区别时,我们需要首先学习这些TCP / IP协议。

什么是TCP? (What is the TCP?)

TCP is short for Transmission Control Protocol. This data transfer protocol is connection-oriented i.e. it waits for a proper connection to be established between the communicating devices.

TCP是传输控制协议的缩写。 该数据传输协议是面向连接的,即它等待在通信设备之间建立正确的连接。

  • The connection is closed once the data transfer is complete.数据传输完成后,连接将关闭。
  • These connections are verified using a three-way handshake.这些连接使用三向握手进行验证。
  • It ensures the proper delivery of data between the two devices.这样可确保在两个设备之间正确传输数据。

To do the above three things, TCP employs its thorough error-checking mechanisms through flow control and data acknowledgement.

为了完成上述三件事,TCP通过流控制和数据确认采用了其彻底的错误检查机制。

  • TCP uses data sequencing to ensure that all the data packets arrive at the receiver in the order they were sent.TCP使用数据排序以确保所有数据包均按其发送顺序到达接收器。
  • In the case of packet loss, the specific data packets can be transferred again using TCP. 在丢包的情况下,可以使用TCP重新传输特定的数据包。

While it is a heavy-weight protocol, TCP compromises on speed and doesn’t allow broadcasting. With its variable header length of 20 to 80 bytes, TCP finds itself being used in HTTP, FTP, SMPT, and Telnet.

TCP虽然是重量级协议,但会影响速度,并且不允许广播。 TCP具有20到80个字节的可变报头长度,可用于HTTP,FTP,SMPT和Telnet。

TCP的应用 (Applications for TCP)

TCP allows a person to establish a connection between systems that may or may not be similar to each other. Its support for a variety of networking protocols makes it a popular choice for inter-networking between two or more parties.

TCP允许一个人在彼此相似或不同的系统之间建立连接。 它对各种网络协议的支持使其成为两个或多个参与者之间进行网络互连的流行选择。

TCP allows easy identification of errors and delays data transfer in case the network is congested. This ensures that packet loss is minimized greatly.

TCP可以轻松识别错误,并在网络拥塞的情况下延迟数据传输。 这样可以确保最大程度地减少数据包丢失。

Hence, it is used for instances when a delay is acceptable while packet loss is not.

因此,它用于延迟可接受但丢包不可接受的情况。

什么是UDP? (What is the UDP?)

UDP is short for User Datagram Protocol. This data transfer protocol is connectionless and oriented with user datagrams.

UDP是用户数据报协议的缩写。 该数据传输协议是无连接的,并且面向用户数据报。

  • A datagram is a unit for data transfer in the case of packet-switched networks.在分组交换网络中,数据报是用于数据传输的单位。
  • While its functioning is broadly similar to TCP, UDP doesn’t wait for the receiver to be ready to receive the data.尽管其功能与TCP大致相似,但UDP并不等待接收者准备好接收数据。
  • It doesn’t wait for a properly established connection or use handshake protocols to check the same. 它不会等待正确建立的连接,也不会使用握手协议进行检查。

This, coupled with UDP’s basic checksum-based error checking mechanisms, increase the possibility of data packet loss.

再加上UDP的基于校验和的基本错误检查机制,增加了数据包丢失的可能性。

  • If packet loss occurs during a UDP transfer, the specific lost packets cannot be sent again.如果在UDP传输期间发生数据包丢失,则无法再次发送特定的丢失数据包。
  • UDP doe not offer any data sequencing either, which means that ordering the data packets has to be done by an application.UDP也没有提供任何数据排序,这意味着必须由应用程序对数据包进行排序。
  • Unlike TCP, UDP offers a lightweight alternative for data transfer.与TCP不同,UDP提供了一种轻量级的数据传输替代方案。
  • It’s simpler, faster than TCP and efficient.它比TCP更简单,更快,并且效率更高。
  • It allows things like broadcasting which isn’t possible through TCP.它允许像TCP之类的广播之类的事情。

With its fixed header length of 8 bytes, UDP finds itself being used in DNS, TFTP, RIP, SNMP and VoIP.

UDP具有8字节的固定报头长度,可用于DNS,TFTP,RIP,SNMP和VoIP。

UDP的应用 (Applications for UDP)

UDP removes the need for an established connection. This helps cut down the latency during startup. UDP allows for broadcasting and multicast data transfer. It is a popular choice for multimedia transmissions such as VoIP.

UDP消除了建立连接的需要。 这有助于减少启动期间的延迟。 UDP允许广播和多播数据传输。 对于VoIP等多媒体传输而言,它是一种流行的选择。

To ensure maximum speed, it uses only checksums to identify errors. This makes the data transfer speed to be enhanced at the cost of risking data packet loss.

为了确保最高速度,它仅使用校验和来识别错误。 这使得数据传输速度得以提高,但以丢失数据包的风险为代价。

As there is no need for a connection to be established, delays aren’t an issue in UDP. Hence it is used for instances where packet loss can be tolerated, but delay can’t.

由于不需要建立连接,因此在UDP中延迟不是问题。 因此,它用于可以容忍丢包但不能延迟的情况。

总结TCP和UDP协议之间的差异 (Summarizing the differences between TCP and UDP protocols)

Now that we have an idea about both these protocols, we can move on to the difference between TCP and UDP protocols.

现在我们对这两种协议都有了一个了解,现在我们可以继续介绍TCP和UDP协议之间的区别。

These differences play a big role in helping you choose the correct protocol for your needs. Both TCP and UDP offer a variety of pros and cons in terms of functionality.

这些差异在帮助您选择所需的正确协议方面起着重要作用。 就功能而言,TCP和UDP都有许多优点和缺点。

Here is a table that contains an overview of the difference between TCP and UDP protocols.

下表概述了TCP和UDP协议之间的区别。

Transmission control protocol (TCP) User datagram protocol (UDP)
TCP is a connection-oriented data transfer protocol UDP is a datagram-oriented data transfer protocol
Data is guaranteed to safely reach the receiver Data is not guaranteed to safely reach the receiver
Uses data acknowledgment and flow control to perform an in-depth error check Uses checksums to search for basic errors in transmission
Data sequencing is handled by TCP Data sequencing needs to be handled by an application
TCP works slower than UDP and is a heavyweight protocol UDP works faster than TCP and is a lightweight protocol
HTTPs, SMPT, FTP and Telnet use TCP for data exchange DNS, DHCP, TFTP, VoIP and RIP utilise UDP for data exchange
TCP does not allow broadcasting UDP allows broadcasting
The header length can vary between 20 to 80 bytes The header length is fixed at 8 bytes
传输控制协议(TCP) 用户数据报协议(UDP)
TCP是一种面向连接的数据传输协议 UDP是面向数据报的数据传输协议
保证数据可以安全到达接收器 无法保证数据可以安全到达接收器
使用数据确认和流控制来执行深入的错误检查 使用校验和来搜索传输中的基本错误
数据排序由TCP处理 数据排序需要由应用程序处理
TCP比UDP慢,并且是重量级协议 UDP比TCP更快,是一种轻量级协议
HTTP,SMPT,FTP和Telnet使用TCP进行数据交换 DNS,DHCP,TFTP,VoIP和RIP利用UDP进行数据交换
TCP不允许广播 UDP允许广播
标头长度可以在20到80个字节之间变化 标头长度固定为8个字节

This difference between TCP and UDP protocols make each better at handling specific kinds of use.

TCP和UDP协议之间的差异使每种协议在处理特定种类的使用方面都更好。

Hence, while TCP is great for general use, choosing UDP would be the right decision when speed is more essential than the risk of packet loss.

因此,尽管TCP非常适合一般使用,但是当速度比丢包风险更重要时,选择UDP是正确的决定。

结语 (Wrapping up)

There is a lot of differences between TCP and UDP protocols. These differences mean that irrespective of your data transfer needs, you always have one protocol which will optimally meet your requirements.

TCP和UDP协议之间有很多区别。 这些差异意味着,无论您的数据传输需求如何,您始终拥有一个可以最佳满足您需求的协议。

  • TCP is designed to handle load efficiently and ensure packet losses don’t occur.TCP旨在有效处理负载并确保不会发生数据包丢失。
  • On the other hand, UDP is based on ensuring maximum speed in data transmission.另一方面,UDP基于确保最大数据传输速度。

Despite the difference between TCP and UDP protocols, both are widely used to transfer data over the network.

尽管TCP和UDP协议之间存在差异,但两者均广泛用于通过网络传输数据。

It’s critical to know the differences between TCP and UDP protocols when you’re working with developing applications that communicate over the network.

在开发通过网络进行通信的应用程序时,了解TCP和UDP协议之间的区别至关重要。

I hope this tutorial has been useful to you.

希望本教程对您有所帮助。

If you have any feedback, queries or suggestions, feel free to reach out to us in the comments below.

如果您有任何反馈,疑问或建议,请随时通过以下评论与我们联系。

翻译自: https://www.journaldev.com/38467/difference-between-tcp-and-udp-protocols

tcp协议和udp协议区别

tcp协议和udp协议区别_TCP和UDP协议有什么区别?相关推荐

  1. TCP协议和UDP协议的区别及其应用

    下面是TCP和UDP的简单程序: 简单的TCP网络程序 https://blog.csdn.net/qq_37941471/article/details/80738319 简单的UDP网络程序 ht ...

  2. doraemon的python tcp协议和udp协议

    ### 8.9 tcp协议和udp协议#### 8.9.1 tcp协议 -------打电话 特点:- ​ 可靠 慢 全双工通信 - ​ 建立连接的时候:三次握手 - ​ 断开连接的时候:四次挥手 - ...

  3. socket通信 tcp协议和udp协议 C++

    Socket通信学习(套字接) Socket通信主要分两种:TCP协议和UDP协议 TCP:Transmission Control Protocol UDP:User Datagram Protoc ...

  4. TCP协议和TCP连接

    TCP协议和TCP连接 一.TCP协议的简介 二.TCP连接的简介 1.TCP连接的建立(TCP三次握手) 2.TCP连接的断开(TCP四次挥手)   一.TCP协议的简介   TCP(Transmi ...

  5. qt定时连续发送udp数据包_TCP和UDP

    首先强调一点,TCP/IP协议是一个协议簇.里面包括很多协议的,UDP只是其中的一个, 之所以命名为TCP/IP协议,因为TCP.IP协议是两个很重要的协议,就用他两命名了. 两个协议的区别实际使用时 ...

  6. TCP协议和UDP协议的区别

    目录 一.简介UDP和TCP来源 OSI七层结构 TCP/IP协议模型 二.TCP协议: 1.TCP的功能: 2.UDP的代码实现: 3.TCP协议的组成: 4.TCP的连接管理:TCP的三次握手(建 ...

  7. 传输层TCP协议和UDP协议

    传输层协议 文章目录 传输层协议 传输层: 传输层协议: UDP协议: TCP协议: UDP协议和TCP协议的比较: 适用场景: 传输层: 传输层是OSI中最重要,最关键的一层,是唯一负责总体的数据传 ...

  8. TCP协议和UCP协议的异同

    TCP和UDP 1.共同点: 同属于传输层协议 2.不同点 TCP:有连接,可靠 UDP:无连接,不保证可靠 TCP:  (Transfer Control Protocol 传输控制协议) (1). ...

  9. tcp序列号为什么是随机的_TCP与UDP

    Hofe's blog​hofe.work 里面有最新的版本 这篇介绍了下TCP与UDP面试题常考内容,并做了延伸,解释了原理. 面试题 tcp和udp的区别 tcp如何实现可靠性 怎么实现拥塞控制 ...

最新文章

  1. ajax、offset
  2. 1810: Huffuman树(vector模拟)
  3. 视+AR正式发布EasyAR引擎2.0版,并宣布开放AR相机平台
  4. 关系型数据库的隔离级别 读一致性
  5. 从补丁到Root——CVE-2014-4323分析
  6. java xml生成word文档_java生成word文档
  7. GridWorld实训总结报告
  8. python lambda拉姆达表达式
  9. DLP 3D打印技术有什么优点
  10. hsv白色h值是多少_rgb颜色模型与hsv颜色模型的理解
  11. Python3批量修改图片像素
  12. 如何避免2.4GHz ISM频段下各种无线设备的干扰
  13. 微信小程序自定义搜索导航栏
  14. CSS-背景颜色 | background-color
  15. 安居客无锡二手房数据获取
  16. 苹果、天猫同步关停是因为发新品?这些猜想你看靠谱吗....
  17. 为什么要使用高彩模式
  18. networks.agent_net Additional property attachable is not allowed
  19. deepfakes超进化!反复变脸行云流水,完全没有PS痕迹,推特10万点赞
  20. 图片大小如何调整到100k?如何把图片改成100kb以内?

热门文章

  1. Linux企业级项目实践之网络爬虫(2)——网络爬虫的结构与工作流程
  2. 实习笔记(数据库相关)-2014
  3. Membership、MembershipUser和Roles类
  4. [转载] Python中filter筛选函数匿名参数问题
  5. [转载] Unicode文本排序和Unicode数据库
  6. Linux系统上安装JDK和Tomcat服务器
  7. linux使用tar命令打包压缩时排除某个文件夹或文件
  8. HIVE大数据出现倾斜怎么办
  9. 【原创】使用Ultra Librarian为Altium Designer 09生成元器件库
  10. DataSet数据导入到Excel