# 5G-IANA: UULM Network Monitoring

This repository contains the CI/CD and Dockerfiles necessary to build
the UULM Network Monitoring Tool.

This tool is used to deploy a RTMP stream behind a reverse proxy and a network
monitoring client which has a consumer for the stream.
The monitoring tool outputs the timestamp, lat, lon, byts per second and rtt.

## Feature Flags

There are currently two feature flags for this tool which enable us to record
and output data to the endpoint in multiple formats.

### RTT

With only the `rtt` flag enabled the tool records and emits the `rtt` towards
the `ping_ip`. One output would look like this:

```csv
# lat, lon, rtt
0.00000000,0.00000000,6480000 ns
```

```sh
curl -X GET -H "Content-Type: application/json" -d "{ \"endpoint_ip\": [\"http://172.17.0.1:41002/upload\"], \"ping_ip\": \"1.1\" }" http://172.17.0.1:8000/demo/start
```

```sh
cargo build -F rtt
```

### RTT/Throughput

```csv
# unix timestamp, lat, lon, bytes per second, rtt
1716480819,0.00000000,0.00000000,1.86 KB,6960000 ns
```

```sh
curl -X GET -H "Content-Type: application/json" -d "{ \"endpoint_ip\": [\"http://172.17.0.1:41002/upload\"], \"ping_ip\": \"1.1\" , \"stream_url\": \"rtmp://132.252.100.137:31000/live/test\" }" http://172.17.0.1:8000/demo/start
```

```sh
cargo build -F rtt -F throughput
```

### Throughput (not yet tested)

```csv
# lat, lon, throughput per second
0.00000000,0.00000000,1.86 KB
```

```sh
curl -X GET -H "Content-Type: application/json" -d "{ \"endpoint_ip\": [\"http://172.17.0.1:41002/upload\"], \"stream_url\": \"rtmp://132.252.100.137:31000/live/test\" }" http://172.17.0.1:8000/demo/start
```

```sh
cargo build -F throughput
```

## Local Deployment

### Example

```sh
# Server
docker build -f nginx.Dockerfile -t ffmpeg-nginx .; docker run -p 1935:1935 ffmpeg-nginx:latest

# Client
# Add features as needed
cargo run -F rtt -F throughput -- -p "/pcap/receiver.pcap" -o "/output/videoprobe_$(date '+%s').log"

# Configure Client
curl -X GET -H "Content-Type: application/json" -d "{ \"endpoint_ip\": [\"http://172.17.0.1:41002/upload\"], \"ping_ip\": \"1.1\" , \"stream_url\": \"rtmp://localhost:1935/live/test\" }" http://172.17.0.1:8000/demo/start
```

## Open internal Ports

- **1935**: RTMP of `web` providing `sender`-stream
- **8000**: Endpoint of `videoprobe`

## Configurations/Environment Variables

- STREAM<sub>URL</sub>: The URL of a rtmp based video stream. In this
  environment it is to be `web`.
- RUST<sub>LOG</sub>: The logging level of the network monitoring tool
  itself.
- ROCKET<sub>CONFIG</sub>: Might as well be constant, but specifies the
  path for the configuration of the API endpoint of `videoprobe`.
- VP<sub>TARGET</sub>: The API endpoint to upload the collected data to
  with with a `POST` request. This is variable should not be used during
  the demonstration.
- CMD: Needed as an alternative to using the `command:` keyword, which
  is usually used to overwrite a containers entrypoint.
- GNSS<sub>ENABLED</sub>: Used for choosing whether the videoprobe
  should be running with "dry gps". Dry GPS means that the tool will be
  running without GPS capabilities in case the user is sure that there
  is no GNSS device present or satalite connectivity can't be ensured.
- GNSS<sub>DEV</sub>: The path of the mounted GNSS Device. Needed to
  start gpsd inside of the container. Changes to it should also be
  applied to the corresponding
  [file:local-docker-compose.yml](local-docker-compose.yml) and
  [file:docker-compose.yml](docker-compose.yml).
