<html>
  <head>
    <meta content="text/html; charset=windows-1252"
      http-equiv="Content-Type">
  </head>
  <body text="#000000" bgcolor="#FFFFFF">
    <div class="moz-cite-prefix">Sorry, forgot to link the repo:<br>
      <a class="moz-txt-link-freetext" href="https://github.com/ninuxorg/netdiff">https://github.com/ninuxorg/netdiff</a><br>
      <br>
      <br>
      On 05/02/2015 09:40 PM, Nemesis wrote:<br>
    </div>
    <blockquote cite="mid:5545281E.9090405@ninux.org" type="cite">
      <meta http-equiv="content-type" content="text/html;
        charset=windows-1252">
      <font face="Helvetica, Arial, sans-serif"><font face="Helvetica,
          Arial, sans-serif">Hey,<br>
          <br>
          <font face="Helvetica, Arial, sans-serif">we just released
            this very simple experimental python library</font> that we
          call<font face="Helvetica, Arial, sans-serif">ed "netdiff".</font><br>
          <font face="Helvetica, Arial, sans-serif"><font
              face="Helvetica, Arial, sans-serif"><font face="Helvetica,
                Arial, sans-serif"><br>
                <font face="Helvetica, Arial, sans-serif">What can you
                  do with it?<br>
                  <br>
                </font><font face="Helvetica, Arial, sans-serif">Mainly
                  figure out changes to the netwo<font face="Helvetica,
                    Arial, sans-serif">r<font face="Helvetica, Arial,
                      sans-serif">k topology. <br>
                      <font face="Helvetica, Arial, sans-serif"><font
                          face="Helvetica, Arial, sans-serif">Currently
                          only olsr 0.6.x and <font face="Helvetica,
                            Arial, sans-serif">batman-advanced are <font
                              face="Helvetica, Arial, sans-serif">implemented,

                              but it<font face="Helvetica, Arial,
                                sans-serif"> should be<font
                                  face="Helvetica, Arial, sans-serif"> </font></font>quite

                              easy to implement other routing protocols</font>.</font></font></font><br>
                    </font></font></font><br>
              </font></font></font></font></font>
      <pre>from netdiff import OlsrParser</pre>
      <pre>from netdiff import diff</pre>
      <pre>from time import sleep</pre>
      <pre>current = OlsrParser('<a moz-do-not-send="true" class="moz-txt-link-freetext" href="http://127.0.0.1:2006">http://127.0.0.1:2006</a>')

# wait 2 minutes
time.sleep(120)

latest = OlsrParser('<a moz-do-not-send="true" class="moz-txt-link-freetext" href="http://127.0.0.1:2006">http://127.0.0.1:2006</a>')
</pre>
      <pre>diff(current, latest)
</pre>
      will return something like:<br>
      <br>
      <pre>{</pre>
      <pre>    "removed": [</pre>
      <pre>        ["10.150.0.7", "10.150.0.9"]</pre>
      <pre>    ], </pre>
      <pre>    "added": [</pre>
      <pre>        ["10.150.0.5", "10.150.0.4"]</pre>
      <pre>    ]</pre>
      <pre>}</pre>
      <br>
      Another cool thing is to output a NetworkGraph json object, eg:<br>
      <br>
      <pre>from netdiff import BatmanParser</pre>
      <pre>from netdiff import diff</pre>
      <pre>batman = BatmanParser('./test/alfred-output.json')</pre>
      <pre>batman.json()</pre>
      <br>
      will output:<br>
      <br>
      <pre>{</pre>
      <pre>    "type": "NetworkGraph", </pre>
      <pre>    "protocol": "batman-adv", </pre>
      <pre>    "version": "2014.3.0", </pre>
      <pre>    "revision": null, </pre>
      <pre>    "metric": "TQ", </pre>
      <pre>    "nodes": [</pre>
      <pre>        {</pre>
      <pre>            "id": "a0:f3:c1:ac:6c:44"</pre>
      <pre>        }, </pre>
      <pre>        {</pre>
      <pre>            "id": "a0:f3:c1:96:94:06"</pre>
      <pre>        }, </pre>
      <pre>        {</pre>
      <pre>            "id": "10:fe:ed:37:3a:39"</pre>
      <pre>        }, </pre>
      <pre>        {</pre>
      <pre>            "id": "00:05:1c:06:35:8e"</pre>
      <pre>        }, </pre>
      <pre>        {</pre>
      <pre>            "id": "90:f6:52:f2:8c:2c"</pre>
      <pre>        }</pre>
      <pre>    ], </pre>
      <pre>    "links": [</pre>
      <pre>        {</pre>
      <pre>            "source": "a0:f3:c1:ac:6c:44", </pre>
      <pre>            "target": "10:fe:ed:37:3a:39", </pre>
      <pre>            "weight": "1.000"</pre>
      <pre>        }, </pre>
      <pre>        {</pre>
      <pre>            "source": "a0:f3:c1:96:94:06", </pre>
      <pre>            "target": "90:f6:52:f2:8c:2c", </pre>
      <pre>            "weight": "1.000"</pre>
      <pre>        }, </pre>
      <pre>        {</pre>
      <pre>            "source": "10:fe:ed:37:3a:39", </pre>
      <pre>            "target": "90:f6:52:f2:8c:2c", </pre>
      <pre>            "weight": "1.000"</pre>
      <pre>        }, </pre>
      <pre>        {</pre>
      <pre>            "source": "00:05:1c:06:35:8e", </pre>
      <pre>            "target": "90:f6:52:f2:8c:2c", </pre>
      <pre>            "weight": "1.000"</pre>
      <pre>        }</pre>
      <pre>    ]</pre>
      <pre>}</pre>
      <br>
      Why we separated this logic into a library?<br>
      <ul>
        <li>not tied to any particular framework or node-database, it's
          pure python</li>
        <li>easy to add more routing protocols, newcomers can work on it
          more easily compared to having to delve into a node-database</li>
        <li>it's possible to add some nice features that we'll implement
          in the near future thanks to the networkx library:</li>
        <ul>
          <li>calculating betweenness centrality</li>
          <li>merge topologies of different nodes of an island into one
            (union), so that if the network gets split up, it is
            possible to draw a complete topology with just the missing
            link, and not just half topology</li>
        </ul>
      </ul>
      <p>So.. there's still some hard work to do to integrate this into
        our node-db but I hope this experiment succeeds!<br>
      </p>
      <p>We are open for suggestions and improvements.<br>
      </p>
      <p>Federico<br>
      </p>
    </blockquote>
    <br>
  </body>
</html>