statsapp.php3 6.44 KB
Newer Older
1 2
<?php
#
3
# Copyright (c) 2000-2013 University of Utah and the Flux Group.
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
# 
# {{{EMULAB-LICENSE
# 
# This file is part of the Emulab network testbed software.
# 
# This file is free software: you can redistribute it and/or modify it
# under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, either version 3 of the License, or (at
# your option) any later version.
# 
# This file is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Affero General Public
# License for more details.
# 
# You should have received a copy of the GNU Affero General Public License
# along with this file.  If not, see <http://www.gnu.org/licenses/>.
# 
# }}}
23 24 25 26
#
chdir("..");
include("defs.php3");

27 28 29
$this_user = CheckLoginOrDie();
$uid       = $this_user->uid();
$isadmin   = ISADMIN();
30

31
PAGEHEADER("Wireless Testbeds Connectivity Statistics");
32 33 34

?>

35
<h2><a href="#instructions">Instructions</a></h2>
36 37 38 39 40 41

<?php

##
## need to find out what datasets exist
##
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56
$dbq = DBQueryFatal("select ws.name,ws.floor,ws.building," .
		    "fi.scale,fi.pixels_per_meter " .
		    "from wireless_stats as ws left join floorimages as fi " .
		    "on fi.building=ws.building and ws.floor=fi.floor");

## now, here's the method:
## if there is more than one floor, only the primary should be listed.
## now, when the applet scans the position data, if it sees more floors than
## the primary, it calls up and downloads the maps it needs.  Thus, we want to
## send a bit for each dataset in the following format:
## "name,building,primary_floor,s1:s2:...:sN,f1:f2:...:fN,ppm1:ppm2:...:ppmN"
## each of these strings is then separated by a ';'

$count = -1;
$lpc = 0;
57 58
$strlist = "";

59 60 61 62 63 64 65
$names = array();
$floors = array();
$buildings = array();
$nameScales = array();
$nameScaleFactors = array();
$namePPMs = array();

66 67
while ($row = mysql_fetch_array($dbq)) {
    $name = $row["name"];
68 69 70 71

    $floor = $row["floor"];
    $building = $row["building"];
    $scale = $row["scale"];
72

73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97
    $factor = 0;
    if ($scale == 1) {
        $factor = 1;
    }
    else if ($scale == 2) {
        $factor = 1.5;
    }
    else {
        $factor = $scale - 1;
    }
    $ppm = $row["pixels_per_meter"];

    # there should only be floor and building per name (this is determined
    # by the PRIMARY KEY  (building,floor,scale) in the floorimages table
    if (!in_array($name,$names)) {
        ++$count;
        
        $names[$count] = $name;
        $floors[$count] = $floor;
        $buildings[$count] = $building;

        $nameScales[$count] = array();
        $nameScaleFactors[$count] = array();
        $namePPMs[$count] = array();
        $lpc = 0;
98 99
    }

100 101 102 103 104 105
    # now, we *can* have more than one value for scale and ppm, but
    # each corresponds to a building-floor-name tuple:
    $nameScales[$count][$lpc] = $scale;
    $nameScaleFactors[$count][$lpc] = $factor;
    $namePPMs[$count][$lpc] = $ppm;
    ++$lpc;
106 107
}

108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150
## now we print out the big list:
$strlist = '';
for ($i = 0; $i <= $count; ++$i) {
    $n = $names[$i];
    $f = $floors[$i];
    $b = $buildings[$i];
    $sa = $nameScales[$i];
    $sf = $nameScaleFactors[$i];
    $ppma = $namePPMs[$i];

    if ($strlist != '') {
        $strlist .= ";";
    }

    $strlist .= "$n,$b,$f,";

    # now add the scales...
    for ($j = 0; $j < count($sa); ++$j) {
        if ($j != 0) {
            $strlist .= ":";
        }
        $strlist .= $sa[$j];
    }
    $strlist .= ",";
    # now add the scale factors...
    for ($j = 0; $j < count($sf); ++$j) {
        if ($j != 0) {
            $strlist .= ":";
        }
        $strlist .= $sf[$j];
    }
    $strlist .= ",";
    # now add the ppms...
    for ($j = 0; $j < count($ppma); ++$j) {
        if ($j != 0) {
            $strlist .= ":";
        }
        $strlist .= $ppma[$j];
    }

}     


151
$auth    = $_COOKIE[$TBAUTHCOOKIE];
152 153 154 155 156 157 158 159

## the requester will need to append '&dataset=...'
$mapurl = "getdata.php3?type=map";
$dataurl = "getdata.php3?type=data";
$positurl = "getdata.php3?type=posit";

echo "<applet name='wireless-stats' code='WirelessMapApplet.class'
              archive='wireless-stats.jar'
160
              width='900' height='700'
161 162 163 164 165 166 167 168 169
              alt='You need java to run this applet'>
            <param name='uid' value='$uid'>
            <param name='auth' value='$auth'>
	    <param name='datasets' value='$strlist'>
	    <param name='mapurl' value='$mapurl'>
	    <param name='dataurl' value='$dataurl'>
            <param name='positurl' value='$positurl'>
     </applet>\n";

170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211
?>

<h3><a name="instructions">Instructions</a></h3>

This applet allows you to inspect the connectivity properties of
various Emulab wireless testbeds and areas.  At the moment, you
can only view statistics for the static WSN testbed, but soon 
you'll be able to inspect the various floors Emulab's wifi testbed
as well.  The display shows nodes, "links" between them, and the 
percentage of loss on each link.
<p>

To use this applet, simply select a dataset.  Then, if the dataset
offers multiple power levels, choose one that corresponds to your 
intended use.  By default, all wireless "links" that can transmit 
some data between any nodes are displayed.  You can select a different
mode if desirable.  "Select by source" means that links between nodes
you select in the list below and any other nodes are shown.  "Select
by receiver" means that all links between the receivers you selected 
and any senders are shown.  You can also modify the selected nodes by 
clicking on the map on the appropriate node circles.  To add a node to a
selection, hold down the shift key and left-click on the node.  To remove
a node from a selection, hold down the shift key and click the node.  To
remove all nodes from a selection, click anywhere on the map outside of any
nodes.  You can edit the current selection using the map, the list, or a
combination.
<p>

Since some maps may get cluttered with any links, we provide some 
limiting options to reduce the number of links shown in a sensible manner.  
You can limit by "k best neighbors", which filters out all but the 
N best links leaving or entering the selected nodes; N is the number 
you enter in the box just below this limit option.  You can also 
limit by setting a threshold; only nodes with loss rates above this 
threshold are shown.  To remove the limit, choose the "None" limit.

Finally, an additional option allows you to never see links with 0% 
connectivity.
<p>


<?php
212 213

PAGEFOOTER();
214

215
?>