4.3 MAC Payload of Data Messages (MACPayload)

  1. The MAC payload of the data messages, a so-called ―data frame‖, contains a frame header

3 (FHDR) followed by an optional port field (FPort) and an optional frame payload field

  1. (FRMPayload).

4.3.1 Frame header (FHDR)

  1. The FHDR contains the short device address of the end-device (DevAddr), a frame control
  2. octet (FCtrl), a 2-octets frame counter (FCnt), and up to 15 octets of frame options (FOpts)
  3. used to transport MAC commands.

9

Size (bytes) 4 1 2 0..15
FHDR DevAddr FCtrl FCnt FOpts

10 For downlink frames the FCtrl content of the frame header is:

Bit# 7 6 5 4 [3..0]
FCtrl bits ADR RFU ACK FPending FOptsLen

11 For uplink frames the FCtrl content of the frame header is:

Bit# 7 6 5 4 [3..0]
FCtrl bits ADR ADRACKReq ACK RFU FOptsLen
  1. 4.3.1.1 Adaptive data rate control in frame header (ADR, ADRACKReq in FCtrl)
  2. LoRa network allows the end-devices to individually use any of the possible data rates. This
  3. feature is used by the LoRaWAN to adapt and optimize the data rate of static end-devices.
  4. This is referred to as Adaptive Data Rate (ADR) and when this is enabled the network will be
  5. optimized to use the fastest data rate possible.

17 Adaptive Data Rate control may not be possible when the radio channel attenuation

  1. changes fast and constantly. When the network is unable to control the data rate of a device
  2. , the device‘s application layer should control it. It is recommended to use a variety of
  3. different data rates in this case. The application layer should always try to minimize the
  4. aggregated air time used given the network conditions.
  5. If the ADR bit is set, the network will control the data rate of the end-device through the
  6. appropriate MAC commands. If the ADR bit is not set, the network will not attempt to control
  7. the data rate of the end-device regardless of the received signal quality. The ADR bit may
  8. be set and unset by the end-device or the Network on demand. However, whenever
  9. possible, the ADR scheme should be enabled to increase the battery life of the end-device
  10. and maximize the network capacity.
28 Note: Even mobile end-devices are actually immobile most of the time.
29 So depending on its state of mobility, an end-device can request the
30 network to optimize its data rate using ADR.
  1. If an end-device whose data rate is optimized by the network to use a data rate higher than
  2. its lowest available data rate, it periodically needs to validate that the network still receives
  3. the uplink frames. Each time the uplink frame counter is incremented (for each new uplink,
34 repeated transmissions do not increase the counter), the device increments an
35 ADR_ACK_CNT counter. After ADR_ACK_LIMIT uplinks (ADR_ACK_CNT >=
  1. ADR_ACK_LIMIT) without any downlink response, it sets the ADR acknowledgment request
  2. bit (ADRACKReq). The network is required to respond with a downlink frame within the
  3. next ADR_ACK_DELAY frames, any received downlink frame following an uplink frame

©2016 LoRa™ Alliance Page 16 of 70

The authors reserve the right to change specifications without notice.

LoRaWAN Specification
1 resets the ADR_ACK_CNT counter. The downlink ACK bit does not need to be set as any
2 response during the receive slot of the end-device indicates that the gateway has still
3 received the uplinks from this device. If no reply is received within the next
  1. ADR_ACK_DELAY uplinks (i.e., after a total of ADR_ACK_LIMIT + ADR_ACK_DELAY), the
  2. end-device may try to regain connectivity by switching to the next lower data rate that
  3. provides a longer radio range. The end-device will further lower its data rate step by step
  4. every time ADR_ACK_DELAY is reached. The ADRACKReq shall not be set if the device
  5. uses its lowest available data rate because in that case no action can be taken to improve
  6. the link range.
10 Note: Not requesting an immediate response to an ADR
11 acknowledgement request provides flexibility to the network to
12 optimally schedule its downlinks.
13
14 Note: In uplink transmissions the ADRACKReq bit is set if
15 ADR_ACK_CNT >= ADR_ACK_LIMIT and the current data-rate is
16 greater than the device defined minimum data rate, it is cleared in
17 other conditions.
  1. 4.3.1.2 Message acknowledge bit and acknowledgement procedure (ACK in FCtrl)
  2. When receiving a confirmed data message, the receiver shall respond with a data frame that
  3. has the acknowledgment bit (ACK) set. If the sender is an end-device, the network will send
  4. the acknowledgement using one of the receive windows opened by the end-device after the
  5. send operation. If the sender is a gateway, the end-device transmits an acknowledgment at
  6. its own discretion.
  7. Acknowledgements are only sent in response to the latest message received and are never
  8. retransmitted.
