在 PHP 中创建 IP 层数据包?
我想知道是否可以使用 PHP 创建网络层数据包(即定义我自己的 IP 标头)?看起来 socket_create
和 SOCK_RAW
只能让您定义 IP 数据包的内容,而不是标头本身。
预先感谢您的回复!
I'm wondering if it possible to create network layer packets (i.e. define my own IP headers) using PHP? It seems like socket_create
with SOCK_RAW
only lets you define the contents of the IP packet, not the headers itself.
Thanks in advance for your replies!
只要我以 root 身份运行脚本,我就能在 Mac OS X 上使用
SOCK_RAW
成功创建套接字。我使用的示例取自 Jean Charles MAMMANA 的 ping.inc.php
我创建了一个 ping.php 包装器,并执行:
sudo ping.php www.google.com
。这是我的 ping.php 包装器:
I was able to successfully create a socket using
SOCK_RAW
on Mac OS X, as long as I ran the script as root.The example I used was taken from Jean Charles MAMMANA's ping.inc.php
I created a ping.php wrapper, and executed:
sudo ping.php www.google.com
.Here's my ping.php wrapper: