当前位置:网站首页>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
};边栏推荐
- 机器人前行、旋转的service编写
- Scala download and idea installation of scala plug-ins (nanny level tutorial is super detailed)
- 学习是一件逆人性的事情(成为高手的内功心法)
- 简单的爬虫框架:解析51job页面岗位信息
- 应势而变,2022年下半场的升级之路
- [jvm learning] parental delegation mechanism and PC register (program counter)
- Increase the maximum number of MySQL connections
- ngork实现内网穿透--免费
- Is it safe to open an account for flush mobile stock trading
- 虚拟机中用户和root忘记密码解决办法
猜你喜欢

Function related matters

Interface.

ngork实现内网穿透--免费

SOA Architecture

Swap numbers, XOR, operator correlation

Tcp/ip three handshakes and four waves (interview questions)
![[LDA] rough version notes of EM variational reasoning [to be improved](/img/de/4b028e77694297db05a2d6b6589276.png)
[LDA] rough version notes of EM variational reasoning [to be improved

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

Xshell 7 official website free download

TCP/IP 三次握手四次挥手(面试题)
随机推荐
leetcode每日一题-公平的糖果棒交换
[spark][core] what is an external shuffle service?
RARP总结(TCP/IP详解卷1/2)
C data type
Seaborn Brief
Industrial end: a new battlefield of 618
Module yaml error: Unexpected key in data: static_ context [line 9 col 3]
[jvm learning] local method stack and heap
IMU的学习记录
Method reference instance method reference
Wild pointer understanding
How to write year-end summary
Deepin20.6 rtx3080 installer le lecteur de carte graphique 510.60.02, cuda 11.6, pytorch1.11
Two ways of array simulating queue
Microservice fault tolerance
Pta: self test -2 prime pair conjecture (20 points)
Servlet connects to database to realize user login function
Kinect2.0+ORBSLAM2_ with_ pointcloud_ map
The difference and brief description of "file name" and < file name > import header file used in # include
Some useful websites