11 Gateway Cluster and Device Roaming

The IMX93-GW8016 supports distributed LoRaWAN edge clusters where multiple gateways form a self-managing cluster via the MQTT protocol, enabling device roaming and high-availability deployment.

11.1 Cluster Architecture Diagram

graph TB subgraph "LoRaWAN Devices" DEV1["device A<br/>DevEUI: ffffff200000b001<br/>AppKey: xxx"] DEV2["device B<br/>DevEUI: ffffff200000b002<br/>AppKey: yyy"] DEV3["device C<br/>DevEUI: ffffff200000b003<br/>AppKey: zzz"] DEV4["Mobile device D<br/>DevEUI: ffffff200000b004<br/>Roaming"] end subgraph "Gateway Cluster" GW1["gateway 1<br/>GW ID: ...3610<br/>DevAddr: 3610xxxx"] GW2["gateway 2<br/>GW ID: ...4521<br/>DevAddr: 4521xxxx"] GW3["gateway 3<br/>GW ID: ...7832<br/>DevAddr: 7832xxxx"] GW4["gateway 4<br/>GW ID: ...8943<br/>DevAddr: 8943xxxx"] GW5["gateway 5<br/>GW ID: ...1054<br/>DevAddr: 1054xxxx"] GW6["gateway 6<br/>GW ID: ...2165<br/>DevAddr: 2165xxxx"] end subgraph "Cluster MQTT Broker" MQTT_CLUSTER["MQTT Broker<br/>Cluster message bus"] end subgraph "Data Flow" FLOW1["① Device A joins at GW1"] FLOW2["② GW1 broadcasts AppKey"] FLOW3["③ Device D moves to GW4"] FLOW4["④ Session sync"] end %% Device to gateway connections DEV1 -.->|LoRa join| GW1 DEV2 -.->|LoRa join| GW2 DEV3 -.->|LoRa data| GW3 DEV4 -.->|LoRa roaming| GW4 %% Gateway to MQTT connections GW1 <-->|MQTT| MQTT_CLUSTER GW2 <-->|MQTT| MQTT_CLUSTER GW3 <-->|MQTT| MQTT_CLUSTER GW4 <-->|MQTT| MQTT_CLUSTER GW5 <-->|MQTT| MQTT_CLUSTER GW6 <-->|MQTT| MQTT_CLUSTER %% Styles classDef device fill:#e8f5e9,stroke:#1b5e20,stroke-width:2px classDef gateway fill:#e3f2fd,stroke:#0d47a1,stroke-width:3px classDef mqtt fill:#fff3e0,stroke:#e65100,stroke-width:2px classDef flow fill:#fce4ec,stroke:#880e4f,stroke-width:2px class DEV1,DEV2,DEV3,DEV4 device class GW1,GW2,GW3,GW4,GW5,GW6 gateway class MQTT_CLUSTER mqtt class FLOW1,FLOW2,FLOW3,FLOW4 flow

11.2 Cluster Working Principle

11.2.1 Key Broadcasting (Broadcaster)

Feature: Securely broadcasts local device credentials (AppKey) to the cluster network.

Workflow:

  1. The device joins on Gateway 1 (OTAA Join Request)
  2. Gateway 1 verifies the AppKey and assigns a DevAddr (format: 3610xxxx)
  3. Gateway 1 publishes the AppKey to the MQTT topic
  4. Other gateways subscribe to this topic, receive and store the AppKey
  5. When a device moves to another gateway, any gateway in the cluster can handle its join request

11.2.2 Key Synchronization (Learner)

Feature: Automatically learns device credentials shared by other gateways in the cluster.

Workflow:

  1. The gateway subscribes to the MQTT topic
  2. Receives AppKeys broadcast by other gateways
  3. Store the AppKey in the local ChirpStack database
  4. When a device sends a Join Request, this gateway can directly verify it

Advantages:

  • Devices can join any gateway in the cluster
  • Reduces manual configuration workload
  • After a device changes location, re-joining is not required

11.2.3 Session Synchronization (Roaming)

Feature: Real-time sync of active session status (DevAddr, session private key, frame counter).

Workflow:

  1. The device completes joining on Gateway 1 and obtains a DevAddr and session private key
  2. Gateway 1 publishes the session information to the MQTT topic
  3. Other gateways subscribe to this topic, receive and store session information
  4. The device moves to Gateway 4
  5. Gateway 4 receives the device uplink data and decrypts it using the synced session private key
  6. Gateway 4 verifies the frame counter to prevent replay attacks

Advantages:

  • Seamless Roaming: Devices moving between gateways experience no data interruption
  • Prevent Duplicate Processing: Deduplicate using FCnt
  • High Availability: If one gateway fails, devices automatically switch to another

11.3 DevAddr Differentiation Mechanism

When assigning a join address (DevAddr), each gateway uses the last two bytes of its Gateway ID as an identifier.

DevAddr format(32):

  • Bits 31–25: Network ID (7 bits)
  • Bits 24–16: Gateway ID (8 bits)
  • Bits 15–0: Device sequence number (16 bits)

Example:

  • Gateway 1 ID: 0010502df4563610, last 2 digits: 10
  • Assigned DevAddr:3610bd78
  • Gateway 2 ID: 0010502df45806b4, last 2 digits: 21
  • Assigned DevAddr:06b407e4

Advantages:

  • DevAddr can be used to quickly identify the gateway that a device initially joined
  • Facilitates fault investigation and network optimization
  • Supports multi-gateway cooperative operation