Automesh - building mesh networks easily
Posted: Sun Nov 19, 2017 8:51 am
Sometimes one might want to use several ESPs in a row or a mesh to cover a larger distance or area. Generally, this can be done without major problems with the esp_wifi_repeater. Actually, you will have several layers of NAT. Of course, the available bandwidth goes down the more hops you need. But uses have reported that even 5 esp_wifi_repeaters in a row work quite well.
In such a setup configuration is quit a time consuming and error-prone activity. To simplify that, I would like to propose a kind of a protocol that automates and simplifies this for an ESP with NAT-routing in place: "Automesh":
Just configure the SSID and the password and do the following: Each ESP should automatically offer a WiFi network on the AP inferface with the same SSID/password as it is connected to. Clients can use the same WiFi settings for the original network or the repeated ones. Each ESP will first search for the best other AP to connect to. This is the one which closest to the original WiFi network and has the best signal strength (RSSI).
The signal strenght is easy to measure with a scan, but which is the one closest to the original WiFi network if you see several APs with the same SSID? Therefore I use a somewhat dirty trick: the esp_wifi_repeaters in "automesh" mode manipulate their BSSID, i.e. the MAC address of their AP interface which is send out with every beacon frame 10 about time times per second. It uses the format: 24:24:mm:rr:rr:rr. "24:24" is just the unique identifier of a repeater (there is a minimal probability that this collides with the real APs MAC, but we can neglect this, as we can change that prefix if really required). "mm" means the "mesh level", this is the distance in hops to the original WiFi network. The last three "rr:rr:rr" are just random numbers to distinguish the various ESPs.
Now each ESP can learn which other ESP is the closest to the the original WiFi network, can connect to that, and chose its own BSSID accordingly. This creates a tree (a very special mesh) with the original WiFi network as root and nodes on several mesh levels (actually, it works somewhat similar as the Spanning Tree Protocol (STP) on the link layer or routing on the network layer using a Distance Vector protocol). As soon as a link loss is detected, configuration is restarted. This should avoid loops as during (re-)configuration also no beacons with an BSSID are sent.
The latest version of the esp_wifi_repeater includes this feature - give it a try!
In such a setup configuration is quit a time consuming and error-prone activity. To simplify that, I would like to propose a kind of a protocol that automates and simplifies this for an ESP with NAT-routing in place: "Automesh":
Just configure the SSID and the password and do the following: Each ESP should automatically offer a WiFi network on the AP inferface with the same SSID/password as it is connected to. Clients can use the same WiFi settings for the original network or the repeated ones. Each ESP will first search for the best other AP to connect to. This is the one which closest to the original WiFi network and has the best signal strength (RSSI).
The signal strenght is easy to measure with a scan, but which is the one closest to the original WiFi network if you see several APs with the same SSID? Therefore I use a somewhat dirty trick: the esp_wifi_repeaters in "automesh" mode manipulate their BSSID, i.e. the MAC address of their AP interface which is send out with every beacon frame 10 about time times per second. It uses the format: 24:24:mm:rr:rr:rr. "24:24" is just the unique identifier of a repeater (there is a minimal probability that this collides with the real APs MAC, but we can neglect this, as we can change that prefix if really required). "mm" means the "mesh level", this is the distance in hops to the original WiFi network. The last three "rr:rr:rr" are just random numbers to distinguish the various ESPs.
Now each ESP can learn which other ESP is the closest to the the original WiFi network, can connect to that, and chose its own BSSID accordingly. This creates a tree (a very special mesh) with the original WiFi network as root and nodes on several mesh levels (actually, it works somewhat similar as the Spanning Tree Protocol (STP) on the link layer or routing on the network layer using a Distance Vector protocol). As soon as a link loss is detected, configuration is restarted. This should avoid loops as during (re-)configuration also no beacons with an BSSID are sent.
The latest version of the esp_wifi_repeater includes this feature - give it a try!