当前位置:网站首页>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
边栏推荐
- Applet - WXS
- Cmake qmake simple knowledge
- The principle and solution of not allowing pasting in an English Network
- ROS series (IV): ROS communication mechanism series (6): parameter server operation
- JS changes the words separated by dashes into camel style
- Design and implementation of redis (1): understand data structures and objects
- 深度学习笔记(二)——激活函数原理与实现
- Instructions for fastmock
- 標識符、關鍵字、數據類型
- 7-3 poly width
猜你喜欢
Design and implementation of redis (1): understand data structures and objects
对象和类的概念
Design and implementation of redis (2): how to handle expired keys
Design and implementation of redis (5): master-slave replication strategy and optimization
Detailed explanation on the use of annotation tool via (VGg image annotator) in mask RCNN
Un aperçu des flux d'E / s et des opérations de fichiers de classe de fichiers
Applet - WXS
Wechat applet cloud database value assignment to array error
Seekbar custom style details
Development record of primary sensitive word detection
随机推荐
2022 group programming ladder simulation l2-1 blind box packaging line (25 points)
Design and implementation of redis (2): how to handle expired keys
Websites frequented by old programmers (continuously updated)
[AI vision · quick review of NLP natural language processing papers today, issue 28] wed, 1 Dec 2021
ROS series (IV): ROS communication mechanism series (1): topic communication
Numpy's broadcasting mechanism (with examples)
Romantic silhouette of L2-3 of 2022 group programming ladder Simulation Competition (25 points)
Why is it necessary to divide the variance by 255^2 when adding Gaussian noise using the imnoise function of MATLAB
Development record of primary sensitive word detection
Oracle JDK vs OpenJDK
Section 1 array and slicing in Chapter 6
Chapter VI, Section III pointer
Cuda11 is installed perfectly in win10 X + pytorch 1.9 (blood flowing into the river) cuda. is_ Available() becomes true!
Basic knowledge of convolutional neural network
常用的辅助类
Applet - more than two pieces of folding and expansion logic
Redis(17) -- Redis缓存相关问题解决
Solve the technical problems in seq2seq + attention machine translation
A hundred dollars for a hundred chickens
2021-09-03 crawler template (only static pages are supported)