LoRa Network Server

The network server is the center of a LoRa network, it provides communication between motes and applications. It ensures message integrity through CRC, CMAC and sequence number tracking. AES-128 encryption is enabled through the use of pre-shared keys.

LNS Diagram

Links

Intro to LoRa

Basic Configuration

Advanced Configuration

MQTT Messages

Methods for end-devices to join the Conduit LoRaWAN network

Order of network server join authentication

The first one to succeed will provide the appkey and configuration used for creating the session keys.

  1. Network ID and Network Key are checked if the JoinEUI/AppEUI in the Join Request matches the NetworkID
  2. If Join Server Location is set to Local Keys, or in mLinux whitelist is enabled
    • The whitelist is searched for the DevEUI and the AppKey and Class setting are used for the device
  3. If Join Server Location is set to Cloud Key Store, or in mLinux whitelist is disabled and Lens settings are correct
    • The Join Request is sent to the Join Server to be authenticated, the Lens end-device configuration is returned to the Conduit including the Class setting.

LoRa Query Utility

The LoRa Query Utility provides an easy to use interface to the command port for most operations as an alternative to directly accessing the UDP command port.

lora-query
Version: 1.0.4

Usage: lora-query [-t timeout] [-s] [-n]
        Simple UDP client utility to pull info from LoRa Network server
        --timeout (t)     : UDP recv timeout, default: 100 (msecs)
        --stats (s)       : get LoRa Network server statistics
        --stats-reset (r) : reset LoRa Network server statistics
        --node-list (n)   : get Node List
        --command (x) : send command string to network server
                usage: --command   ...
                ex:    --command device list json
                ex:    -x help
        --json (j)        : data in json format
        --help (?)        : returns this message
        --version (v)     : print version

Examples

End-Device List

> lora-query -x devices

Add End-device
Add a node for ABP or MANUAL network joining

> lora-query -x device add '{"deveui":"00-80-00-00-00-00-e1-9c","class":"C"}'
> lora-query -x session add '{"deveui":"00-80-00-00-00-00-e1-9c","dev_addr":"00112233","appeui":"00-88-88-88-00-00-e1-9c","joineui":"00-99-99-99-00-00-e1-9c","net_id":"000017","app_senc_key":"531bd9c5ec5d8ba5ef3b262cebfb3e66","fnwk_sint_key":"531bd9c5ec5d8ba5ef3b262cebfb3e66"}'

Add a node for OTA join with unique APPKEY

AEP use LoRaWAN > Key Management page in GUI or this curl command, restart of network server is needed after adding

> curl 127.0.0.1/api/loraNetwork/whitelist/devices -X POST --data '{"deveui":"16ea76f6ab663d80","appeui":"0001020304050607","class":"C","appkey":"4c194e20d396b5f7d3e1551e4cd320de"}' -H "Content-Type: application/json"
> curl 127.0.0.1/api/command/save -X POST --data ""
> /etc/init.d/lora-network-server restart

mLinux

> vi /var/config/lora/lora-network-server.conf
...,
"whitelist": {
 "enabled": true,
 "devices": [
     {"deveui":"16ea76f6ab663d80","appeui":"0001020304050607","class":"C","appkey":"4c194e20d396b5f7d3e1551e4cd320de"}
  ]
},
...

Remove an end-device

> lora-query -x device delete 008000df30011a6c

Change node class

> curl 127.0.0.1/api/loraNetwork/whitelist/devices/0 -X PUT --data '{"class":"A"}' -H "Content-Type: application/json"

 

Command Interface

Connect using netcat

nc -u localhost 6677

or

echo "$x" > /dev/udp/localhost/6677

Where $x is the command to execute.

LoRa Network Server Commands 2.0.19

admin@mtcdt:/opt/lora# lora-query -x help
MTS Lora Server Command Help

Commands:
stats - list current stats
  reset - reset stats for network, gateways and end-devices
gateway - gateway commands
  list - list connected gateways
      format: gateway list [json]
  delete - remove a gateway from the list
      format: device gateway 
