当前位置:网站首页>UDP summary (tcp/ip details volume 1/2)
UDP summary (tcp/ip details volume 1/2)
2022-06-12 15:21:00 【QQ851301776】
Created by QQ:851301776, mailbox :[email protected], Welcome to technical exchange , This blog is mainly my own learning experience , Just to make a little progress every day !
Personal motto :
1. No one was born , As long as it is thick, it will happen .
2. You can have a low degree , You can skip school , But you have to learn
Summary of this blog , It is mainly to facilitate future viewing and learning
One 、 brief introduction
UDP Is a simple datagram oriented transport layer protocol : Each output operation of the process produces exactly one UDP The datagram , And assemble a copy of the IP The datagram . This is different from the stream character oriented protocol , Such as T C P, The whole data generated by the application and the single data actually sent I P The datagram may not have any connection .

U D P No reliability : It passes the application to I P Layer data sent out , But there is no guarantee that they will reach their destination .
Two 、UDP The first one

Port number Express Sending and receiving processes . because I P The layer has put I P A datagram is assigned to T C P or U D P( according to I P Protocol field value in the first part ), therefore T C P Port number from T C P Check it out. , and U D P Port number from U D P Check it out. .T C P Port number and U D P Port numbers are independent of each other .
In spite of their independence , If T C P and U D P At the same time provide some well-known Services , Two protocols usually choose the same port number . It's just for convenience , Not the requirements of the agreement itself .
U D P length Field refers to U D P The first one and U D P Byte length of data . The minimum value of this field is 8 byte ( Send a copy of 0 Bytes of U D P The datagram is O K). This U D P Length is redundant . I P Datagram length refers to the total length of datagram , therefore U D P The length of the datagram is the total length minus I P The length of the head .
UDP Inspection and :U D P Inspection and coverage U D P The first and U D P data . To recall I P The inspection of the first part and , It only covers I P The first — It doesn't cover I P Any data in a datagram .U D P and T C P In the header, there are tests and . U D P And is optional , and T C P And is necessary .
Even though U D P The basic calculation method and I P The first test is similar to the calculation method (16 bit The binary inverse of a word and ), But there are differences between them .
- U D P The length of datagram can be odd bytes , But the test and algorithm is to put a number of 16 bit Add words . The solution is to add padding bytes at the end if necessary 0, It's just for checking and calculating ( in other words , Possible additional padding bytes are not transmitted ).
- U D P Datagram and T C P Segment contains one 1 2 Byte long pseudo header , It's set up to calculate the checksums . Pseudo header contains I P First some fields . The purpose is to make U D P Check twice whether the data has arrived at the destination correctly ( for example , I P No accepted address is not the datagram of the host , as well as I P Did not transmit the data report that should be transmitted to another senior level to U D P).U D P The format of pseudo header in datagram is as shown in figure 11 - 3 Shown .

In this diagram , We give an example of odd length datagram , Therefore, we need to add padding bytes when calculating checksums . Be careful ,U D P The length of the datagram appears twice in the process of inspection and calculation . If the test sum is calculated as 0, Then the stored value is all 1(6 5 5 3 5), This is equivalent in the calculation of binary inverse code . If the test sum of the transmission is 0, Note that the sender does not calculate the check and .
If the sender does not calculate the check sum and the receiver detects the check sum error , that U D P Datagrams will be quietly discarded . No error messages are generated ( When I P Layer detected I P Do the same for the first inspection and when there is an error ).U D P Inspection and is an end-to-end inspection and . It's calculated by the sender , Then it is verified by the receiver . The aim is to discover U D P Any changes in the header and data between the sending end and the receiving end .
Even though U D P Test and are optional , But they should always be in use . stay 8 0 years , Some computer manufacturers turn off... By default U D P The function of inspection and , To improve the use of U D P Agreed N F S(Network File System) The speed of . This may be acceptable in a single LAN , But when the datagram goes through the router , Through the cyclic redundancy test of the link layer data frame ( Such as Ethernet or token ring data frame ) Most errors can be detected , Cause the transmission to fail . Believe it or not , There are also software and hardware errors in routers , So as to modify the data in the datagram . If end-to-end U D P Inspection and function , So these mistakes are U D P The datagram can't be detected . in addition , Some DLL protocols ( Such as S L I P) There is no form of data link verification and .
Host Requirements RFC Statement ,U D P Checks and options are on by default . It also states , If the sender has calculated the check and , Then the receiver must check the received check and ( If received inspection and not for 0). however , Many systems do not comply with this , The received inspection sum is verified only when the export inspection sum option is turned on .
3、 ... and 、 Code implementation
struct udphdr {
__be16 source; // Source port
__be16 dest; // Destination port
__be16 len; //UDP Header and application data length
__sum16 check; // check
};边栏推荐
- SCUACM22暑假集训前劝退赛部分题解
- [jvm learning] local method stack and heap
- Idea大全(转载)
- Industrial end: a new battlefield of 618
- 应势而变,2022年下半场的升级之路
- FIRSTVT and LASTVT vernacular
- Alibaba, Tencent and pinduoduo set an example, and the new logic of industrial Internet is gradually emerging
- Qiming Zhixian shares the application scheme of 2.8-inch handheld central control screen
- Method reference instance method reference
- Deepin20.6 rtx3080 installing graphics card drivers 510.60.02, cuda11.6, pytorch1.11
猜你喜欢

Acwing summer daily question (sexy prime number on June 10)

Servlet connects to database to realize user login function

TCP与UDP的区别,以及TCP的三次握手和TCP的四次挥手

Qiming cloud sharing | demonstrate the switch through an example of the matter protocol to control the light on and off through the matter protocol

Wild pointer understanding

Xshell 7 official website free download

Dart typedef的理解

ROS 中 boost::bind( ) 的使用

IMU learning records

Deepin20.6 rtx3080 installing graphics card drivers 510.60.02, cuda11.6, pytorch1.11
随机推荐
Pta: self test -3 array element cyclic right shift problem (20 points)
New关键字、引用&与指针的学习记录
TCP/IP 三次握手四次挥手(面试题)
Module yaml error: Unexpected key in data: static_ context [line 9 col 3]
Simple crawler framework: parsing 51job page position information
[spark][core] interview questions talk about push based shuffle
[jvm learning] types of GC and allocation process of objects on JVM heap
jupyter notebook新環境快捷方式
TCP与UDP的区别,以及TCP的三次握手和TCP的四次挥手
使用CSDN-markdown编辑器
Seaborn的简述
2021-06-27
Servlet连接数据库实现用户登录功能
2021-06-20
ROS beginners write the server that the little turtle rotates a certain angle at a certain speed
POSTMAN-REST Client插件的应用
Scala下载及IDEA安装Scala插件(保姆级教程超详细)
Use of multithreading
Points chocolate (two points answer) Blue Bridge Cup provincial competition
Introduction to resttemplate