Skip to content
Germán Martín edited this page Jan 5, 2017 · 12 revisions

PainlessMesh Technical Documentation

PainlessMesh creates a mesh network using a star topology, without any circular paths.

General

PainlessMesh does not use the native mesh functionality of the ESP8266. (See here.) Instead it uses the regular wifi accesspoint (AP) and client, to create a self organizing and repairing network where all nodes are connected.

Network layout

Every node acts as an accesspoint (AP) for other nodes to connect to and as a client to connect to a maximum of 1 AP of another node. There is a limit of 4 station nodes per AP. This limit is fixed by ESP8266 SDK.

Each node which is not already/anymore connected to an AP, scans for other AP's from other nodes periodically.

From all AP's found while scanning, which are not already present in the list of connections or sub-connections, the AP with the strongest signal is connected to. This avoid the creation of nerwork loops. There is a single route between each pair of nodes of the mesh.

All nodes in the mesh have the same weigth. That is there is no central node, all them have the same function in the network.

sample The direction of the arrow represents the direction in which the connection is made.

Although comunication from a note to its connected AP is made over a TCP/IP conection, mech based messages do not flow over IP. They are text messages in JSON format. Each node is responsible to route each message to the right path

Node Sync

A list of connections of a node is stored and for each connection a list of sub-connections is also stored. (Note: the list of connections contains the connections which are received by the node, but also the connection (max 1) that are initiated by the node...). So, every node knows the complete network topology.

The list of sub-connections per node is obtained by a request/response message. The request contains the sub-connections of the requesting node, and the response contains the sub-connections of the responding node. The collection of sub-connections returned, always excludes the requesting connection and its sub-connections.

Cases in which a new node sync is done

  • Request for sub-connections is done periodically
  • When any update in the network is detected, i.e. any sub-connection of a node has changed
  • When a new node connects to a new AP

Each node sends out a request sub-connections for each connection.

Routing messages

With the star network topology without any loops. routing becomes very easy. There is a single route for each node pair.

SINGLE messages

For single messages, a destination and origin node is specified. First the connection to use is looked up. Either the direct connection, or the connection which has a sub-connection to the destination node. The message is send to that node. When that node is not the destination node, the exact message is relayed to the next connection, which is looked up in the same way. This repeats until the message arrives at the destination node.

Messages are not acknowledged. If needed it has to be done at application level.

BROADCAST messages

For broadcast messages, all connections are iterated and the message is sent to each connection. Upon receiving the broadcast message, the message is relayed to all connections of the receiving node, except for the connection by which the message is received.