This is the public GitHub repo for Varad Chavan's Cyber Security Master's Dissertation at Lancaster University.
This guide assumes that the local network tested on is in the IP range 192.168.0.0/24
, and the Raspberry Pi server has been assigned a static IP address 192.168.0.199
. Setup for all three ESP chips when testing threat model haven't been provided here, just the test metrics. Installation of ESP-IDf and ESP_8266_RTOS_SDK can be done by following their respective guides:
Note: There are public/private keypairs provided here that were used in a local isolated environment, hence aren't considered "unsafe" for test purposes. This is purely for convenience. Use newly generated secrets for other deployments.
To set up and run the ESP MQTT Benchmarks project, follow these instructions:
Start by cloning the repository to your local machine using the following command:
mkdir ~/esp_source
cd ~/esp_source
git clone https://github.com/ChavanVarad/esp_mqtt_benchmarks/tree/main/esp_idf_source
Change into the project directory:
cd esp_mqtt_benchmarks
-
Navigate to the unencrypted MQTT configuration directory:
cd ue
-
Run the menu configuration utility:
make menuconfig
in the case of ESP8266_RTOS_SDK (for ESP8266). idf.py menuconfig
in the case of ESP-IDF (for ESP32).
-
WiFi Configuration:
- WiFi SSID: Enter the SSID of your border router.
- WiFi Password: Enter the password of your border router.
- Use TCPIP Adapter: Set to
true
if compiling for ESP8266. - Use ESP Netif: Set to
true
if compiling for ESP32.
-
MQTT Broker Configuration:
- Broker URL: Set to the actual URL or IP address of your MQTT broker, prepended with
mqtt://
. - Client Username: Set to either
esp32-1
oresp8266-1
depending on the chip you are compiling for. - Client Password: Set to the broker password. In this case, use
"gc5459"
.
- Broker URL: Set to the actual URL or IP address of your MQTT broker, prepended with
-
Exit the configuration menu and save your settings.
-
Navigate to the unencrypted MQTT configuration directory:
cd tls
-
Run the menu configuration utility:
make menuconfig
in the case of ESP8266_RTOS_SDK (for ESP8266). idf.py menuconfig
in the case of ESP-IDF (for ESP32).
-
WiFi Configuration:
- WiFi SSID: Enter the SSID of your border router.
- WiFi Password: Enter the password of your border router.
- Use TCPIP Adapter: Set to
true
if compiling for ESP8266. - Use ESP Netif: Set to
true
if compiling for ESP32.
-
MQTT Broker Configuration:
- Broker URL: Set to the actual URL or IP address of your MQTT broker, prepended with
mqtts://
. - Client Username: Set to either
esp32-1
oresp8266-1
depending on the chip you are compiling for. - Client Password: Set to the broker password. In this case, use
"gc5459"
.
- Broker URL: Set to the actual URL or IP address of your MQTT broker, prepended with
-
Exit the configuration menu and save your settings.
-
Navigate to the unencrypted MQTT configuration directory:
cd wg
-
Run the menu configuration utility:
make menuconfig
in the case of ESP8266_RTOS_SDK (for ESP8266). idf.py menuconfig
in the case of ESP-IDF (for ESP32).
-
WiFi Configuration:
- WiFi SSID: Enter the SSID of your border router.
- WiFi Password: Enter the password of your border router.
- Use TCPIP Adapter: Set to
true
if compiling for ESP8266. - Use ESP Netif: Set to
true
if compiling for ESP32.
-
MQTT Broker Configuration:
- Broker URL: Set to the actual WireGuard IP of the broker, prepended with
mqtt://
. In this case,mqtt://10.8.0.1
. - Client Username: Set to either
esp32-1
oresp8266-1
depending on the chip you are compiling for. - Client Password: Set to the broker password. In this case, use
"gc5459"
.
- Broker URL: Set to the actual WireGuard IP of the broker, prepended with
-
WireGuard peer configuration and component setting:
- Wireguard Private Key: Set to private key generated for the ESP32 or ESP8266. In this case,
qCEY2fFpeBmCvlAyvwVL15z9qxbeItNx7dakCI8hn0I=
. - Wireguard local IP address: Set to WireGuard IP to be used for the ESP32 or ESP8266. In this case,
10.8.0.2
. - Wireguard local netmask: Subnet mask used by WireGuard virtual IP range. Since its
\24
here, use255.255.255.0
. - Wireguard local port: Port to be used for ingress and egress WireGuard traffic on the ESP chips. Here,
51820
. - Wireguard remote peer public key: Public key of the Raspberry Pi WireGuard server. Here,
4IVGEBmd+HqfDH28X7P8wtXKUPlcLm3l5Cb05b4i7XA=
. - Wireguard pre-shared symmetric key: Pre-shared key set for the specific device. Here,
+Centm7O8bJfRMD+0/eUD6hhnl1W8f11KtGnTebGbg4=
. - Wireguard remote peer address: Local IP address of the Raspberry Pi. For our setup,
192.168.0.199
. - Wireguard remote peer port: Port used at Raspberry Pi for WireGuard connection. In this case,
51820
.
- Wireguard Private Key: Set to private key generated for the ESP32 or ESP8266. In this case,
-
Exit the configuration menu and save your settings.
For flashing, make flash
in the case of ESP8266_RTOS_SDK (for ESP8266). idf.py flash
in the case of ESP-IDF (for ESP32).
- Operating System: Flash the Raspberry Pi with
Raspbian (Bookworm)
using the Raspberry Pi imager. - Update repositories:
sudo apt update
andsudo apt upgrade
before installing any necessary packages. - Required packages:
sudo apt install wireguard-tools chrony mosquitto mosquitto-clients python3-full python3-pip
- Clone repository configurations:
cd /etc/ sudo git clone https://github.com/ChavanVarad/esp_mqtt_benchmarks/tree/main/raspberry_pi_configurations
- Permissions for mosquitto broker:
sudo chown -R mosquitto:mosquitto /etc/mosquitto/
- Start services:
sudo systemctl enable mosquitto chrony sudo systemctl enable wg-quick@wg0.service sudo systemctl daemon-reload sudo systemctl start mosquitto chrony wg-quick@wg0.service
- Virtual enviornment for paho-MQTT:
python3 -m venv ~/paho source ~/paho/bin/activate pip install paho-mqtt
- Clone repository:
mkdir ~/scripts cd ~/scripts git clone https://github.com/ChavanVarad/esp_mqtt_benchmarks/tree/main/server_scripts
- Running the tests:
RTT tests:
Throughput tests:
python3 rtt.py
Power tests:python3 throughput.py
python3 power.py