device - end-device commands
  add - add a new end-device record
      format: device add 
      example: device add '{"deveui":"00-80-00-00-00-00-e1-9c","class":"C"}'
  stats - show end-device statistics
  update - update end-device configuration or session info
      format: device update   
      example: device update 00-80-00-00-00-00-e1-9c class C
      fields: class, nskey, dskey, ulc, dlc
      format: device update 
      example: device update '{"deveui":"00-80-00-00-00-00-e1-9c","class":"C"}'
      fields: class, name, serial_number, product_id, hardware_version, firmware_version, lorawan_version
  delete - delete an end-device configuration, session and packet records
      format: device delete 
  config - show configuration for a specific device
  reset - reset end-device session counters
      format: device reset 
  list - list end-devices configured in the network server
      format: device list [json | json file ]
      example: device list json
      example: device list json file /tmp/devices.json
  keygen - generate a unique end-device key using zero-touch settings
      format: device keygen  [APP-EUI]
session - session commands
  add - add a session for a device
      format: session add 
      example: session add '{"deveui":"00-80-00-00-00-00-e1-9c","dev_addr":"00112233","appeui":"00-88-88-88-00-00-e1-9c","joineui":"00-99-99-99-00-00-e1-9c","net_id":"0
00017","app_senc_key":"531bd9c5ec5d8ba5ef3b262cebfb3e66","fnwk_sint_key":"531bd9c5ec5d8ba5ef3b262cebfb3e66"}'
      fields: deveui, appeui, joineui, dev_addr, net_id, app_senc_key, fnwk_sint_key
  delete - remove a device session
      format: session delete 
  reset - reset session counters
      format: session reset 
  list - show current device sessions
      format: session list [json | json file  ]
      example: session list jsonvi /
      example: session list json file /tmp/sessions.json
packet - packet commands
  join - list all validated join packets
      format: packet join [json]
  recent - list all recently received packets (unauthenticated)
      format: packet recent [json]
      join - list all recently received join requests
            format: packet recent join [json]
  up - list all validated uplink packets
      format: packet up [json]
  down - list all downlink packets
      format: packet down [json]
  list - list all packets: join, up and down
      format: packet list [json]
  queue - list downlink queue packets to be sent to end-device
      format: packet queue [json]
    add - add a packet to the downlink queue
      format: packet queue add 
      fields: deveui, data, ack, ack_retries, rx_wnd
    delete - delete all downlinks for a specific device
      format: packet queue delete 
    delete - delete one downlink for a specific device
      format: packet queue delete  
database - database commands
  backup - backup database to flash memory
config - show network server configuration
debug - change debug level
ping - ping the network server command port
help - display this help
quit - command network server process to stop

- add 'json' modifier to request output in json

LoRa Network Server Commands 1.0.32

  • database backup

LoRa Network Server Commands 1.0.26

  • node keygen <DEV-EUI> [APP-EUI] – zero touch key generation

LoRa Network Server Commands 1.0.8

    • config – display config
    • stats – display stats
    • stats reset – reset network server stats
    • print error|warning|info|debug|trace – change debug output level
    • node list – list nodes
    • node add <NET-ADDR> [CLASS] <APP-EUI> <DEV-EUI> { [APP-KEY] | [NET-SKEY] [APP-SKEY] }
      • ABP
        node add <NET-ADDR> [CLASS] <APP-EUI> <DEV-EUI> [NET-SKEY] [APP-SKEY]
        node add 00000001 A 0011223344556677 7766554433221100 00112233445566777766554433221100 77665544332211007766554433221100
      • OTAA with unique APP-KEY
        node add <NET-ADDR> [CLASS] <APP-EUI> <DEV-EUI> [APP-KEY]
        node add 00000001 A 0011223344556677 7766554433221100 00112233445566777766554433221100
    • node delete <NET-ADDR> – delete a node
    • node config <NET-ADDR> – show node config
    • node update <NET-ADDR> (class | appkey | nskey | dskey) <VALUE> – update a config setting
      • change existing node to class C
        node update 00000001 class c
      • change existing node APP-KEY
        node update 00000001 appkey 00112233445566777766554433221100
    • node reset <NET-ADDR> – reset node counters
    • ping – print alive message
    • include <FILENAME> – Read commands from file

LoRa Network Server Commands 0.9.2

    • config – display config
    • stats – display stats
    • stats reset – reset network server stats
    • print error|warning|info|debug|trace – change debug output level
    • node list – list nodes
    • node add <NET-ADDR> <APP-EUI> <DEV-EUI> [NET-SKEY] [APP-SKEY]
    • node delete <NET-ADDR> – delete a node
    • node reset <NET-ADDR> – reset node stats
    • ping – print alive message
    • include <FILENAME> – Read commands from file