{"id":11786,"date":"2016-02-29T06:51:47","date_gmt":"2016-02-29T12:51:47","guid":{"rendered":"http:\/\/www.multitech.net\/developer\/?page_id=11786"},"modified":"2018-04-20T08:09:20","modified_gmt":"2018-04-20T13:09:20","slug":"lora-network-server","status":"publish","type":"page","link":"https:\/\/www.multitech.net\/developer\/software\/lora\/lora-network-server\/","title":{"rendered":"LoRa Network Server"},"content":{"rendered":"<div class=\"note\">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.<\/div>\n<p><img decoding=\"async\" alt=\"LNS Diagram\" src=\"https:\/\/www.multitech.net\/developer\/wp-content\/uploads\/2016\/02\/LNS-diagram-e1488383721685.png\" \/><\/p>\n<h2>Links<\/h2>\n<p><a title=\"Intro to LoRa\" href=\"https:\/\/www.multitech.net\/developer\/software\/lora\/introduction-to-lora\/\">Intro to LoRa<\/a><\/p>\n<p><a title=\"Basic Configuration\" href=\"https:\/\/www.multitech.net\/developer\/software\/lora\/getting-started-with-lora-conduit-mlinux\/\">Basic Configuration<\/a><\/p>\n<p><a title=\"Advanced Configuration\" href=\"https:\/\/www.multitech.net\/developer\/software\/lora\/conduit-mlinux-lora-communication\/conduit-mlinux-advance-lora-configuration\/\">Advanced Configuration<\/a><\/p>\n<p><a title=\"MQTT Messages\" href=\"https:\/\/www.multitech.net\/developer\/software\/lora\/lora-network-server\/mqtt-messages\/\">MQTT Messages<\/a><\/p>\n<p><\/p>\n<h2>Methods for end-devices to join the Conduit LoRaWAN network<\/h2>\n<h3>Order of network server join authentication<\/h3>\n<p>The first one to succeed will provide the appkey and configuration used for creating the session keys.<\/p>\n<ol>\n<li>Network ID and Network Key are checked if the JoinEUI\/AppEUI in the Join Request matches the NetworkID<\/li>\n<li>If Join Server Location is set to Local Keys, or in mLinux whitelist is enabled\n<ul>\n<li>The whitelist is searched for the DevEUI and the AppKey and Class setting are used for the device<\/li>\n<\/ul>\n<\/li>\n<li>If Join Server Location is set to Cloud Key Store, or in mLinux whitelist is disabled and Lens settings are correct\n<ul>\n<li>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.<\/li>\n<\/ul>\n<\/li>\n<\/ol>\n<p><\/p>\n<h2>LoRa Query Utility<\/h2>\n<p>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.<\/p>\n<pre class=\"brush:shell\">lora-query\r\nVersion: 1.0.4\r\n\r\nUsage: lora-query [-t timeout] [-s] [-n]\r\n        Simple UDP client utility to pull info from LoRa Network server\r\n        --timeout (t)     : UDP recv timeout, default: 100 (msecs)\r\n        --stats (s)       : get LoRa Network server statistics\r\n        --stats-reset (r) : reset LoRa Network server statistics\r\n        --node-list (n)   : get Node List\r\n        --command (x) : send command string to network server\r\n                usage: --command <COMMAND-NAME> <COMMAND-OPTIONS> ...\r\n                ex:    --command device list json\r\n                ex:    -x help\r\n        --json (j)        : data in json format\r\n        --help (?)        : returns this message\r\n        --version (v)     : print version\r\n<\/pre>\n<h3>Examples<\/h3>\n<p><b>End-Device List<\/b><\/p>\n<pre class=\"brush:shell\">&gt; lora-query -x devices<\/pre>\n<p><b>Add End-device<\/b><br \/>\nAdd a node for ABP or MANUAL network joining<\/p>\n<pre class=\"brush:shell\">&gt; lora-query -x device add '{\"deveui\":\"00-80-00-00-00-00-e1-9c\",\"class\":\"C\"}'<\/pre>\n<pre class=\"brush:shell\">&gt; 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\"}'<\/pre>\n<p>Add a node for OTA join with unique APPKEY<\/p>\n<h4>AEP use LoRaWAN > Key Management page in GUI or this curl command, restart of network server is needed after adding<\/h4>\n<pre class=\"brush:shell\">&gt; 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\"\r\n&gt; curl 127.0.0.1\/api\/command\/save -X POST --data \"\"\r\n&gt; \/etc\/init.d\/lora-network-server restart\r\n<\/pre>\n<h4>mLinux<\/h4>\n<pre class=\"brush:shell\">&gt; vi \/var\/config\/lora\/lora-network-server.conf\r\n...,\r\n\"whitelist\": {\r\n \"enabled\": true,\r\n \"devices\": [\r\n     {\"deveui\":\"16ea76f6ab663d80\",\"appeui\":\"0001020304050607\",\"class\":\"C\",\"appkey\":\"4c194e20d396b5f7d3e1551e4cd320de\"}\r\n  ]\r\n},\r\n...\r\n<\/pre>\n<p><b>Remove an end-device<\/b><\/p>\n<pre class=\"brush:shell\">&gt; lora-query -x device delete 008000df30011a6c<\/pre>\n<p><b>Change node class<\/b><\/p>\n<pre class=\"brush:shell\">&gt; curl 127.0.0.1\/api\/loraNetwork\/whitelist\/devices\/0 -X PUT --data '{\"class\":\"A\"}' -H \"Content-Type: application\/json\"<\/pre>\n<p>&nbsp;<\/p>\n<h2>Command Interface<\/h2>\n<p>Connect using netcat<\/p>\n<p><code>nc -u localhost 6677<\/code><\/p>\n<p>or<\/p>\n<p><code>echo \"$x\" &gt; \/dev\/udp\/localhost\/6677<\/code><\/p>\n<p>Where $x is the command to execute.<\/p>\n<h3>LoRa Network Server Commands 2.0.19<\/h3>\n<pre>\r\nadmin@mtcdt:\/opt\/lora# lora-query -x help\r\nMTS Lora Server Command Help\r\n\r\nCommands:\r\nstats - list current stats\r\n  reset - reset stats for network, gateways and end-devices\r\ngateway - gateway commands\r\n  list - list connected gateways\r\n      format: gateway list [json]\r\n  delete - remove a gateway from the list\r\n      format: device gateway <GW-EUI>\r\ndevice - end-device commands\r\n  add - add a new end-device record\r\n      format: device add <DEV-JSON>\r\n      example: device add '{\"deveui\":\"00-80-00-00-00-00-e1-9c\",\"class\":\"C\"}'\r\n  stats - show end-device statistics\r\n  update - update end-device configuration or session info\r\n      format: device update <DEV-EUI> <FIELD> <VALUE>\r\n      example: device update 00-80-00-00-00-00-e1-9c class C\r\n      fields: class, nskey, dskey, ulc, dlc\r\n      format: device update <DEV-JSON>\r\n      example: device update '{\"deveui\":\"00-80-00-00-00-00-e1-9c\",\"class\":\"C\"}'\r\n      fields: class, name, serial_number, product_id, hardware_version, firmware_version, lorawan_version\r\n  delete - delete an end-device configuration, session and packet records\r\n      format: device delete <DEV-EUI>\r\n  config - show configuration for a specific device\r\n  reset - reset end-device session counters\r\n      format: device reset <DEV-EUI>\r\n  list - list end-devices configured in the network server\r\n      format: device list [json | json file <path>]\r\n      example: device list json\r\n      example: device list json file \/tmp\/devices.json\r\n  keygen - generate a unique end-device key using zero-touch settings\r\n      format: device keygen <DEV-EUI> [APP-EUI]\r\nsession - session commands\r\n  add - add a session for a device\r\n      format: session add <DEV-JSON>\r\n      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\r\n00017\",\"app_senc_key\":\"531bd9c5ec5d8ba5ef3b262cebfb3e66\",\"fnwk_sint_key\":\"531bd9c5ec5d8ba5ef3b262cebfb3e66\"}'\r\n      fields: deveui, appeui, joineui, dev_addr, net_id, app_senc_key, fnwk_sint_key\r\n  delete - remove a device session\r\n      format: session delete <DEV-EUI>\r\n  reset - reset session counters\r\n      format: session reset <DEV-EUI>\r\n  list - show current device sessions\r\n      format: session list [json | json file <path> ]\r\n      example: session list jsonvi \/\r\n      example: session list json file \/tmp\/sessions.json\r\npacket - packet commands\r\n  join - list all validated join packets\r\n      format: packet join [json]\r\n  recent - list all recently received packets (unauthenticated)\r\n      format: packet recent [json]\r\n      join - list all recently received join requests\r\n            format: packet recent join [json]\r\n  up - list all validated uplink packets\r\n      format: packet up [json]\r\n  down - list all downlink packets\r\n      format: packet down [json]\r\n  list - list all packets: join, up and down\r\n      format: packet list [json]\r\n  queue - list downlink queue packets to be sent to end-device\r\n      format: packet queue [json]\r\n    add - add a packet to the downlink queue\r\n      format: packet queue add <PACKET-JSON>\r\n      fields: deveui, data, ack, ack_retries, rx_wnd\r\n    delete - delete all downlinks for a specific device\r\n      format: packet queue delete <DEV-EUI>\r\n    delete - delete one downlink for a specific device\r\n      format: packet queue delete <DEV-EUI> <ID>\r\ndatabase - database commands\r\n  backup - backup database to flash memory\r\nconfig - show network server configuration\r\ndebug - change debug level\r\nping - ping the network server command port\r\nhelp - display this help\r\nquit - command network server process to stop\r\n\r\n- add 'json' modifier to request output in json\r\n\r\n<\/pre>\n<h3>LoRa Network Server Commands 1.0.32<\/h3>\n<ul>\n<li>database backup<\/li>\n<\/ul>\n<h3>LoRa Network Server Commands 1.0.26<\/h3>\n<ul>\n<li>node keygen &lt;DEV-EUI&gt; [APP-EUI] &#8211; zero touch key generation<\/li>\n<\/ul>\n<h3>LoRa Network Server Commands 1.0.8<\/h3>\n<ul>\n<ul>\n<li>config &#8211; display config<\/li>\n<li>stats &#8211; display stats<\/li>\n<li>stats reset &#8211; reset network server stats<\/li>\n<li>print error|warning|info|debug|trace &#8211; change debug output level<\/li>\n<li>node list &#8211; list nodes<\/li>\n<li>node add &lt;NET-ADDR&gt; [CLASS] &lt;APP-EUI&gt; &lt;DEV-EUI&gt; { [APP-KEY] | [NET-SKEY] [APP-SKEY] }\n<ul>\n<li>ABP\n<pre class=\"brush:js\">node add &lt;NET-ADDR&gt; [CLASS] &lt;APP-EUI&gt; &lt;DEV-EUI&gt; [NET-SKEY] [APP-SKEY]\r\nnode add 00000001 A 0011223344556677 7766554433221100 00112233445566777766554433221100 77665544332211007766554433221100<\/pre>\n<\/li>\n<li>OTAA with unique APP-KEY\n<pre class=\"brush:js\">node add &lt;NET-ADDR&gt; [CLASS] &lt;APP-EUI&gt; &lt;DEV-EUI&gt; [APP-KEY]\r\nnode add 00000001 A 0011223344556677 7766554433221100 00112233445566777766554433221100<\/pre>\n<\/li>\n<\/ul>\n<\/li>\n<li>node delete &lt;NET-ADDR&gt; &#8211; delete a node<\/li>\n<li>node config &lt;NET-ADDR&gt; &#8211; show node config<\/li>\n<li>node update &lt;NET-ADDR&gt; (class | appkey | nskey | dskey) &lt;VALUE&gt; &#8211; update a config setting\n<ul>\n<li>change existing node to class C\n<pre class=\"brush:js\">node update 00000001 class c<\/pre>\n<\/li>\n<li>change existing node APP-KEY\n<pre class=\"brush:js\">node update 00000001 appkey 00112233445566777766554433221100<\/pre>\n<\/li>\n<\/ul>\n<\/li>\n<li>node reset &lt;NET-ADDR&gt; &#8211; reset node counters<\/li>\n<li>ping &#8211; print alive message<\/li>\n<li>include &lt;FILENAME&gt; &#8211; Read commands from file<\/li>\n<\/ul>\n<\/ul>\n<h3>LoRa Network Server Commands 0.9.2<\/h3>\n<ul>\n<ul>\n<li>config &#8211; display config<\/li>\n<li>stats &#8211; display stats<\/li>\n<li>stats reset &#8211; reset network server stats<\/li>\n<li>print error|warning|info|debug|trace &#8211; change debug output level<\/li>\n<li>node list &#8211; list nodes<\/li>\n<li>node add &lt;NET-ADDR&gt; &lt;APP-EUI&gt; &lt;DEV-EUI&gt; [NET-SKEY] [APP-SKEY]<\/li>\n<li>node delete &lt;NET-ADDR&gt; &#8211; delete a node<\/li>\n<li>node reset &lt;NET-ADDR&gt; &#8211; reset node stats<\/li>\n<li>ping &#8211; print alive message<\/li>\n<li>include &lt;FILENAME&gt; &#8211; Read commands from file<\/li>\n<\/ul>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>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. Links Intro to LoRa Basic Configuration Advanced Configuration MQTT Messages Methods for end-devices to join the Conduit [&hellip;]<\/p>\n","protected":false},"author":1337,"featured_media":0,"parent":8462,"menu_order":1,"comment_status":"closed","ping_status":"closed","template":"","meta":{"_bbp_topic_count":0,"_bbp_reply_count":0,"_bbp_total_topic_count":0,"_bbp_total_reply_count":0,"_bbp_voice_count":0,"_bbp_anonymous_reply_count":0,"_bbp_topic_count_hidden":0,"_bbp_reply_count_hidden":0,"_bbp_forum_subforum_count":0,"footnotes":""},"class_list":["post-11786","page","type-page","status-publish","hentry"],"_links":{"self":[{"href":"https:\/\/www.multitech.net\/developer\/wp-json\/wp\/v2\/pages\/11786","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.multitech.net\/developer\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/www.multitech.net\/developer\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/www.multitech.net\/developer\/wp-json\/wp\/v2\/users\/1337"}],"replies":[{"embeddable":true,"href":"https:\/\/www.multitech.net\/developer\/wp-json\/wp\/v2\/comments?post=11786"}],"version-history":[{"count":60,"href":"https:\/\/www.multitech.net\/developer\/wp-json\/wp\/v2\/pages\/11786\/revisions"}],"predecessor-version":[{"id":23228,"href":"https:\/\/www.multitech.net\/developer\/wp-json\/wp\/v2\/pages\/11786\/revisions\/23228"}],"up":[{"embeddable":true,"href":"https:\/\/www.multitech.net\/developer\/wp-json\/wp\/v2\/pages\/8462"}],"wp:attachment":[{"href":"https:\/\/www.multitech.net\/developer\/wp-json\/wp\/v2\/media?parent=11786"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}