为什么要发送没有有效载荷的 UDP 数据包? [英] Why would you send a UDP packet with no payload?

查看:25
本文介绍了为什么要发送没有有效载荷的 UDP 数据包?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

似乎可以在没有负载的情况下发送 UDP 数据包.

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

我能想到的唯一不需要有效载荷的方法是用于 NAT 打孔.这还能用来做什么?

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?

这和我之前的问题有关Linux下,可以recv曾经在 UDP 上返回 0?

我想更重要的是,如果它被指定为某个标准的一部分,那么它被认为在某处很有用,对吗?

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?

推荐答案

任何事情!UDP 数据包不是空的——它带有发送者的身份.因此,这样的数据包可以用作一种原始的信号:可能是打招呼、再见或保持连接.

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.

对于像 sendmsg 这样的接口,可能会使用一个空包来发送辅助数据,例如 cmsg 结构(可用于传输文件描述符之类的事情)在 Linux 上的两个进程之间).

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).

另一种用途:NAT 遍历算法,例如 STUN 或 UDP 打孔.

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

这篇关于为什么要发送没有有效载荷的 UDP 数据包?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