当前位置:网站首页>UDP protocol: simple because of good nature, it is inevitable to encounter "city can play"
UDP protocol: simple because of good nature, it is inevitable to encounter "city can play"
2022-07-06 18:11:00 【Zhang quandan, Foxconn quality inspector】

TCP and UDP What are the differences ?
I usually ask the difference between the two agreements during the interview , Most people will answer ,TCP It's connection-oriented ,UDP It's for connectionless .
What is connection oriented , What is connectionless ? Before intercommunication , The connection oriented protocol establishes the connection first . for example ,TCP Will shake hands three times , and UDP Can't . Why establish a connection ? you TCP Three handshakes , I UDP You can also send three bags to play , What's the difference ?
The so-called establishing a connection , To maintain the connection between the client and the server , And establish a certain data structure to maintain the state of interaction between the two sides , Use this data structure to guarantee the so-called connection oriented features .
for example ,TCP Provide reliable delivery . adopt TCP Connect the transmitted data , No mistakes 、 No loss 、 No repetition 、 And arrive in order . We all know IP There is no reliability guarantee for the package , Once sent out , It's like learning from the West , Lost it 、 Eaten by monsters , Can only let it go . however TCP It claims to be able to do what the connection maintenance program does , and UDP Inherited IP Package features , There is no guarantee that it will not be lost , There is no guarantee of arrival in order .
Again ,TCP Is oriented to a byte stream . When sending, you send a stream , No head, no tail .IP A package is not a stream , But one by one IP package . The reason why it becomes a stream , This is also TCP Your own state maintenance . and UDP Inherited IP Characteristics of , Datagram based , One by one , One by one .
also TCP There can be congestion control . It realizes that the packet is discarded or the network environment is bad , Will adjust their behavior according to the situation , See if it's fast , Would you like to slow down .UDP Won't , The app let me send , I'll send it , Despite the flood .
thus TCP It's actually a stateful service , Generally speaking, it's a brain , It accurately remembers whether it has been sent , Received no , To which , Which should be accepted , No mistake at all . and UDP Stateless service . Generally speaking, it's mindless , Innocent , Just send it out .
UDP What is Baotou like ?
When I send UDP When the package reaches the target machine , Find out MAC Address matching , So he took it down , Pass the rest of the packets to the processor IP Layer code . hold IP Take off your head , Finding goals IP matching , The next? ? Who is the packet in here for ?
At the time of sending , I know I sent a UDP My bag , How did you know about the machine you received ? So in IP There's a... In the head 8 Bit agreement , It will store , What's in the data TCP still UDP, Of course, here it is UDP. therefore , If we knew UDP The format of the head , From the data , Parse it out . After analyzing it ? Who will process the data ?
After dealing with the transport layer , The kernel is basically done , The data inside should be handled by the application itself , But there are so many applications running on one machine , Who should I give it to ?
Regardless of application write usage TCP The data transfer , still UDP The data transfer , Listen to a port . It is this port , Used to distinguish applications , Let's say that ports cannot conflict . Two applications listen on one port , Who will you give it to then ? therefore , Logically speaking , Whether it's TCP still UDP There should be a port number in the header , According to the port number , Give the data to the corresponding application .
When we see UDP When Baotou , It is found that there is indeed a port number , Active port number and target port number . Because it's communication between two ends , That makes sense . But you will also find ,UDP Except for the port number , There is nothing else . and TCP Head to head , This is simply a mess !
UDP Three characteristics of
UDP Just like a child , It has the following characteristics :
- First of all , Simple communication , You don't need a belly of fancy intestines ( A lot of data structures 、 Processing logic 、 Header field ). The premise is that it believes that the online world is beautiful , Uphold the theory of good nature , I believe that the default of network channel is easy to deliver , Not easily discarded .
- second , Credulity . It doesn't make connections , Although there is a port number , But monitoring is in this place , Anyone can send him data , He can also send data to anyone , It can even be transmitted to multiple personal data at the same time .
- Third , I'm so stupid , Don't know how to change things . I don't know when to insist , When should we give way . It will not control the congestion of the contract according to the situation of the network , No matter what happens to network packet loss , How it should be sent back .
边栏推荐
- std::true_ Type and std:: false_ type
- Interesting - questions about undefined
- 历史上的今天:Google 之母出生;同一天诞生的两位图灵奖先驱
- 【Android】Kotlin代码编写规范化文档
- scratch疫情隔离和核酸检测模拟 电子学会图形化编程scratch等级考试三级真题和答案解析2022年6月
- Stealing others' vulnerability reports and selling them into sidelines, and the vulnerability reward platform gives rise to "insiders"
- 重磅!蚂蚁开源可信隐私计算框架“隐语”,主流技术灵活组装、开发者友好分层设计...
- Four processes of program operation
- Introduction to the usage of model view delegate principal-agent mechanism in QT
- OpenEuler 会长久吗
猜你喜欢

从交互模型中蒸馏知识!中科大&美团提出VIRT,兼具双塔模型的效率和交互模型的性能,在文本匹配上实现性能和效率的平衡!...

kivy教程之在 Kivy 中支持中文以构建跨平台应用程序(教程含源码)

2019阿里集群数据集使用总结

传输层 拥塞控制-慢开始和拥塞避免 快重传 快恢复

微信为什么使用 SQLite 保存聊天记录?
![Jerry's access to additional information on the dial [article]](/img/a1/28b2a5f7c16cbcde1625a796f0d188.jpg)
Jerry's access to additional information on the dial [article]

Summary of Android interview questions of Dachang in 2022 (I) (including answers)

I want to say more about this communication failure
![[introduction to MySQL] the first sentence · first time in the](/img/1e/2401d821b1008922bc5f8a15de31f9.png)
[introduction to MySQL] the first sentence · first time in the "database" Mainland

传统家装有落差,VR全景家装让你体验新房落成效果
随机推荐
In terms of byte measurement with an annual salary of 30W, automated testing can be learned in this way
How to output special symbols in shell
最新财报发布+天猫618双榜第一,耐克蓄力领跑下个50年
30 分钟看懂 PCA 主成分分析
adb常用命令
FMT开源自驾仪 | FMT中间件:一种高实时的分布式日志模块Mlog
从交互模型中蒸馏知识!中科大&美团提出VIRT,兼具双塔模型的效率和交互模型的性能,在文本匹配上实现性能和效率的平衡!...
C语言指针*p++、*(p++)、*++p、*(++p)、(*p)++、++(*p)对比实例
Jielizhi obtains the currently used dial information [chapter]
2019阿里集群数据集使用总结
MS-TCT:Inria&SBU提出用于动作检测的多尺度时间Transformer,效果SOTA!已开源!(CVPR2022)...
d绑定函数
模板于泛型编程之declval
Markdown grammar - better blogging
2019 Alibaba cluster dataset Usage Summary
Will openeuler last long
历史上的今天:Google 之母出生;同一天诞生的两位图灵奖先驱
李書福為何要親自掛帥造手機?
TCP packet sticking problem
递归的方式