# A Survey on LoRaWAN Architecture, Protocol and Technologies
## 2 LoRa & LoRaWAN Technologies
### MAC Layer--LoRaWAN
#### 2.4.4 MAC Commands  
LoRaWAN protocol runs a simple control mechanism to coordinate the medium and end-devices through the commands presented in Table 5. MAC commands are identified by an octet identifier called CID (Command Identifier). Each command has a predefined length and has to be identified implicitly by the implementation. _LinkCheckReq_ command is used by end-device to validate network connectivity. _LinkCheckAns_ is replied by the GW including GwCnt indicating the number of GWs received the request successfully. _LinkADDRreq_ is sent from GW through the nodes to adopt a data rate. ADR (Adaptive Data Rate) message contains DataRate and Tx output power TXPower with region specific values. Also, usable uplink channels are encoded using ChMask field in the message. _LinkADRAns_ is sent by end-devices indicating that weather requested DataRate, Tx Power and requested channel states are discarded or successfully implemented. Maximum aggregated (Equation (7)) Duty Cycle is controlled through the \(DutyCycleReq\) request and message contains MaxDCycle in range [0:15] field to be implemented for all sub-bands as. 0 indicated that there is no duty cycle limitation and 255 is off switch to turn off the remote device immediately. \[Aggreaged\ duty\ cycle=\frac{1}{2^{MaxDCycle}} \tag{7}\]  
\(DutyCycleAns\) is a reply to \(DutyCycleReq\) without any payload. \begin{table}
\begin{tabular}{r l} \hline \hline
**MType** & **Description** \\ \hline
000 & Join Request \\
001 & Join Accept \\
010 & Unconfirmed Data Up \\
011 & Unconfirmed Data Down \\
100 & Confirmed Data Up \\
101 & Confirmed Data Down \\
110 & RFU \\
111 & Proprietary \\ \hline \hline \end{tabular}
\end{table} 
Table 4: LoRaWAN MAC Message Types. \begin{table}
\begin{tabular}{r l l l} \hline \hline
**CID** & **Command** & **Transmitted By** & **Description** \\ \hline
0x02 & LinkCheckReq & Node & Connection validation. \\
0x03 & LinkCheckAns & GW & Reply to LinkCheckReq. \\
0x03 & LinkADRreq & GW & Adjust node data rate, tx power, rx rate or channel \\
0x04 & LinkADRAns & Node & Response to LinkADRreq. \\
0x04 & DutyCycleReq & GW & Set tx duty cycle. \\
0x04 & DutyCycleAns & Node & Response DutyCycleReq. \\
0x05 & RXParamSetupReq & GW & Set rx slot parameters. \\
0x05 & RXParamSetupAns & Node & Response KRYParamSetupReq. \\
0x06 & DevStatusRep & GW & Request status of node. \\
0x06 & DevStatusAns & Node & Response to DevStatusReq with battery level ad \\
0x07 & NewChannelReq & GW & Setup/modify new radio channel. \\
0x07 & NewChannelAns & Node & Response to NewChannelReq. \\
0x08 & RXTimingSetupReq & GW & Set reception slot timing. \\
0x08 & RXTimingSetupAns & Node & Response to RXTimingSetupReq. \\
0x08-0 xFF & Proprietary & Node/GW & Reserved further extensions. \\ \hline \hline \end{tabular}
\end{table} 
Table 5: LoRaWAN MAC Commands. \(RXParamSetupReq\) controls the second receive window (RX2) data rate and the frequency for each uplink. \(RXParamSetupAns\) contains status bits indicating that configuration is successful or invalid. \(DevStatusReq\) is an empty message is used to check the status of end-devices. End-device replies the message with battery level, modulation margin of SNR ratio with \(DevStatusAns\). The Network Server can modify an existing channel or add a new one with \(NewChannelReq\) request. The message contains central frequency and range of usable data rates as shown in Figure 14. According to the protocol end-devices have to handle 16 different channels indexed through 0 to N \(-\) 1 where N is the number of default channels. ChIndex is the index of the channel being configured. Freq field is 24 bit unsigned integer to refer actual frequency (100\(\times\) Freq). Below 100 MHz reserved for future use cases so, the frequency can be set through 100-1670 MHz with 100 Hz steps. if Freq value set to 0, the channel is disabled. DrRange subfield (in Figure 15) in \(NewChannelReq\) specifies the permitted data range for the given channel with 4 bit indexes. DrRange field has min and max data rates referred to as MinDR, MaxDR.