Implementation - chuckablack/quokka GitHub Wiki
Preamble
Before we begin looking at the quokka implementation, here are a couple overriding principles I've tried to follow in developing quokka:
- Simplicity: Wherever possible, I have attempted to implement quokka in the simplest manner possible. “Everything should be made as simple as possible, but no simpler,” is a quote attributed to Einstein, and with which I totally concur. So if you see something implemented in a particular way, feel free to critique, but also remember that perhaps I was just looking for the simplest solution.
- Teachability: In the same manner, recall that quokka has been built for the purpose of teaching people how to write code. If I've avoided using a technique or implementing a feature, perhaps it is because it didn't lend to the goal of this software being used to teach people how to become programmers.
Something else of which you should be aware, in case you are in danger of being overwhelmed by the thought of writing all this code: the basic quokka functionality was implemented by me in only three weeks. Admittedly I've been doing this all my life - however, the point to take away is that a huge amount of the code here comes from open source. So, do not worry that quokka is too much for you. Besides, anything you learn from this implementation, will help to bolster your knowledge and understanding of programming._
So without further ado, let's look at the implementation.
Quokka Implementation
Quokka is implemented with two main components. These are:
-
quokka: Also sometimes referred to as the quokka server, this is the main quokka application, which monitors devices, hosts, and services, and initiates executions of functions such as packet capture, port scan, and traceroute. Quokka is implemented in Python, using the Flask web application framework.
-
quokka-ui: This is the UI component of quokka, which utilizes the React Javascript framework, which serves up the quokka UI pages.
In addition to these two components, quokka may invoke various worker programs, written in Python, which perform various diagnostic functions.
Lastly, quokka stores data about devices, hosts, and services, and their status, in a database.
The following image shows the general design of quokka:
As mentioned earlier, quokka benefits from open source software for much of its functionality. Below is a partial list of the open source code used by quokka:
- Flask: Flask is the main web application framework, in which quokka runs. That means that Flask provides the web server, and provides a framework for the implementation of REST APIs, that are used by the quokka UI, as well as by workers, and even by devices.
- SQL Alchemy: SQL Alchemy is the database framework used by quokka, which allows quokka to attach to an SQL database (we are using PostgreSQL). Information about devices, hosts, and services, status information, summaries, events, packet captures, etc. are all stored in the DB.
- NAPALM: For communication with certain devices, quokka uses NAPALM, which provides a higher-level abstraction of basic networking functions such as getting configs, ARP tables, traffic data, etc., using a single interface. NAPALM translates requests into the appropriate SSH or NETCONF requests and responses.
- ncclient: Sometimes NAPALM doesn't support NETCONF where it might be desired, so quokka has the ability to do certain things via the ncclient library.
- scapy: Fortunately, "scapy" is easier to use than pronounce (I'm still not sure which is correct). Scapy is a useful set of Python functions for doing things such as packet capture and traceroute (which quokka uses), and even goes so far as to allow injecting packets into the network.
- nmap: Nmap is a tool, like scapy, that allows quokka to perform functions very similar to what scapy does. For quokka, we are using nmap for port scanning.
The following image shows how some of these open source libraries are used in quokka:
There are a number of topics to be explored regarding quokka's implementation, such as: