Skip to content

Instantly share code, notes, and snippets.

@maakunh
Last active October 24, 2017 08:14
Show Gist options
  • Save maakunh/b741e3aeeef10e25e9ded0c0866dc914 to your computer and use it in GitHub Desktop.
Save maakunh/b741e3aeeef10e25e9ded0c0866dc914 to your computer and use it in GitHub Desktop.
<?php
require_once "parse_arp_from_pcap.php";
//センサーネットワークアドレスを取得する
$network_addr = sensor_network_addr();
list($network_ip, $mask) = explode('/', $network_addr);
$imax = pow(2, 32 - $mask) - 2;
for($i = 1; $i <= $imax; $i++){
$ip_long = ip2long($network_ip) + $i;
$rtn = exec('ping -c 1 '.long2ip($ip_long).' > /dev/null &');
$i++;
echo long2ip($ip_long).PHP_EOL;
if($i > $imax){
$i = 1;
}
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment