Home Installation Documentation Screenshots Analyser
Best practice Configuration Visualization Router Update FAQ Topology


Topology files

The discovered topology is stored in XML files. Previous versions of OSPFviz (0.5 and below) used Perl's Data::Dumper format which is not covered here.
The file is structured hierarchical: first level contains all devices addressed by its OSPF router ID. Second level is the neighbor router addressed by the neighbors interface IP. Third level contains attribute/value pairs containing the OSPF settings of the device (metric, area ID, etc). --> --> ifDescr = FastEthernet2/1
localIP =
netmask =
AreaId = 15 --> ifDescr = ATM2/8
localIP =
netmask =
AreaId = 92 --> ifDescr = Loopback0
localIP =
netmask =
AreaId = 0
sysName = tbr1-cl1.sffca.ip.att.net/td>

External access

With the following subroutines you can access to topology files from another software by using predefined functions. All provided subroutines require the name of the topology file and at least one argument for the query. To use the latest topology file in a given directory use the asterisk (*) as file name. The main result is a reference to a hash containing all resulting attributes.
To use the given functions you must include the OSPFviz module in your Perl script:
use ospfviz;
Refer to the sample code in the example directory of the OSPFviz distribution.

GetAttrByIfDescr ()

sub GetAttrByIfDescr (topology file, OspfRouterId, interface)
Subroutine that searches the topology file for a given interface name/description (e.g. FastEthernet3/1) on a specific device, e.g.
%attr = %{ GetAttrByIfDescr ('my-topo-file.xml', '', 'FastEthernet3/1') };
printf ("%s\n", $attr{netmask});
This would print the netmask

GetAttrByIpAddr ()

sub GetAttrByIpAddr (topology file, ip address)
This subroutine searches the topology file for a given IP address. Return value is a hash reference and the OspfRouterId that owns the IP, e.g.
($attr, $id) = GetAttrByIpAddr ('my-topo-file.xml', '');
%attr = %$attr;
printf ("%s on %s\n", $attr{ifDescr}, $id);
This would print the interface name and the OSPF router ID: GigabitEthernet0/3 on

GetAttrByValue ()

sub GetAttrByValue (topology file, OspfRouterId, leaf name, search pattern)
With this subroutine you can build universal queries, searching the topology for any defined attribute. It's a little complicated so try to use any of the other subs unless your query is not covered by them.
leaf name is the name of the attribute (e.g. ospfRouterId) and search pattern is the value of the leaf that you want to find. In case you search for something very common (interface name Ethernet0) please keep in mind that only the first occurence is returned.
GetAttrByValue ('myfile.xml', '', 'ospfRouterId', '');
printf ("%s\n", $attr{sysName});
This would print the system name: tbr1-cl1.sffca.ip.att.net.