26
27 Note: To allow the end-devices to be as simple as possible and have
28 as few states as possible it may transmit an explicit (possibly empty)
29 acknowledgement data message immediately after the reception of a
30 data message requiring a confirmation. Alternatively the end-device
31 may defer the transmission of an acknowledgement to piggyback it
32 with its next data message.
33 4.3.1.3 Retransmission procedure
34 The number of retransmissions (and their timing) for the same message where an
  1. acknowledgment is requested but not received is at the discretion of the end device and
  2. may be different for each end-device.
37 Note: Some example timing diagrams of the acknowledge mechanism
38 are given in Chapter 18.
39
40 Note: If an end-device has reached its maximum number of
41 retransmissions without receiving an acknowledgment, it can try to re-
42 gain connectivity by moving to a lower data rate with longer reach. It is
43 up to the end-device to retransmit the message again or to forfeit that
44 message and move on.
45
©2016 LoRa™ Alliance Page 17 of 70 The authors reserve the right to change
specifications without notice.
LoRaWAN Specification
1 Note: If the network server has reached its maximum number of
2 retransmissions without receiving an acknowledgment, it will generally
3 consider the end-device as unreachable until it receives further
4 messages from the end-device. It is up to the network server to
5 retransmit the message once connectivity to the end-device in question
6 is regained or to forfeit that message and move on.
7
8 Note: The recommended data rate back-off strategy during re-
9 transmissions is described in Chapter 18.4
  1. 4.3.1.4 Frame pending bit (FPending in FCtrl, downlink only)
  2. The frame pending bit (FPending) is only used in downlink communication, indicating that
  3. the gateway has more data pending to be sent and therefore asking the end-device to open
  4. another receive window as soon as possible by sending another uplink message.
  5. The exact use of FPending bit is described in Chapter 18.3.
  6. 4.3.1.5 Frame counter (FCnt)
  7. Each end-device has two frame counters to keep track of the number of data frames sent
  8. uplink to the network server (FCntUp), incremented by the end-device and received by the
  9. end-device downlink from the network server (FCntDown), which is incremented by the
  10. network server. The network server tracks the uplink frame counter and generates the
  11. downlink counter for each end-device. After a JoinReq – JoinAccept message exchange or
  12. a reset for a personalized end-device, the frame counters on the end-device and the frame
  13. counters on the network server for that end-device are reset to 0. Subsequently FCntUp and
  14. FCntDown are incremented at the sender side by 1 for each new data frame sent in the
  15. respective direction. At the receiver side, the corresponding counter is kept in sync with the

25 value received provided the value received has incremented compared to the current

  1. counter value and is less than the value specified by MAX_FCNT_GAP1 after considering
  2. counter rollovers. If this difference is greater than the value of MAX_FCNT_GAP then too
  3. many data frames have been lost then subsequent will be discarded. The FCnt is not
  4. incremented in case of multiple transmissions of an unconfirmed frame (see NbTrans
  5. parameter), or in the case of a confirmed frame that is not acknowledged.
  6. The LoRaWAN allows the use of either 16-bits or 32-bits frame counters. The network side
  7. needs to be informed out-of-band about the width of the frame counter implemented in a
  8. given end-device. If a 16-bits frame counter is used, the FCnt field can be used directly as
  9. the counter value, possibly extended by leading zero octets if required. If a 32-bits frame
  10. counter is used, the FCnt field corresponds to the least-significant 16 bits of the 32-bits
  11. frame counter (i.e., FCntUp for data frames sent uplink and FCntDown for data frames sent
  12. downlink).
  13. The end-device shall not reuse the same FCntUp value, except for retransmission, with the
  14. same application and network session keys.

1 Actual value for MAX_FCNT_GAP, RECEIVE_DELAY1 and RECEIVE_DELAY2 can be found at

Error! Reference source not found. for EU863-870 or Error! Reference source not found. forUS902-928.

©2016 LoRa™ Alliance Page 18 of 70

