|
Posted by d43m0n AT shaw DOT ca on 05/04/07 09:04
I'm writting a bunch of standards for interpreting net communication,
and built my first icmp echo request interpreter, and wanted to
release it to the public, it may be of some use to someone... I will
post back the entire class, but this was just a quick sandbox code I
wrote up just to understand the protocol standard...
<?php
$data = "\x08\x00\x19\x2f\x00\x00\x00\x00\x70\x69\x6e\x67";
/*
8 bits in a byte
strlen() returns length of a string in bytes.
*/
//$data = "\x08\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00";
echo 'String $data is ' . strlen($data) . ' bytes in size, or ' .
(strlen($data) * 8) . ' bits in size' . "\n";
var_dump($data);
var_dump(unpack("Ctype/Ccode/Cchecksum/nidentifier/nsequenceNumber/
Ndata", $data));
print_r(unpack("Ctype/Ccode/Cchecksum/nidentifier/nsequenceNumber/
Ndata", $data));
echo implode(' ', unpack('C*', $data)) . "\n";
foreach (unpack("Ctype/Ccode/Cchecksum/nidentifier/nsequenceNumber/@8/
c*data", $data) as $key => $string) {
echo $key . ' => '. str_pad(dechex($string), 2, '0', STR_PAD_LEFT) .
"\n";
}
?>
Comments are welcome... please!
Navigation:
[Reply to this message]
|