Mercurial > hg > anonet-resdb
annotate doc/ucis.ano/bgp_graph/path_list_to_dot.php @ 61:d8b6fb8cd729 draft
added hyperlinks to graph (to UFO's pages)
author | Nick <nick@somerandomnick.ano> |
---|---|
date | Thu, 17 Jun 2010 16:04:03 +0000 |
parents | 8643d1b779de |
children | ec2590f00495 |
rev | line source |
---|---|
28 | 1 #!/usr/bin/php |
2 <?php | |
3 $nodes = array(); | |
4 | |
5 $file = STDIN; | |
6 | |
7 while (!feof($file)) { | |
8 $line = stream_get_line($file, 1024, "\n"); | |
9 if ($line === NULL) break; | |
10 if (!strlen($line)) continue; | |
11 $pathnodes = explode(' ', $line); | |
12 $prevnode = NULL; | |
13 foreach ($pathnodes as $node) { | |
14 if ($prevnode && $node) $nodes[$prevnode][$node] = 1; | |
15 $prevnode = $node; | |
16 } | |
17 } | |
18 | |
19 foreach ($nodes as $node => $links) { | |
20 foreach ($links as $link => $dummy) { | |
34 | 21 if ($node != $link && isset($nodes[$node][$link]) && isset($nodes[$link][$node])) unset($nodes[$link][$node]); |
28 | 22 } |
23 } | |
24 | |
50
0e7ba1239f5a
now pulls AS info from dn42 registry
Nick <nick@somerandomnick.ano>
parents:
47
diff
changeset
|
25 function static_nodename ($node) { switch ($node) { |
51
198bd6e327eb
added some more customization capability for ASN names
Nick <nick@somerandomnick.ano>
parents:
50
diff
changeset
|
26 // case '64731': return 'SRN (AS64731)'; |
198bd6e327eb
added some more customization capability for ASN names
Nick <nick@somerandomnick.ano>
parents:
50
diff
changeset
|
27 // case '64766': return 'UFO (AS64766)'; |
198bd6e327eb
added some more customization capability for ASN names
Nick <nick@somerandomnick.ano>
parents:
50
diff
changeset
|
28 }; return NULL; }; |
198bd6e327eb
added some more customization capability for ASN names
Nick <nick@somerandomnick.ano>
parents:
50
diff
changeset
|
29 |
198bd6e327eb
added some more customization capability for ASN names
Nick <nick@somerandomnick.ano>
parents:
50
diff
changeset
|
30 function nodenickname ($node) { switch ($node) { |
198bd6e327eb
added some more customization capability for ASN names
Nick <nick@somerandomnick.ano>
parents:
50
diff
changeset
|
31 case '64731': return 'SRN'; |
198bd6e327eb
added some more customization capability for ASN names
Nick <nick@somerandomnick.ano>
parents:
50
diff
changeset
|
32 case '64766': return 'UFO'; |
52 | 33 case '64768': return 'yang'; |
34 case '64738': return 'welterde'; | |
35 case '64827': return 'deelkar'; | |
50
0e7ba1239f5a
now pulls AS info from dn42 registry
Nick <nick@somerandomnick.ano>
parents:
47
diff
changeset
|
36 }; return NULL; }; |
0e7ba1239f5a
now pulls AS info from dn42 registry
Nick <nick@somerandomnick.ano>
parents:
47
diff
changeset
|
37 |
0e7ba1239f5a
now pulls AS info from dn42 registry
Nick <nick@somerandomnick.ano>
parents:
47
diff
changeset
|
38 function nodename ($node) { |
0e7ba1239f5a
now pulls AS info from dn42 registry
Nick <nick@somerandomnick.ano>
parents:
47
diff
changeset
|
39 $node=preg_replace('/[^0-9]+/','',$node); |
0e7ba1239f5a
now pulls AS info from dn42 registry
Nick <nick@somerandomnick.ano>
parents:
47
diff
changeset
|
40 if (($name=static_nodename($node))!==NULL) return $name; |
51
198bd6e327eb
added some more customization capability for ASN names
Nick <nick@somerandomnick.ano>
parents:
50
diff
changeset
|
41 $nameparts=array(); |
198bd6e327eb
added some more customization capability for ASN names
Nick <nick@somerandomnick.ano>
parents:
50
diff
changeset
|
42 if (($nick=nodenickname($node))!==NULL) $nameparts[]=$nick; |
50
0e7ba1239f5a
now pulls AS info from dn42 registry
Nick <nick@somerandomnick.ano>
parents:
47
diff
changeset
|
43 $name=rtrim(`echo $node | ./asn2adminc | ./hdl2person`); |
51
198bd6e327eb
added some more customization capability for ASN names
Nick <nick@somerandomnick.ano>
parents:
50
diff
changeset
|
44 if (empty($name)) $name='AS'.$node; else $name="AS$node ($name)"; |
198bd6e327eb
added some more customization capability for ASN names
Nick <nick@somerandomnick.ano>
parents:
50
diff
changeset
|
45 $nameparts[]=$name; |
198bd6e327eb
added some more customization capability for ASN names
Nick <nick@somerandomnick.ano>
parents:
50
diff
changeset
|
46 return join(' - ',$nameparts); }; |
35 | 47 |
48 $nodelist=array(); | |
49 foreach ($nodes as $node => $links) { | |
50 if (!array_key_exists($node,$nodelist)) $nodelist[$node]=nodename($node); | |
51 foreach ($links as $link => $dummy) | |
47
f2fb1d2dcf8c
fixed another bug (misnamed ASes)
Nick <nick@somerandomnick.ano>
parents:
46
diff
changeset
|
52 if (!array_key_exists($link,$nodelist)) $nodelist[$link]=nodename($link); |
35 | 53 }; |
54 | |
36 | 55 print("graph BGP_nodes {\n"); |
35 | 56 foreach ($nodelist as $node => $name) |
61
d8b6fb8cd729
added hyperlinks to graph (to UFO's pages)
Nick <nick@somerandomnick.ano>
parents:
52
diff
changeset
|
57 print "\t".$node.' [label="'.$name.'",URL="http://ix.ucis.dn42/dn42/db/asdetails.php?h='.$node.'"];'."\n"; |
35 | 58 |
28 | 59 foreach ($nodes as $node => $links) { |
60 foreach ($links as $link => $dummy) { | |
61 print("\t".$node.' -- '.$link.";\n"); | |
62 } | |
63 } | |
64 print('}'); |