This script passively listens to OSPFv2 multicast traffic, and generates a graphviz diagram representing the network. Because it only listens and does not participate in the OSPF protocol, it takes about half an hour to learn about the network.
python-netaddr
The script has been tested under Python2.6
ospf-to-graphviz.py mynetwork.dot
After a while, convert the .dot file for viewing with something like this:
dot -Tpng mynetwork.dot >mynetwork.png
The output file will be rewritten when an OSPF update is received, so you can keep converting the file every time it changes to see the diagram converge on your network topology. This should be complete after LSRefreshTime (30mins).
Only OSPFv2 is supported. Only LS Update messages are analysed. Only Router LSAs, Network LSAs and External LSAs are handled at present. For Router LSAs, only transit networks, stub networks and point to point networks are handled.
This code is based on a Python recipe by Ferdy Riphagen: http://code.activestate.com/recipes/576664-ospf-multicast-sniffer/