Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why would you send a UDP packet with no payload?

Tags:

udp

It seems that a UDP packet can be sent without a payload.

The only thing I can think of that doesn't need a payload is for NAT hole punching. What else could this be used for?

This relates to my previous question Under Linux, can recv ever return 0 on UDP?

I suppose more to the point is that if it's been specified as part of some standard, then it's been thought to be useful somewhere right?

like image 538
hookenz Avatar asked Oct 15 '25 17:10

hookenz


1 Answers

Anything! The UDP packet isn't empty -- it comes with the sender's identity. Therefore, such a packet could be used as a primitive kind of signal: maybe a hello, a goodbye, or a keep-alive.

With interfaces like sendmsg, an empty packet might be used in order to send auxiliary data, like a cmsg structure (which can be used for things like transferring file descriptors between two processes on Linux).

EDIT: One more use: NAT traversal algorithms such as STUN or UDP hole punching.

like image 123
nneonneo Avatar answered Oct 19 '25 13:10

nneonneo