long2ip($ip)."";
echo "
Subnet Mask: ". long2ip($netmask)."";
echo "
Network Address: ". long2ip($na)."";
echo "
Broadcast Address: ". long2ip($ba)."";
echo "
Total Available Hosts: ".($ba - $na - 1)."";
echo "
Host Range: ". long2ip($na + 1)." - ".
long2ip($ba - 1)."";
echo "";
}
?>
Consider an example. If you supply 192.168.1.101 as the IP address and
255.255.255.0 as the subnet mask, you should see the output shown in Figure 16-2.
Figure 16-2. Calculating network addressing
Testing User Bandwidth
Although various forms of bandwidth-intensive media are commonly used on today??™s
Web sites, keep in mind that not all users have the convenience of a high-speed
network connection at their disposal. You can automatically test a user??™s network
speed with PHP by sending the user a relatively large amount of data and then noting
the time it takes for transmission to complete.
CHAPTER 16 ?– NETWORKING 423
To do this, create the datafile that will be transmitted to the user. This can be
anything, really, because the user will never actually see the file. Consider creating it
by generating a large amount of text and writing it to a file. For example, this script will
generate a text file that is roughly 1.5MB in size:
// Create a new file, creatively named "textfile.txt"
$fh = fopen("textfile.txt","w");
// Write the word "bandwidth" repeatedly to the file.
Pages:
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502