# A LoRa-Based Linear Sensor Network for Location Data in Underground Mining
## 3 System Implementation and Trials
### Design
Although this prevents the endless transmission of the same message it introduces another problem when a tag restarts and the sequence number information is lost. A tag that restarts and sends messages with a lower sequence number than recorded by the relays will have its messages ignored. Consequently, our approach is for each tag, when it restarts, to first send a Reset message to all other nodes. Reset messages cause relays to reset to zero the sequence number recorded for the tag it originated from. It is important to note that Reset messages need to be forwarded regardless of their own sequence number. Unfortunately, without a further mechanism, Reset messages will cause a broadcast storm. We address this problem by including a time-to-live (TTL) field within each message. A message is given a ttl value when it is created. Whenever a relay receives the message its TTL is decremented. Once the TTL reaches zero the message is discarded. There may be some concern that using LoRa in this way may result in interference with other underground systems. This is very unlikely. Underground mining data communications is dominated by IEEE 802.11 WiFi transmitting at 2.4 GHz. Underground voice is a VHF radio-based operating at 148 to 178 MHz. We used LoRa transmitters and receivers operating in the 915 MHz bands. Other frequencies LoRa operates at are 433 MHz and 815 MHz. None of these are likely to interfere with other underground communications. The third design decision is that contention is managed through a simplified CSMA scheme where nodes monitor the wireless medium until it becomes silent and then wait a random interval before transmitting. Some form of carrier sensing is necessary because there will inevitably be occasions when multiple tags or relays in the same coverage area have a message whose transmission times overlap. Yet a sophisticated scheme such a CSMA/CA (Carrier Sense Multiple Access/Collision Avoidance) is unnecessary. Consequently, this network uses a simpler scheme. The node listens for the medium to go silent and waits a random interval of time before transmitting. Despite its simplicity there is the issue of how long tags and relays should wait. A large waiting time reduces the risk of collisions but messages that arrive during that time are ignored. A short waiting time means messages are less likely to be dropped but makes collisions more likely. Determining an optimal waiting time is a challenging issue which we have noted is an area for future research. We somewhat arbitrarily chose an exponentially distributed waiting time with mean of 100 ms. With a bit rate of 21,875 bps and thirty byte messages his means that each message takes a mean of 111 ms to forward which gives us a service rate of nine messages per second. The following pseudo-code describes the relay implementation. ```
whiletruedo begin whilechannelisidle monitorchannelformessage; uponreceiptofamessage ifmessage.typeeqReset tag[message.tag].sequence:=0; ifmessage.sequence<tag[message.tag].sequence discardmessage; else ifmessage.ttleq0 discardmessage else begin message.ttl:=message.ttl-1; wait(exponentiallydistributedrandomamountoftime,mean100 ms) end transmit(message); end
```