Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

LoRaWAN Relay implementation #6678

Merged
merged 24 commits into from
Nov 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
05161ea
api: Add initial relay MAC commands
adriansmares Aug 23, 2023
52926fb
api: Add relay metadata
adriansmares Aug 30, 2023
f143a4c
api: Add relay related MAC parameters
adriansmares Aug 30, 2023
962a18b
api: Add relay zero field support
adriansmares Sep 1, 2023
1a16b6a
all: Add relay command marshaling
adriansmares Sep 4, 2023
4f69f99
ns: Implement RelayConfReq
adriansmares Sep 6, 2023
c2230a1
ns: Implement RelayConfigureFwdLimitReq
adriansmares Sep 13, 2023
7efebb9
ns: Implement RelayNotifyNewEndDeviceReq
adriansmares Sep 20, 2023
74900e1
ns: Implement RelayEndDeviceConfReq
adriansmares Sep 6, 2023
a41dbc6
all: Add relay root key derivation
adriansmares Sep 7, 2023
52d93d6
ns: Add BatchGetByID
adriansmares Sep 7, 2023
f022e7b
ns: Sanitize pending requests after downlink generation
adriansmares Sep 7, 2023
7f758e3
ns: Add relay key derivation service
adriansmares Sep 7, 2023
0c447a0
ns: Implement RelayUpdateUplinkListReq
adriansmares Sep 8, 2023
0f18b42
ns: Add relay MAC state generation
adriansmares Sep 8, 2023
fa1f479
api: Add relay fields to allowed field mask
adriansmares Sep 8, 2023
939ba0e
ns: Add relay uplink flow
adriansmares Sep 11, 2023
c8b6d88
all: Support relay metadata
adriansmares Sep 12, 2023
df4f6b3
ns: Add relay session key delivery during join
adriansmares Oct 11, 2023
d1f9617
ns: Relay downlink flow
adriansmares Sep 13, 2023
f65eaaf
ns: Add relay forwarding rule unique index
adriansmares Oct 12, 2023
50d9b17
ns: Implement RelayCtrlUplinkListReq
adriansmares Oct 13, 2023
5e55c0d
ns: Validate relay fields
adriansmares Oct 20, 2023
9036e94
ns: Add zero field checks
adriansmares Oct 20, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
451 changes: 449 additions & 2 deletions api/ttn/lorawan/v3/api.md

Large diffs are not rendered by default.

577 changes: 558 additions & 19 deletions api/ttn/lorawan/v3/api.swagger.json

Large diffs are not rendered by default.

128 changes: 125 additions & 3 deletions api/ttn/lorawan/v3/end_device.proto
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,108 @@ message BoolValue {
bool value = 1;
}

message ServingRelayParameters {
option (thethings.flags.message) = {
select: true,
set: true
};

// Second wake on radio channel configuration.
RelaySecondChannel second_channel = 1;
// Index of the default wake on radio channel.
uint32 default_channel_index = 2 [(validate.rules).uint32.lte = 255];
// Channel activity detection periodicity.
RelayCADPeriodicity cad_periodicity = 3 [(validate.rules).enum.defined_only = true];
message UplinkForwardingRule {
// Bucket configuration for the served end device.
// If unset, no individual limits will apply to the end device, but the relay global limitations will apply.
RelayUplinkForwardLimits limits = 1;
// Last wake on radio frame counter used by the served end device.
uint32 last_w_f_cnt = 2;

// End device identifier of the served end device.
string device_id = 3 [(validate.rules).string = {
pattern: "^[a-z0-9](?:[-]?[a-z0-9]){2,}$",
max_len: 36,
ignore_empty: true
}];
// Session key ID of the session keys used to derive the root relay session key.
bytes session_key_id = 4;
}
// Configured uplink forwarding rules.
repeated UplinkForwardingRule uplink_forwarding_rules = 4 [(validate.rules).repeated.max_items = 16];
message ForwardingLimits {
// Reset behavior of the buckets upon limit update.
RelayResetLimitCounter reset_behavior = 1;
// Bucket configuration for join requests.
// If unset, no individual limits will apply to join requests, but the relay overall limitations will apply.
RelayForwardLimits join_requests = 2;
// Bucket configuration for unknown device notifications.
// If unset, no individual limits will apply to unknown end device notifications, but the relay overall
// limitations will still apply.
RelayForwardLimits notifications = 3;
// Bucket configuration for uplink messages across all served end devices.
// If unset, no individual limits will apply to uplink messages across all served end devices, but the relay
// overall limitations will still apply.
RelayForwardLimits uplink_messages = 4;
// Bucket configuration for all relay messages.
// If unset, no overall limits will apply to the relay, but individual limitations will still apply.
RelayForwardLimits overall = 5;
}
// Configured forwarding limits.
// If unset, the default value from Network Server configuration will be used.
ForwardingLimits limits = 5;
}

