Thursday 20 February 2014

Hierarchical Topology


The GEXF file format contains a hierarchical network topology which is very distinct from the others.

In the GEXF file we have 3 main entities involved.

1. The Antenna : The Antenna is where wireless communication between nodes are established. Yet, it's not very distinctively clear on how to determine using queries if a node is an antenna but, the Antenna can be found as the source of a wired edge and also the source or destination of a wireless edge.

2. The Router : The router is a node that has many IPs ( to be more distinctive, the node name is not an IP adress), the node name of a router is the parent ID of the interfaces.

3. The Interfaces : The Interfaces are all nodes that have a parent ID (router).

The edge connections,

All Interfaces are connected to a particular antenna using a wired link while, for wireless communication, the Antenna IP is used to link up to other neighboring nodes.


A diagram of the entities involved.


Now with the PICTURE, in mind.  The GEXF file has interface, antennas and routers as nodes. And this is also how it is represented inside the MYSQL database. In other for me to have the hierarchical representation, an option could be to use the appropriate mysql queries that will retrieve these nodes from the database and properly present them in the right json structure.

The JSON structure for node representation in Libremap is :



To represent a node, I plan to do the following :

{
  "_id": "TheRouterID(PID)",
  "type": "router",
  "hostname": "hostname of router",
  "lat": -31.805412,
  "lon": -64.424677,
  "aliases": [
    {
      All the Interfaces IPs will be here
    {
      Also the Antenna IPs
    }
  ],
  "links": [
    {
      Wired links(Connect all local IPs to Antenna)
    },
    {
      Wireless links (Connect the Antenna to other nodes)
    }
  ],
  "site": "info",
  "community": "info",
  "attributes": {
    "firmware": {
                }
  }
}

These attributes will be retrieved from the database and used to built the json data structure in php that will yield such an output above.




GEXF to JSON(Libremap)

Since the data i will be needing to import into libremap is in GEXF format,  parsing is needed in other to produce the suitable json format for libremap. So first i am inserting this data into mysql which will help me build queries for the insertion into libremap. At the moment using mysql as an intermediary isn't the best possible plan but at the moment is it the most feasible to archive my needs.


This will be an optimal approach for future implementation.



Saturday 23 November 2013

Adding a router on Libremap.

To add a router with libremap, it is as simple as :

curl -X POST -d @router.json http://admin:admin@127.0.0.1:5984/mapit/_design/libremap-api/_rewrite/router

@router.json is the document containing the router details.  A sample can be found here,

https://github.com/libremap/libremap-api/blob/master/doc-api-router.md#json-example

_/router , is the api command to add a new router.

If this is successful, the router should be seen on the map. Unfortunately i was not able to see anything on the map. I kept trying for hours no avail. Then i communicated with the author Andre, who advised me to check some procedures and among those was to make sure i follow the browser url communication on developer tools. So this is what i found out :


I noticed that the browser request wasn't getting through.

Finally i actually had hope, because i saw a problem that could be fixed ! So i checked the console view and saw this on the image :


Upon "googling" this error, i found the solution by enabling COR, at couchdb's local.ini file et VOILA !



So that is the view of what a router looks like on the map. After so much relieve, i decided to add a few more which resulted in :



I tried to create links between them, which resulted to no changes on the map. I am probably missing something or the feature hasn't been done yet. Also the right side options functionality of the webui is still in development. 

Libremap Installation Ubuntu 13.04

Libremap comes with 2 main components for installation which are :


  1. Libremap-webui
  2. Libremap-api
The directives of installing libremap are pretty clear on those repositories.

So from my experience, these are all the steps, i took to make sure everything was running.

After installing couchdb and geocouch, I created a database from couchdb (also created an admin account) and named it "mapit" for example. When installing libremap-api i got to this section below :

Copy couch.json.example to couch.json and configure your CouchDB server there.

I did per the instruction and since i had to change the contents of the couch.json file, this is what i included for the "dev" section.



"dev": {

      "database": "http://localhost:5984/mapit",

      "user": "admin",
      "pass": "admin"
    }

The url is where your couchdb database is located and the passwords beneath. 


So after the setup of libremap-api, i moved to the libremap-webui phase where i followed the instructions as stated in the link provided. At step 3,

  1. Copy config.json.example to config.json and configure your LibreMap API URL there. If you don't have your own LibreMap API you can use an existing one, for example http://libremap.net/api.
Since i wanted to have my own libremap instance and use my own API url, what i did was to add my own api url inside the config.json file which is :

http://localhost:5984/mapit/_design/libremap-api/_rewrite/

Note : The url can be made shorter with vhost.

After that being done with other minor changes in the config.json file, i proceeded to also create the couch.json file which i added the database url as i did before with the libremap-api couch.json file. (I mention only the file changing steps, other steps such as "grunt push --couch dev" should not be skipped)

Et voila ! Thats all, i did and the next thing was to run using grunt. Which then gave me a url to access the webui (in my case 0.0.0.0:9000) 




Installation of Apache CouchDb 1.4 and GeoCouch 1.3 on Ubuntu 13.04

There are so many ways of installing Apache CouchDB in any linux distribution. The way in which you make this installation strongly impacts the possibility of you having a successful Geocouch installation. The methods that failed were :

1. Using the a package installer like apt-get.
This will give you a working couchdb installation but, in other to install geocouch you will need the sources and even if you plan to install using the package manager, then download the source and install geocouch, it won't work (atleast not for me).

2. The second approach was to use build-couchdb. This approach didn't get me to successfully install apache couchdb alongside geocouch.

3. Since geocouch 1.3x was specifically made for apache couchdb 1.3, this was my first try. To use apache couchdb 1.3 for geocouch 1.3x which it wasn't successful.

So to wrap things up, those where the methods, that kept me stuck for a long time. After further reading of blogs with the help of the "mighty google" ! I found 2 blogs that eased my pain. So to successfully install apache couchdb from source alongside geocouch, use :

1.  This link for apache couchdb installation"
https://www.digitalocean.com/community/articles/how-to-install-couchdb-from-source-on-an-ubuntu-13-04-x64-vps
Note that you will need apache couchdb 1.4, or anyother version that is compatible with the version of geocouch you plan to use. In my case, Apache Couchdb 1.4 & Geocouch 1.3.x.

2.  This link to install geocouch.
http://www.blmak.com/blog/?p=414



NB: INSTALL THE DEPENDENCIES PROVIDED ON ALL SITES LISTED.




Thursday 24 October 2013

Prerequisites

This project requires some prerequisites which i should fulfill in other to continue. The first of these are

Apache CouchDB and GeoCouch.

Apache CouchDB

CouchDB is an opensource document-oriented database that started in 2005 and was adopted by Apache in 2013. This is a NoSQL database meaning it is not based on traditional relational database models for simplicity, horizontal scaling and contol. JSON is used to store data and queries are performed using javascript.

GeoCouch

This is a spacial extension for Apache CouchDB.

================================================================================================================================================


The first step i took towards installing couchdb/geocouch was to use the source provided here :

https://github.com/iriscouch/build-couchdb

When i try to build by running  "sudo rake"
I get a missing package error : missing package : libxslt1-dev
But i can vouch that this package has been installed.
So using that package, i couldn't go any further.


I reverted changes and the next step was :

The latest version of apachecouchdb is 1.4, which can be automatically installed from aptitude.However geocouch is version 1.3 thus not guaranteed compability.After installing apachecouchdb, i had to install geocouch using the source of apachecouchdb as the manual(https://github.com/couchbase/geocouch/tree/couchdb1.3.x) says but i had this error while "making" geocouch.

Uncaught error in rebar_core: {'EXIT',{{badmatch,{error,badfile}},
                                       [{rebar_core,select_modules,3},
                                        {rebar_core,acc_modules,4},
                                        {rebar_core,process_dir,4},
                                        {rebar_core,process_commands,2},
                                        {rebar,main,1},
                                        {escript,run,2},
                                        {escript,start,1},
                                        {init,start_it,1}]}}
make: *** [compile] Error 1
.....................................................................

So i revert to original and tried to install apachecouchdb1.3 with geocouch1.3. I still encountered the recore_core error, but i somehow got passed that by reinstalling rebar. But after trying to "make" i had this new error which i was not able to comprehend at first.

can't find include file "couch_db.hrl"

So upon searching, i found a fix for it but however this fix (
https://aur.archlinux.org/packages/geocouch/) could not work for the apachecouchdb1.3 version. So i went back to version 1.4, tried and it was succesful.


Further more, after trying to configure geocouch with couchdb as in

https://github.com/couchbase/geocouch

Everything went ok, until the moment when i had to test the geocouch.

This statement : curl -X GET 'http://localhost:5984/places/_design/main/_spatial/points?bbox=0,0,180,90'

failed !

With this error : {error":"not_found". "reason":"missing handler: _spatial"}

So upon further digging, i found a post (http://www.blmak.com/blog/?p=414)  which said that the README instructions were misleading, so after following the method which was described there, i succeeded in running the command without any errors.

So for an update : Couchdb and Geocouch are running ok !

The next step is to install erica and Libremap.