This is not as easy as it may seem. It involves dealing with raw sockets and protocols that on a good day can be difficult to understand. There are libraries for PHP to help but even then any extension developed might require a specific OS/Kernel in order to work properly because of the fragmentation between PHP on Linux/Mac and PHP on Windows.