# HG changeset patch # User ivo # Date 1276121751 -7200 # Node ID 4dbe5bf653bbf7743970f64dc93d9629d3aafea0 # Parent 26b849b22eaa3f8d39168c6d4b119ad2edc3e762 Added bgp graph scripts diff -r 26b849b22eaa -r 4dbe5bf653bb doc/ucis.ano/bgp_graph/bgp_path_list_bird.php --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/doc/ucis.ano/bgp_graph/bgp_path_list_bird.php Thu Jun 10 00:15:51 2010 +0200 @@ -0,0 +1,20 @@ +#!/usr/bin/php + array('pipe','r'), 1 => array('pipe','w'), 2 => STDERR), $fds); +fwrite($fds[0], "show route all\n"); +fclose($fds[0]); +$paths = array(); + +while (!feof($fds[1])) { + $line = stream_get_line($fds[1], 1024, "\n"); + if ($line === NULL || $line === FALSE) break; + if (!strlen($line) || $line[0] != "\t") continue; + if (substr($line, 0, 14) != "\tBGP.as_path: ") continue; + $path = substr($line, 14); + if (in_array($path, $paths)) continue; + $paths[] = $path; + print($mynode.' '.$path."\n"); +} diff -r 26b849b22eaa -r 4dbe5bf653bb doc/ucis.ano/bgp_graph/bgp_path_list_bird.sh --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/doc/ucis.ano/bgp_graph/bgp_path_list_bird.sh Thu Jun 10 00:15:51 2010 +0200 @@ -0,0 +1,3 @@ +#!/bin/sh +LOCALNODE=0 +echo "show route all" | birdc | grep -F "BGP.as_path:" | sed "s/^\tBGP.as_path: \([0-9 ]*\)$/$LOCALNODE \1/" | sort -u diff -r 26b849b22eaa -r 4dbe5bf653bb doc/ucis.ano/bgp_graph/bgp_path_list_quagga.php --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/doc/ucis.ano/bgp_graph/bgp_path_list_quagga.php Thu Jun 10 00:15:51 2010 +0200 @@ -0,0 +1,16 @@ +#!/usr/bin/php +') === FALSE) break; + seekto($file, ''); + $endofsection = FALSE; + $path = $mynode; + while (!feof($file)) { + if (seekto($file, '<') === FALSE) break; + switch (fread($file, 4)) { + case 'asn>': break; + case '/seg': $endofsection = TRUE; break; + default: die('unknown tag at '.(ftell($file)-4)); + } + if ($endofsection) break; + $asn = seekto($file, ''); + $path .= ' '.$asn; + } + if (in_array($path, $paths)) continue; + $paths[] = $path; + print($path."\n"); +} + +function seekto($f, $str) { + $part = ''; + $i = 0; + $len = strlen($str); + while ($i < $len && !feof($f)) { + $c = fgetc($f); + if ($c === FALSE) return FALSE; + if ($c == $str[$i]) { + $i++; + } else { + if ($i) { + $i = 0; + $part = ''; + } + $part .= $c; + } + } + return $part; +} diff -r 26b849b22eaa -r 4dbe5bf653bb doc/ucis.ano/bgp_graph/path_list_to_dot.php --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/doc/ucis.ano/bgp_graph/path_list_to_dot.php Thu Jun 10 00:15:51 2010 +0200 @@ -0,0 +1,31 @@ +#!/usr/bin/php + $links) { + foreach ($links as $link => $dummy) { + if (isset($nodes[$node][$link]) && isset($nodes[$link][$node])) unset($nodes[$link][$node]); + } +} + +print("graph BGP_nodes {\n"); +foreach ($nodes as $node => $links) { + foreach ($links as $link => $dummy) { + print("\t".$node.' -- '.$link.";\n"); + } +} +print('}'); diff -r 26b849b22eaa -r 4dbe5bf653bb doc/ucis.ano/bgp_graph/path_list_to_xml.php --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/doc/ucis.ano/bgp_graph/path_list_to_xml.php Thu Jun 10 00:15:51 2010 +0200 @@ -0,0 +1,17 @@ +#!/usr/bin/php +'."\n"); + $prevnode = $node; + } +} diff -r 26b849b22eaa -r 4dbe5bf653bb doc/ucis.ano/bgp_graph/process_xml.sh --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/doc/ucis.ano/bgp_graph/process_xml.sh Thu Jun 10 00:15:51 2010 +0200 @@ -0,0 +1,6 @@ +#!/bin/sh +for file in ./xml/* +do + echo "Processing $file" + ./bgp_path_list_xml.php < "$file" > data/`basename "$file"` +done