From: Richard Whitehouse Date: Fri, 20 May 2011 14:20:36 +0000 (+0100) Subject: Produce graph for dissertation X-Git-Url: https://git.richardwhiuk.com/?a=commitdiff_plain;h=9c1ddda1db2d58f2a1959b1bc1bca7005f5826ac;p=ii-simulations.git Produce graph for dissertation --- diff --git a/graph b/graph new file mode 100755 index 0000000..dffb3fb --- /dev/null +++ b/graph @@ -0,0 +1,131 @@ +#!/usr/bin/php + $graph['ethernet'][$breadth]){ + $graph['ethernet'][$breadth] = $val; + } + $mode = 3; + } else { + $mode = 1; + } + } else { + $mode = 1; + } + } + + $data = file($moose); + + $mode = 0; // 0 <= STATE; + + foreach($data as $data){ + if($mode == 0){ + if(trim($data) == "State Table"){ + $mode = 1; + } + } elseif($mode == 1) { + $addr = trim($data); + $mode = 2; + } elseif($mode == 2){ + $w = explode("\t", trim($data)); + if(trim($w[0]) == 'Hosts' && isset($w[1])){ + if(!isset($graph['moose']['hosts'][$breadth])){ + $graph['moose']['hosts'][$breadth] = 0; + } + $val = (int) trim($w[1]); + if($val > $graph['moose']['hosts'][$breadth]){ + $graph['moose']['hosts'][$breadth] = $val; + } + $mode = 3; + } else { + $mode = 1; + } + } elseif($mode == 3){ + $w = explode("\t", trim($data)); + if(trim($w[0]) == 'Switches' && isset($w[1])){ + if(!isset($graph['moose']['switches'][$breadth])){ + $graph['moose']['switches'][$breadth] = 0; + } + $val = (int) trim($w[1]); + if($val > $graph['moose']['switches'][$breadth]){ + $graph['moose']['switches'][$breadth] = $val; + } + $mode = 4; + } else { + $mode = 1; + } + } elseif($mode == 4){ + $w = explode("\t", trim($data)); + if(trim($w[0]) == 'Total' && isset($w[1])){ + if(!isset($graph['moose']['total'][$breadth])){ + $graph['moose']['total'][$breadth] = 0; + } + $val = (int) trim($w[1]); + if($val > $graph['moose']['total'][$breadth]){ + $graph['moose']['total'][$breadth] = $val; + } + $mode = 5; + } else { + $mode = 1; + } + } else { + $mode = 1; + } + } + + } } } } } +} + +foreach($graph['ethernet'] as $k => $v){ + $h = $k * $k * $hps; + echo "$h $v {$graph['moose']['total'][$k]} {$graph['moose']['hosts'][$k]} {$graph['moose']['switches'][$k]}\r\n"; +} +