mosh has asked for the wisdom of the Perl Monks concerning the following question:

Hello friends,

I've searched for all over the Internet including CPAN, and didn't find out any Perl module related with OSPF protocol (Open Shortest Path First).
Something like Net::OSPF or NetPacket::OSPF or anything else.
Had someone encounter such a module ?

Mosh.

Replies are listed 'Best First'.
Re: OSPF Protocol
by g0n (Priest) on Mar 03, 2005 at 11:59 UTC
    I don't know of an OSPF module, and if there was one in circulation suitable for use I would expect it to be at CPAN.

    It would be an intriguing project to develop though. A good starting point would be Net::BGP, especially the use of an event loop and callbacks on receipt of relevant packets. That would cover the need for code to be constantly on the lookout for hellos and LSAs.

    You don't state what you are looking for an OSPF module to do: simply monitoring and parsing OSPF packets shouldn't be too horrible to implement. Writing a module to act as a DR/BDR could be rather tricker.

    VGhpcyBtZXNzYWdlIGludGVudGlvbmFsbHkgcG9pbnRsZXNz
      I need a module that knows how to build/parse OSPF packets, for a beginning.

      Does BGP and OSPF are similar protocols ?

        OSPF and BGP are very different. The reason I suggested Net::BGP as a starting point is that it implements event driven code based on receipt of routing packets.

        This is a bit off topic, so I won't go into too much detail, but OSPF is a multicast connectionless protocol - route updates are sent to a multicast address (224.0.0.5). BGP is connection oriented - routers are configured with relationships to each other, and unicast updates over TCP. When I was first learning both OSPF and BGP I wrote some brief notes on each, which you can see here. (I make no warranty as to their accuracy).

        For your purposes I would suggest starting by sniffing some OSPF LSAs from the wire, using tcpdump/ethereal/some other packet sniffer listening to 224.0.0.5, and (referring to the OSPF rfcs where necessary) writing some code to parse and interpret them.

        VGhpcyBtZXNzYWdlIGludGVudGlvbmFsbHkgcG9pbnRsZXNz

        No they aren't the same protocol I'm afraid. It looks like you are going to be starting with Net::RawIP and a copy of RFC 2328 :-s Good Luck!

        /J\

Re: OSPF Protocol
by rg0now (Chaplain) on Mar 03, 2005 at 15:25 UTC
    Very long time ago, we used to monitor some test OSPF deployments through ethereal. Somehow, we managed to get ethereal to sniff and parse OSPF packets into a text file (I can't recall now, how), which gave us a pretty nice text representation of the OSPF packets seen at the network interfaces. It was then just a matter of patience to grep the relevant parts out of the test file, of course by using Perl.

    This is a big and ugly hack, but it worked for us pretty nicely... Also, you can use tcpdump too, but it does not give you so verbose and nicely formatted output...

    rg0now

      you use 'tethereal' the text based version of ethereal. then add the -V flag and presto. one of my most favorite reverse engineering tools...