当前位置:网站首页>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
边栏推荐
- Variable definition and use
- Leetcode punch in diary day 01
- Paddlepaddle does not support arm64 architecture.
- ROS series (I): rapid installation of ROS
- L3-011 direct attack Huanglong (30 points)
- SQL learning record
- Cmake qmake simple knowledge
- Wechat applet cloud database value assignment to array error
- Solve the technical problems in seq2seq + attention machine translation
- Three types of cyclic structure
猜你喜欢
Variables, constants, operators
PYMOL-note
PyMOL usage
Code forces round # 784 (DIV. 4) solution (First AK CF (XD)
Key point detection of human hand based on mediapipe
STM32 advanced timer com event
The great gods in acmer like mathematics very much
you need to be root to perform this command
Install PaddlePaddle on ARM
【微服务】(十)—— 统一网关Gateway
随机推荐
Application and definition of interface
Notes sur l'apprentissage profond (Ⅱ) - - Principe et mise en oeuvre de la fonction d'activation
Now is the best time to empower industrial visual inspection with AI
Writing latex with vscode - the latest tutorial 2022 / 4 / 17
Mechanical design knowledge point planning
[AI vision · quick review of NLP natural language processing papers today, issue 28] wed, 1 Dec 2021
What if you encounter symbols you don't know in mathematical formulas
51 single chip microcomputer: D / a digital to analog conversion experiment
Section 2 map and structure in Chapter 6
Source code and update details of new instance segmentation network panet (path aggregation network for instance segmentation)
Redis (17) -- redis cache related problem solving
Vs studio modifies C language scanf and other errors
Seekbar custom style details
A sword is a sword. There is no difference between a wooden sword and a copper sword
ROS series (III): introduction to ROS architecture
PolarMask is not in the models registry
ROS series (IV): ROS communication mechanism series (6): parameter server operation
Design and implementation of redis (4): what is the event driver of redis
Design and implementation of redis (2): how to handle expired keys
Variables, constants, operators