


Characteristics of UDP protocol and its header format
Features of UDP
The UDP protocol is very simple, and it adds almost no functions to the IP layer. Let’s take a look at some features of the UDP protocol:
UDP is connectionless and delivers best effort. It will not notify you in advance before sending data. It just sends it and does not care whether you can receive it or not.
UDP is message-oriented. Whatever content the application gives it, it encapsulates a header in front of the content and forwards it to the IP layer below. It doesn’t matter whether the content is large or small, I will send whatever you give me. For its brainless operation, the application process needs to choose the appropriate size. To prevent overly large data packets from being split at the IP layer, marketing efficiency will be improved.
UDP supports one-to-one, one-to-many and many-to-many communication. Judging from the fact that TCP only supports point-to-point communication, UDP seems to be doing a pretty good job.
The UDP header is simple and is a fixed 8 bytes.
Based on the above characteristics of UDP, we can guess some of its application scenarios:
Suitable for environments with relatively good networks and good for packet loss Not sensitive.
Scenarios that require broadcasting, such as the DHCP protocol, which requires broadcasting, so it uses the UDP protocol.
In scenarios with high transmission efficiency and fast speed, such as live video broadcast, it is generally insignificant that a few frames of live video broadcast are lost.
UDP header format
As mentioned above, the UDP header is a fixed 8 bytes. Compared with TCP, its header overhead is very small.
Source port number, occupies 2 bytes
Destination port number, occupies 2 bytes
Header length, occupies 2 bytes
Checksum, occupies 2 bytes
If the destination host receives a UDP packet with an illegal port number, it will discard the packet and then send an ICMP error message "Port Unreachable" to the source host. The traceroute command uses this feature to obtain path information between two hosts.
The verification method of UDP is somewhat special. When verifying, it needs to add a 12-byte pseudo header to the header at zero time. The pseudo header is used only for verification and is discarded after verification is completed. In addition, unlike IP datagrams which only check the header, it will check the header and data part.
Related recommendations: "linux video tutorial"
The above is the detailed content of Characteristics of UDP protocol and its header format. For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



How to use PHP and UDP protocols to implement asynchronous communication In modern Internet applications, asynchronous communication has become a very important method. By using asynchronous communication, user requests can be processed concurrently without blocking the main thread, improving system performance and response speed. As a popular back-end programming language, PHP how to use UDP protocol to achieve asynchronous communication? This article will introduce how to use the UDP protocol in PHP to implement simple asynchronous communication, and attach specific code examples. 1. Introduction to UDP protocolU

Common UDP port numbers are 53, 69, 161, 2049, 68, and 520. UDP uses port numbers to reserve their own data transmission channels for different applications: 1. Network File System (NFS), the port number is 2049; 2. Simple Network Management Protocol (SNMP), the port number is 161; 3. Domain Name System (DNS) , the port number is 53; 4. Simple File Transfer System (TFTP), the port number is 69; 5. Dynamic Host Configuration Protocol (DHCP), the port number is 68; 6. Routing Information Protocol, the port number is 520, etc.

UDP (User Datagram Protocol) is a lightweight connectionless network protocol commonly used in time-sensitive applications. It allows applications to send and receive data without establishing a TCP connection. Sample Java code can be used to create a UDP server and client, with the server listening for incoming datagrams and responding, and the client sending messages and receiving responses. This code can be used to build real-world use cases such as chat applications or data collection systems.

UDP provides "connectionless" transport services. The Chinese name of UDP is User Datagram Protocol. It is a connectionless transport layer protocol in the OSI reference model. It provides simple and unreliable transaction-oriented information transmission services; UDP provides applications with a way to send encapsulated data without establishing a connection. IP packet method.

1. Socket: socket: ip address + port number. In the TCP/IP protocol, it uniquely identifies a process in network communication. Sockets are used to describe a one-to-one relationship between network connections. The TCP/IP protocol stipulates that network data flow should use big-endian byte order, that is, (memory) low address high byte (data). 2. UDP_SOCKET related UDP protocol----User Datagram Protocol (non-connection oriented)---SOCK_DGRAMh represents host, n represents network, l represents 32-bit long integer, and s represents 16-bit short integer. The IPv4 address format is defined in netinet/in.h, IPv4 address: sockadd

Basic introduction to UDP programming communication classes DatagramSocket and DatagramPacket [data packet/datagram] implement network programs based on the UDP protocol. UDP datagrams are sent and received through the datagram socket DatagramSocket. The system does not guarantee that the UDP datagram will be safely delivered to the destination, nor is it sure when it will arrive. The DatagramPacket object encapsulates a UDP datagram, which contains the IP address and port number of the sender and the IP address and port number of the receiver. Each datagram in the UDP protocol gives complete address information, so there is no need to establish a connection between the sender and the receiver. The two classes/objects at the core of the basic process Da

UDP is a connectionless transport layer protocol that provides a way to send data packets to the network, but does not guarantee the reliability, sequence and integrity of data packets, nor does it provide congestion control and flow control, etc. Function. Characteristics of UDP: 1. No connectivity, no need to establish a connection before sending data, data packets can be sent directly to the target host; 2. High efficiency, the header overhead is small, only 8 bytes; 3. Unreliability, It does not provide the reliability of data packets. After the data packet is sent, it will not be resent even if it is lost, nor does it guarantee the order of the data packets, etc.

The main reason why DNS (DomainNameSystem) uses UDP (UserDatagramProtocol) instead of TCP (TransmissionControlProtocol) is for performance and efficiency considerations. The following explains in detail why DNS chooses to use the UDP protocol: Small requests and fast responses: DNS queries are usually small requests, requiring only a few bytes of data transfer. UDP is a connectionless protocol that does not require establishing a connection before communicating, but instead sends packets to the destination address and waits for a response. This makes UDP more suitable for fast response scenarios than TCP. Low latency: DNS queries generally require low latency to provide fast domain name resolution services.
