Skip to content

Commit 9667862

Browse files
authored
Webapp development notes (#150)
- Adding notes on how to test webapp for development. - Adding notes documenting webapp structure for maintenance. - Adding notes on potential future development.
1 parent bacb201 commit 9667862

File tree

2 files changed

+127
-1
lines changed

2 files changed

+127
-1
lines changed

webapp/README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ Webapp AS Visualization
33

44
More installation and usage information is available on the [SCION Tutorials web page for webapp](https://netsec-ethz.github.io/scion-tutorials/as_visualization/webapp/).
55

6-
## Webapp
6+
# Webapp
77
Webapp is a Go application that will serve up a static web portal to make it easy to visualize and experiment with SCIONLab test apps on a virtual machine.
88

99

@@ -43,6 +43,8 @@ systemctl cat scion-webapp
4343

4444

4545
## Development Setup/Run
46+
For maintenance of `webapp` details of its structure and operation can be found at [development.md](./development.md).
47+
4648
For running `webapp` in a development environment for the SCION Infrastructure, follow the SCIONLab development install and run process at [https://github.com/netsec-ethz/scion](https://github.com/netsec-ethz/netsec-scion).
4749

4850
Then, follow these steps to install SCIONLab Apps to run `webapp` in development.

webapp/development.md

Lines changed: 124 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,124 @@
1+
# Webapp Construction and Design
2+
Webapp is a go application designed to operate a web server for purposes of visualizing and testing the SCION infrastructure. Webapp occupies a strange place in the SCIONLab ecosystem, in that, it draws from a wide variety of sources to provide testing and visualization features so a list of [dependencies](dependencies.md) has been developed for maintenance purposes. There isn't one central source or API for the information webapp uses to interrogate SCIONLab, thus webapp may do the following:
3+
4+
* Read from environment variables.
5+
* Scan SCION's logs.
6+
* Scan SCION's directory structure.
7+
* Call third-party service APIs.
8+
* Request static configuration from a SCIONLab-maintained location.
9+
* Execute bash scripts.
10+
* Execute SCION or SCIONLab tools and apps.
11+
* Read from SCION's databases.
12+
* Make connections to SCION services, like the SCION Daemon.
13+
14+
## Users
15+
* **SCIONLab AS Operators**: Visualize and test the SCIONLab production network.
16+
* **Developers**: Visualize and test any topology you create on `localhost`.
17+
18+
## Structure
19+
* `lib/` - go modules governing sciond, images, health checks, command-line app parsing
20+
* `models/` - go webapp database schema and CRUD operations
21+
* `tests/` - scripts and offline versions of data retrieval for testing
22+
* `util/` - go logging and other universally useful code
23+
* `web/` - root of the static website to serve
24+
* `config/` - default addresses of command-line apps, also locally saved user settings
25+
* `data/` - location of image and long term app responses *(generated)*
26+
* `logs/` - location of webapp log *(generated)*
27+
* `static/` - location of static code to serve, custom and third-party
28+
* `css/` - custom style is mostly `style.css`, `style-viz.css`, `topology.css`
29+
* `js/` - JavaScript
30+
* `webapp.js` - main JavaScript for the Apps menu that governs real-time graphs and paths configuration
31+
* `tab-paths.js` - controls topology/map switch, parsing of retrieved paths/locations/labels
32+
* `tab-topocola.js` - operates the path topology graph, nodes, arrows
33+
* `tab-g-maps.js` - operates the path map graph along with `web/static/html/map.html`
34+
* `asviz.js` - operates AS topology graph, path selection
35+
* `topology.js` - utility functions to sort and order paths data
36+
* `location.js` - utility functions manage maps
37+
* `html/` - non-template HTML, mostly `map.html` that is injected into a frame
38+
* `webapp.db` - SQL Lite database *(generated)* of command-line app responses, short term 24-hour lifetime.
39+
* `template/` - most of the site HTML, broken into pages per navbar menu
40+
* `tests/health/` - bash scripts and json config to run health checks
41+
* `webapp.go` - go main module for webapp, governing web-server, AJAX-style requests, and executing command-line apps.
42+
43+
## Website Features
44+
1. **Launch Config**: Several command line parameters allow you to define multiple locations where your SCION deployment is running and where this website should be served from and to.
45+
1. **Health Checks**: The default first page in the Health Checks that will run several bash scripts checking for common SCION misconfiguration and operational requirements.
46+
1. **AS Address (IA)**: On a local development topology you can switch perspective to any AS in the topology from the Navbar. Unless your production deployment co-locates multiple ASes, in production usually only one AS will be available.
47+
1. **Apps Tests**: On the Apps menu, run test for bandwidth, latency, routing, and IoT sensors at ETH (camera, temperature, humidity, ambient noise, etc.). Many of these tests can be run continuously and graphs are provided to show performance over time. Expanding the available paths tree in many cases will select the path to run a test app on.
48+
1. **Paths Visualization**: A graph is provided by default to visualize available paths to the user's AS, and to allow visual examination of individual path routes through the SCION instrstrcutre.
49+
50+
## Future Features
51+
* **Latency Tests**: *(in development)* SCION ping and traceroute results would be listed next to available paths or overlaid on path graphs allowing easy examination of performance.
52+
* **Name Resolution**: Integration with the SCION name resolution service (RAINS), would optionally show human-readable hostnames rather than IA numbers.
53+
* **Geolocation**: Dynamic locations provided by ASes issuing beacons with geolocation would be more accurate and complete than the current static geolocation data on the global paths map.
54+
* **Web sockets**: Data between the go web-server and the browser is requested by AJAX and polling from the browser. Implementing websockets would avoid timing issues polling for updated graph data from the web-server and reduce browser load.
55+
56+
## Open Source Code Used
57+
* [Highcharts](https://www.highcharts.com/): Apps menu linear graph rendering.
58+
* [D3](https://d3js.org/) and [Cola](https://ialab.it.monash.edu/webcola/): Apps menu path topology graph and Monitor menu AS topology graph.
59+
* [Bootstrap](https://getbootstrap.com/): Some tabs styling and icons.
60+
* [Google Maps](https://developers.google.com/maps/documentation) API: Map tab of AS paths.
61+
* [Google Geolocation API](https://developers.google.com/maps/documentation/geolocation/): Locating the user's address on the map.
62+
* [Pretty Checkboxes](https://lokesh-coder.github.io/pretty-checkbox/): GUI slider switches.
63+
* [JQuery](https://jquery.com/): Code style JavaScript querying of DOM elements.
64+
* [JQuery Knob](http://anthonyterrien.com/demo/knob/): Stylized dials for the bandwidth controls.
65+
* [TopoJSON](https://github.com/topojson/topojson): Geospatial utilities *(possibly deprecated)*
66+
67+
# SCIONLab VM Test Development
68+
69+
Add alternate test forwarding port line in `Vagrantfile`:
70+
```
71+
config.vm.network "forwarded_port", guest: 8080, host: 8080, protocol: "tcp"
72+
```
73+
74+
Update Go Paths:
75+
```shell
76+
echo 'export GOPATH="$HOME/go"' >> ~/.profile
77+
echo 'export PATH="$HOME/.local/bin:$GOPATH/bin:/usr/local/go/bin:$PATH"' >> ~/.profile
78+
source ~/.profile
79+
mkdir -p "$GOPATH"
80+
```
81+
82+
Install Go 1.13:
83+
```shell
84+
cd ~
85+
curl -O https://dl.google.com/go/go1.13.10.linux-amd64.tar.gz
86+
sudo tar -C /usr/local -xzf go1.13.10.linux-amd64.tar.gz
87+
```
88+
89+
Build and install `scion-apps`:
90+
```shell
91+
sudo apt install make gcc libpam0g-dev
92+
cd ~
93+
git clone -b scionlab https://github.com/netsec-ethz/scion-apps
94+
cd scion-apps
95+
make install
96+
```
97+
98+
Download scionlab's fork of scion and build and install `sig`:
99+
```shell
100+
cd ~
101+
git clone -b scionlab https://github.com/netsec-ethz/scion
102+
go build -o $GOPATH/bin/sig ~/scion/go/sig/main.go
103+
```
104+
105+
Install Go Watcher:
106+
```shell
107+
go get -u github.com/mitranim/gow
108+
```
109+
110+
Development Run:
111+
```shell
112+
cd ~/scion-apps/webapp
113+
gow run . \
114+
-a 0.0.0.0 \
115+
-p 8080 \
116+
-r ./web/data \
117+
-srvroot ./web \
118+
-sabin /usr/bin/scion \
119+
-sroot /etc/scion \
120+
-sbin /usr/bin \
121+
-sgen /etc/scion/gen \
122+
-sgenc /var/lib/scion \
123+
-slogs /var/log/scion
124+
```

0 commit comments

Comments
 (0)