使用 PHP 发送 IGMP
我可以使用 PHP 脚本发送 IGMP 数据包吗? IGMP 甚至位于传输层吗?
我正在查看一些发往 224.0.0.251 的 JOIN 数据包。
我注意到 IP 标头没有分配端口,但指定了 MAC 地址,这使我相信 IGMP 不在传输层上,而是在网络层上。 (希望我说得对)
有人可以帮我澄清一下吗?我只是想发送一个 JOIN 数据包。
我正在阅读 rfc3376 试图找到答案,但它只是展示了如何构建一个。在尝试这样做时,我只是收到一个格式错误的数据包。
Can I send out IGMP packets with a PHP script? Is IGMP even on the Transport Layer?
I was looking at some JOIN packets that are destined for 224.0.0.251.
I noticed that the IP header had no port assigned but did have MAC addresses specified, which led me to believe that IGMP was not on the Transport Layer but rather on the Network Layer. (hopefully I said that right)
Can someone clarify this for me? I'm just trying to send out a JOIN packet.
I was reading through rfc3376 to try and find the answer, but it just shows how to construct one. On trying to do so, I just get a malformed packet.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
传统上,您可以使用套接字选项
IP_ADD_MEMBERSHIP
(以及相应的IP_DROP_MEMBERSHIP
)来加入多播组。这将触发操作系统生成 IGMP 加入数据包。这些选项使用
IPPROTO_IP
“级别”设置为setsockopt ()
根据 this 上的问题bugs.php.net 站点这些选项默认不可用。然而,该页面上列出了一个补丁,可以将它们添加到您的 php 安装中。
Traditionally you would use the socket option
IP_ADD_MEMBERSHIP
(and the correspondingIP_DROP_MEMBERSHIP
) to join a multicast group. That would trigger the operating system to generate an IGMP join packet.These options are set using the
IPPROTO_IP
"level" tosetsockopt()
According to this issue on the bugs.php.net site these options are not available by default. However there is a patch listed on that page that should add them to your php installation.
现有的 PHP 手段可能不行。现有的扩展允许您访问 TCP/UDP 层,但不能访问下面的层。您可能可以使用一些命令行工具,例如 Nemesis 项目 中的 nemesis-igmp去做它。
Probably not with existing PHP means. Existing extensions allow you access to TCP/UDP layer but not below. You probably could use some command-line tool like nemesis-igmp from Nemesis project to do it.