The authors reserve the right to change specifications without notice.

LoRaWAN Specification
1 Note: Since the FCnt field carries only the least-significant 16 bits of
2 the 32-bits frame counter, the server must infer the 16 most-significant
3 bits of the frame counter from the observation of the traffic.
  1. 4.3.1.6 Frame options (FOptsLen in FCtrl, FOpts)
  2. The frame-options length field (FOptsLen) in FCtrl byte denotes the actual length of the
  3. frame options field (FOpts) included in the frame.
  4. FOpts transport MAC commands of a maximum length of 15 octets that are piggybacked
  5. onto data frames; see Chapter 5 for a list of valid MAC commands.
  6. If FOptsLen is 0, the FOpts field is absent. If FOptsLen is different from 0, i.e. if MAC
  7. commands are present in the FOpts field, the port 0 cannot be used (FPort must be either
  8. not present or different from 0).
  9. MAC commands cannot be simultaneously present in the payload field and the frame
  10. options field. Should this occur, the device shall ignore the frame.

4.3.2 Port field (FPort)

  1. If the frame payload field is not empty, the port field must be present. If present, an FPort
  2. value of 0 indicates that the FRMPayload contains MAC commands only; see Chapter 4.4
  3. for a list of valid MAC commands. FPort values 1..223 (0x01..0xDF) are application-
  4. specific. FPort value 224 is dedicated to LoRaWAN Mac layer test protocol.
19 Note : The purpose of Fport value 224 is to provide a dedicated Fport
20 to run Mac compliance test scenarios over-the-air on final versions of
21 devices, without having to rely on specific test versions of devices for
22 practical aspects. The test is not supposed to be simultaneous with live
23 operations, but the Mac layer implementation of the device shall be
24 exactly the one used for the normal application. The test protocol is
25 normally encrypted using the AppSKey. This ensures that the network
26 cannot enable the device‘s test mode without involving the device‘s
27 owner. If the test runs on a live network connected device, the way the
28 test application on the network side learns the AppSkey is outside of
29 the scope of the LoRaWAN specification. If the test runs using OTAA
30 on a dedicated test bench (not a live network), the way the Appkey is
31 communicated to the test bench, for secured JOIN process, is also
32 outside of the scope of the specification.
33 The test protocol, running at application layer, is defined outside of the
34 LoRaWAN spec, as it is an application layer protocol.
35
36 FPort values 225..255 (0xE1..0xFF) are reserved for future standardized application
37 extensions.
38
Size (bytes) 7..22 0..1 0..N
MACPayload FHDR FPort FRMPayload
  1. N is the number of octets of the application payload. The valid range for N is region specific
  2. and is defined in the LoRaWAN Regional Parameters document [PARAMS].
  3. N should be equal or smaller than:

42 NM - 1 - (length ofFHDRin octets)

©2016 LoRa™ Alliance Page 19 of 70

The authors reserve the right to change specifications without notice.

LoRaWAN Specification

  1. where M is the maximum MAC payload length.

4.3.3 MAC Frame Payload Encryption (FRMPayload)

  1. If a data frame carries a payload, FRMPayload must be encrypted before the message
  2. integrity code (MIC) is calculated.

5 The encryption scheme used is based on the generic algorithm described in IEEE

  1. 802.15.4/2006 Annex B [IEEE802154] using AES with a key length of 128 bits.
  2. The key K used depends on the FPort of the data message:

8

FPort K
0 NwkSKey
9 1..255 AppSKey
Table 3: FPort list
  1. The fields encrypted are:
  2. pld =FRMPayload
  3. For each data message, the algorithm defines a sequence of Blocks Ai for i = 1..k with k =
  4. ceil(len(pld) / 16):
Size (bytes) 1 4 1 4 4 1 1
Ai 0x01 4 x 0x00 Dir DevAddr FCntUp or 0x00 i
FCntDown
  1. The direction field (Dir) is 0 for uplink frames and 1 for downlink frames.
  2. The blocks Ai are encrypted to get a sequence S of blocks Si:

16

  1. Si = aes128encrypt(K, _Ai) for i = 1..k
  2. S = S1 | S2 | .. | Sk
  3. Encryption and decryption of the payload is done by truncating
  4. (pld | pad16) xor S
  5. to the first len(pld) octets.

results matching ""

    No results matching ""