UDP is a simple stateless transport layer (AKA OSI layer 4) protocol, one of the core Internet protocols. It provides source and destination ports, basic checksumming, but provides not guarantees of delivery, order of packets, or duplicate delivery.
This page hosts a formal specification of UDP (User Datagram Protocol) datagram using Kaitai Struct. This specification can be automatically translated into a variety of programming languages to get a parsing library.
digraph {
rankdir=LR;
node [shape=plaintext];
subgraph cluster__udp_datagram {
label="UdpDatagram";
graph[style=dotted];
udp_datagram__seq [label=<<TABLE BORDER="0" CELLBORDER="1" CELLSPACING="0">
<TR><TD BGCOLOR="#E0FFE0">pos</TD><TD BGCOLOR="#E0FFE0">size</TD><TD BGCOLOR="#E0FFE0">type</TD><TD BGCOLOR="#E0FFE0">id</TD></TR>
<TR><TD PORT="src_port_pos">0</TD><TD PORT="src_port_size">2</TD><TD>u2be</TD><TD PORT="src_port_type">src_port</TD></TR>
<TR><TD PORT="dst_port_pos">2</TD><TD PORT="dst_port_size">2</TD><TD>u2be</TD><TD PORT="dst_port_type">dst_port</TD></TR>
<TR><TD PORT="length_pos">4</TD><TD PORT="length_size">2</TD><TD>u2be</TD><TD PORT="length_type">length</TD></TR>
<TR><TD PORT="checksum_pos">6</TD><TD PORT="checksum_size">2</TD><TD>u2be</TD><TD PORT="checksum_type">checksum</TD></TR>
<TR><TD PORT="body_pos">8</TD><TD PORT="body_size">(length - 8)</TD><TD></TD><TD PORT="body_type">body</TD></TR>
</TABLE>>];
}
udp_datagram__seq:length_type -> udp_datagram__seq:body_size [color="#404040"];
}