Multi-interface Mesh Networking
Early in our development process, it became clear a flexible, robust mesh network would be an extremely useful feature of the DroneLink platform. Two of the primary drivers of this were:
- Supporting multiple boats on the water at the same time (4 is our current record, plus support equipment)
- Extending the range of our lake testing beyond 100m from the base station
Use Cases
- Short-range (<50 m):
- Bench testing - all devices located within the vicinity of a single building and/or all within WiFi range of a single router
- Lake testing: Very close to shore/launch-point testing
- Medium-range (<200 m):
- Typical range for most lake tests
- Line-of-sight radio practical at fairly high data rates, 433MHz or 915MHz viable
- Long-range (<20 km):
- Typical range for early sea trials
- Line-of-sight radio is still possible at a low data rate - may require a lower frequency (433MHz) for range and directional base-station antenna
- GSM connection may be possible
- Very long range (over the horizon, international water):
- No line of sight radio possible
- Only satellite (Iridium) comms are practical
Requirements
Allow DroneLink nodes to act as routers and thereby form an ad-hoc mesh
Manage multiple network interfaces, each with different capabilities (e.g. point to point, broadcast) - OSI layers 1-2
Deal with node and/or interface failures, planned restarts, and poor link quality (e.g. high packet loss from poor radio reception)
Seamlessly transmit DroneLink pub/sub messages over the mesh network
Feedback a level of route info/status to “server” nodes for analysis/troubleshooting (web UI, etc)
Low overhead such that it can be implemented on the ESP32 with minimal resource consumption
Provide an estimate of link quality/bandwidth
Support differing packet priorities (relative to link quality/speed)
Support fire-and-forget vs reliable packet delivery
Minimise packet duplication across multiple interfaces / network paths
High-level Design Choices
Packet Sizes
Addressing
Types of network interface
- WiFI (UDP)
- RFM69 on either 915MHz or 433MHz
- Point-to-point using a serial interface (wired link, point-to-point telemetry radio, transparent GSM, etc)
- Iridium satellite radio
Decomposing the challenge by OSI Layers
- Point-to-point or broadcast interfaces with the associated physical interface and data link layer (transmission framing, and packet management) - OSI layers 1-2
- Packet management including addressing, routing, and traffic control - OSI Layer 3
- Optional reliable transport - OSI Layer 4
Physical Interfaces and Data Link Layer
- Specific hardware interface to the ESP32 (via WiFi, serial, SPI, etc)
- Transmission framing including error detection
- Transmit buffer (messages queued for transmission)
- Interface state (up/down)
- Option to enable/disable the interface at run-time
RFM69 Interface
- SPI connection between the ESP32 and the RFM69HW hardware module (using the Radiohead library)
- Transmission framing - wrapping a DroneMesh packet in a special start byte and a trailing 8-bit CRC
- Error checking - on packet receive, the size and CRC are validated before passing the packet onto the Mesh router
- Transmission queueing - new packets are only transmitted once the hardware has completed the transmission of previous packets
Packet Management - Routing and traffic control
- Node discovery
- Routing table maintenance
- Processing received packets - either for local consumption or to transmit on the next hop to their destination
- Maintaining the transmit queue, including rate limiting and packet prioritisation
- Transmitting outbound packets to their next hop
- Maintain routing statistics
Node Discovery
Routing Table Maintenance
- Target node address
- When the node was last heard (any packet type)
- When a Hello packet for this node was last transmitted
- The latest metric received in a Hello packet
- The last received uptime for the node
- The last routing sequence number heard from this node (used to avoid loops - see Babel protocol)
- The next hop to reach this node - the node address to transmit a packet via to reach the target
- Active interface - which interface did we use to last communicate with this node
- Link statistics related to this node
- Time we last received an Ack from this node
- A sequencer map - a form of bitmask used to track what sequence numbers we've received in a circular array, helps to avoid processing duplicate packets received via multiple transmission paths
Processing Received Packets
Maintaining the Transmit Queue
- Some interfaces have higher bandwidth than others and require intermediate buffering
- Reliable delivery (see details below) requires storing a packet for potential re-transmission until an Ack is received
- The internal rate at which DroneLink pub/sub parameters get updated can be in the KHz range, whereas mesh packet bandwidth is practically limited to <50Hz, thus there is a need for rate limiting
- Critical priority packets can transmitted up to 1Hz
- High up to 0.5Hz
- Medium up to 0.25Hz
- Low up to 0.1Hz
Outbound Transmission
Routing Statistics
Mesh Packet Structure
- Packed 1-byte value containing:
- 1-bit for unicast or broadcast
- 1-bit for guaranteed delivery or fire-and-forget
- 6-bits for packet size -1 (i.e. represents values of 1-64 bytes)
- 1-byte Transmitting node address
- 1-byte Source node address
- 1-byte Next node address
- 1-byte Destination node address
- 1-byte Sequence number (incremented on each packet transmitted from a source, used to ignore duplicate reception)
- Packed 1-byte value containing:
- 2-bit payload priority
- 6-bit Payload type
Packet types
- 0: Hello
- 1/2: Subscription Request/Response - establish a DroneLink subscription
- 3/4: Traceroute request/response - trace network path to/from a target node
- 5/6: Routing entry request/response - get info about a specific routing entry on a target node
- 7: DroneLink message - always sent by guaranteed/reliable delivery
- 10/11: Filesystem file request/response: Get header info for an entry in the filesystem
- 12/13: Request/response to resize a file in target filesystem (or set to zero to delete)
- 14/15: Read file request/response: Read a data block from a file
- 16/17: Write file request/response: Write a data block to a file
- 20/21: Router info request/response - high level router statistics
- 22/23: Firmware start request/response - place target node into firmware download mode
- 24: Firmware write - write a block of data to the firmware (guaranteed)
- 25: Firmware rewind - Request re-transmission of a data block from the transmitting server
Reliable Transport
Result & Lessons Learnt
Power Management
- ESP32 WiFi radio consumes a significant amount of current (>120mA) - once out of range we can switch this off via the management system, reducing the ESP32 power draw to approx 20mA
- ESP32 power consumption can further be reduced by dynamically reducing CPU frequency from normal 240MHz down to approx 80MHz
- We can also put the ESP32 to sleep a lot of the time, as the main processing loop can be executed in just a few milliseconds. However, we currently have I2C bus issues when returning from sleep - this needs further investgation
- RFM69 radios are very low power to start with and we can reduce their transmit frequency and transmit power if required using our management interface
- Long-range operation will rely entirely on satellite comms, where we will only power the modem up a few times an hour to send/receive. All other radios will be shutdown in that mode.
Satellite Radio
Iridium
Swarm
Swarm vs Iridium RockBLOCK:
- On a hardware level, Swarm M138 modules are now considerably cheaper:
- Swarm M138 approx £150
- RockBLOCK Mk2 module for Iridium approx £300
- Power consumption:
- Swarm: 80uA in sleep, 1A in transmit
- RockBLOCK: 40mA in low power, 470mA max (leveraging internal super capacitor to smooth the demand when doing burst transmission)
- Network connectivity is comparable - the server-side offers WebHOOK or REST integration
- Iridium has the edge in uplink packet sizes:
- 192 bytes for Swarm
- 340 bytes for Iridium.
- Swarm is the clear winner on data costs, even after converting to cost per byte transmitted:
- Swarm is $5/month for up to 750 packets/month. or less than 1p per packet
- Iridium is a pay-as-you-go credit plan, which at similar volume is £90 for 1000 packets, or 9p per packet.
Given the above, we will acquire and test a Swarm module before finalising the satellite radio setup for sea trials!
Source Code
- src/DroneLinkManager.h
- src/DroneLinkMsg.h
- src/DroneMeshMsg.h
- src/droneModules/NetworkInterfaceModule.h
- src/droneModules/RFM69TelemetryModule.h
Comments
Post a Comment