message ServedRelayParameters {
option (thethings.flags.message) = {
select: true,
set: true,
semantical: true
};

oneof mode {
option (validate.required) = true;

// The end device will always attempt to use the relay mode in order to send uplink messages.
RelayEndDeviceAlwaysMode always = 1;
// The end device will attempt to use relay mode only after a number of uplink messages have been sent without
// receiving a valid a downlink message.
RelayEndDeviceDynamicMode dynamic = 2;
// The end device will control when it uses the relay mode. This is the default mode.
RelayEndDeviceControlledMode end_device_controlled = 3;
}
// Number of uplinks to be sent without a wake on radio frame.
uint32 backoff = 4 [(validate.rules).uint32.lte = 63];
// Second wake on radio channel configuration.
RelaySecondChannel second_channel = 5;

// End device identifier of the serving end device.
string serving_device_id = 6 [(validate.rules).string = {
pattern: "^[a-z0-9](?:[-]?[a-z0-9]){2,}$",
max_len: 36
}];
}

// RelayParameters represent the parameters of a relay.
// This is used internally by the Network Server.
message RelayParameters {
option (thethings.flags.message) = {
select: true,
set: true,
semantical: true
};

oneof mode {
option (validate.required) = true;

// Parameters related to a relay which is serving end devices.
ServingRelayParameters serving = 25;
// Parameters related to an end device served by a relay.
ServedRelayParameters served = 26;
}
}

// MACParameters represent the parameters of the device's MAC layer (active or desired).
// This is used internally by the Network Server.
message MACParameters {
Expand Down Expand Up @@ -162,10 +264,10 @@ message MACParameters {
repeated Channel channels = 19 [(validate.rules).repeated.min_items = 1];

// Whether uplink dwell time is set (400ms).
// If this field is not set, then the value is either unknown or irrelevant(Network Server cannot modify it).
// If unset, then the value is either unknown or irrelevant(Network Server cannot modify it).
BoolValue uplink_dwell_time = 20;
// Whether downlink dwell time is set (400ms).
// If this field is not set, then the value is either unknown or irrelevant(Network Server cannot modify it).
// If unset, then the value is either unknown or irrelevant(Network Server cannot modify it).
BoolValue downlink_dwell_time = 21;

// ADR: number of messages to wait before setting ADRAckReq.
Expand All @@ -174,6 +276,9 @@ message MACParameters {
ADRAckDelayExponentValue adr_ack_delay_exponent = 23;
// Data rate index of the class B ping slot.
DataRateIndexValue ping_slot_data_rate_index_value = 24;

// Relay parameters.
RelayParameters relay = 25;
}

// Template for creating end devices.
Expand Down Expand Up @@ -443,6 +548,14 @@ message MACSettings {
// This option can be used in order to disable any downlink interaction with the end device. It will affect all types
// of downlink messages: data and MAC downlinks, and join accepts.
BoolValue schedule_downlinks = 35;

// The relay parameters the end device is using.
// If unset, the default value from Network Server configuration or regional parameters specification will be used.
RelayParameters relay = 36;

// The relay parameters the Network Server should configure device to use via MAC commands.
// If unset, the default value from Network Server configuration or regional parameters specification will be used.
RelayParameters desired_relay = 37;
}

// MACState represents the state of MAC layer of the device.
Expand Down Expand Up @@ -574,7 +687,11 @@ message MACState {
reserved 1 to 10;
}
PacketBrokerMetadata packet_broker = 18;
reserved 2 to 8, 10, 12, 13, 16, 17, 19, 20, 99;
message RelayMetadata {
reserved 1 to 3;
}
RelayMetadata relay = 23;
reserved 2 to 8, 10, 12, 13, 16, 17, 19, 20, 21, 22, 99;
}
repeated RxMetadata rx_metadata = 5;
google.protobuf.Timestamp received_at = 6;
Expand Down Expand Up @@ -665,6 +782,11 @@ message MACState {
// The Network Server may choose to store only certain types of MAC
// command identifiers in the underlying implementation.
repeated MACCommandIdentifier recent_mac_command_identifiers = 23;

// Pending relay downlink contents.
// The pending downlink will be scheduled to the relay in either Rx1 or Rx2.
// The pending downlink will be cleared after the scheduling attempt.
RelayForwardDownlinkReq pending_relay_downlink = 24;
}

// Power state of the device.
Expand Down
Loading
Loading