master
Raw Download raw file

date: “2016-12-01” draft: false title: “UDP”


UDP uses a simple connectionless transmission model with a minimum of protocol mechanism. UDP provides checksums for data integrity, and port numbers for addressing different functions at the source and destination of the datagram. It has no handshaking dialogues, and thus exposes the user’s program to any unreliability of the underlying network and so there is no guarantee of delivery, ordering, or duplicate protection.

UDP Headers

byte 0               1               2               3               4
bits  0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
     +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
   0 |          Source Port          |       Destination Port        |
     +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
   4 |            Length             |           Checksum            |
     +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
   8 |                             data                              |
     +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

UDP Header Descriptions

Bytes Field Description
udp[0:2] Source Port
udp[2:2] Destination Port
udp[4:2] Length Header+data length in bytes
udp[6:2] Checksum Error checking - [RFC768][1]

UDP BPF Shortcuts

BPF Shortcut Syntax Description
port p packet is IPv4/v6, tcp or udp, and has a source or destination port of p
dst port p packet is IPv4/v6, tcp pr udp, and has a destination port of p
src port p packet is IPv4/v6, tcp or udp, and has a source port of p
udp port p packet is IPv4/v6, udp, and has a source or destination port of p
udp dst port p packet is IPv4/v6, udp, and has a destination port of p
udp src port p packet is IPv4/v6, udp, and has a source port of p
udp abbreviaition for: ip proto udp

Additional resources