当前位置:网站首页>UDP协议与TCP协议
UDP协议与TCP协议
2022-04-23 03:45:00 【小明学编程~】
目录
udp协议特点
(1)无连接
UDP通信双方在发生数据之前是不需要进行沟通的,客户端只需要知道服务端的IP地址和端口号就可以进行发送数据
(2)传输不可靠
不保证数据是可靠并且有序到达对端的。
(3)面向数据报
udp对于应用层和传输层数据递交的时候都是整条数据进行交付的。
UDP传输可能遇到的问题及解决方案
(1)出现此问题的原因:udp数据报的长度是65535字节,但是如果要传输的数据大于65535字节 则在传输过程中会遇到问题。
(2)解决方法步骤:设计应用层协议(自定制协议字段)字段
a、属于同一个应用层的数据切割成不同的块,因为udp传输不是可靠的传输,因此给不同的数据模块加上相同的id。
b、udp传输不是有序到达对端的,在报头当中加上偏移量,使用偏移量描述分块数据在整个应用层数据包当中的位置。
c、包头数据中加上分块数据长度。
TCP协议特点
(1)面向连接的
TCP通信双方在发送数据之前需要先建立连接,才能够发送数据
(2)可靠传输
TCP保证传输过程中数据是可靠有序到达对端的。
(3)面向字节流
a、对于传输的数据之间是没有明显的边界区分的
b、对于接受方在可以接收数据的情况下,可以接收任意字节的数据的。
TCP传输可能遇到的问题及解决方案
(1)出现问题的原因:TCP协议是面向字节流的,会在传输过程造成粘包问题,难以分清数据的 长度。
(2)解决方法:应用层自定制协议,自定制协议增加报头(数据长度)和分隔符
a、[定长报头] + 数据信息
b、[定长包头] + 数据信息 + 分隔符
c、[不定长报头] + 数据 + 分隔符
版权声明
本文为[小明学编程~]所创,转载请带上原文链接,感谢
https://blog.csdn.net/qq_48991744/article/details/124158967
边栏推荐
- 变量、常量、运算符
- mui. Plusready does not take effect
- Digital image processing third edition Gonzalez notes Chapter 2
- 2021-09-03 crawler template (only static pages are supported)
- Use the thread factory to set the thread name in the thread pool
- Chapter VI, Section III pointer
- 7-1 introduction to finance
- The art of concurrent programming (5): the use of reentrantlock
- Win10 boot VMware virtual machine boot seconds blue screen problem perfect solution
- ROS series (III): introduction to ROS architecture
猜你喜欢

Redis (17) -- redis cache related problem solving

Source code and update details of new instance segmentation network panet (path aggregation network for instance segmentation)

ROS series (IV): ROS communication mechanism series (1): topic communication

淺學一下I/O流和File類文件操作

Openvino only supports Intel CPUs of generation 6 and above

深度學習筆記(二)——激活函數原理與實現

Vscode download and installation + running C language

Variables, constants, operators

Wechat applet cloud database value assignment to array error

PYMOL-note
随机推荐
Notes sur l'apprentissage profond (Ⅱ) - - Principe et mise en oeuvre de la fonction d'activation
Man's life
AI CC 2019 installation tutorial under win10 (super detailed - small white version)
Punch in: 4.22 C language chapter - (1) first knowledge of C language - (11) pointer
Photoshop installation under win10
Application and definition of interface
Summary of knowledge map (3)
Common net HP UNIX system FTP server listfiles returns null solution.
Wechat payment iframe sub page has no response
ROS series (I): rapid installation of ROS
Use of rotary selector wheelpicker
ROS series (II): ROS quick experience, taking HelloWorld program as an example
mui. Plusready does not take effect
Opencv4 QR code recognition test
Wechat applet canvas draws a simple asymptotic color of the dashboard
抽象类、接口、常用关键字
2022 group programming ladder game simulation L2-4 Zhezhi game (25 points)
Digital image processing third edition Gonzalez notes Chapter 2
Three types of cyclic structure
Learn about I / O flow and file operations