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

Emit Packet Error Rate as part of the uplink messages #7048

Merged
merged 2 commits into from Apr 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions api/ttn/lorawan/v3/api.md
Expand Up @@ -8183,6 +8183,7 @@ Application uplink message.
| `last_a_f_cnt_down` | [`uint32`](#uint32) | | The last AFCntDown of the current session. This field is only present if the skip_payload_crypto field of the EndDevice is true. Can be used with app_s_key to encrypt downlink payloads. |
| `confirmed` | [`bool`](#bool) | | Indicates whether the end device used confirmed data uplink. |
| `consumed_airtime` | [`google.protobuf.Duration`](#google.protobuf.Duration) | | Consumed airtime for the transmission of the uplink message. Calculated by Network Server using the raw payload size and the transmission settings. |
| `packet_error_rate` | [`float`](#float) | | Packet error rate of the recent uplinks in the current session. Calculated by the Network Server. The value is defined in the [0, 1] interval. |
| `locations` | [`ApplicationUplink.LocationsEntry`](#ttn.lorawan.v3.ApplicationUplink.LocationsEntry) | repeated | End device location metadata, set by the Application Server while handling the message. |
| `version_ids` | [`EndDeviceVersionIdentifiers`](#ttn.lorawan.v3.EndDeviceVersionIdentifiers) | | End device version identifiers, set by the Application Server while handling the message. |
| `network_ids` | [`NetworkIdentifiers`](#ttn.lorawan.v3.NetworkIdentifiers) | | Network identifiers, set by the Network Server that handles the message. |
Expand Down
5 changes: 5 additions & 0 deletions api/ttn/lorawan/v3/api.swagger.json
Expand Up @@ -19396,6 +19396,11 @@
"type": "string",
"description": "Consumed airtime for the transmission of the uplink message. Calculated by Network Server using the raw payload size and the transmission settings."
},
"packet_error_rate": {
"type": "number",
"format": "float",
"description": "Packet error rate of the recent uplinks in the current session.\nCalculated by the Network Server. The value is defined in the [0, 1] interval."
},
"locations": {
"type": "object",
"additionalProperties": {
Expand Down
6 changes: 5 additions & 1 deletion api/ttn/lorawan/v3/messages.proto
Expand Up @@ -246,6 +246,10 @@ message ApplicationUplink {
// Consumed airtime for the transmission of the uplink message. Calculated by Network Server using the raw payload size and the transmission settings.
google.protobuf.Duration consumed_airtime = 13;

// Packet error rate of the recent uplinks in the current session.
// Calculated by the Network Server. The value is defined in the [0, 1] interval.
float packet_error_rate = 19;

// End device location metadata, set by the Application Server while handling the message.
map<string, Location> locations = 14;

Expand All @@ -255,7 +259,7 @@ message ApplicationUplink {
// Network identifiers, set by the Network Server that handles the message.
NetworkIdentifiers network_ids = 16;

// next: 19
// next: 20
}

message ApplicationUplinkNormalized {
Expand Down
1 change: 1 addition & 0 deletions pkg/networkserver/grpc_gsns.go
Expand Up @@ -1150,6 +1150,7 @@ func (ns *NetworkServer) handleDataUplink(ctx context.Context, up *ttnpb.UplinkM
Settings: up.Settings,
ReceivedAt: up.ReceivedAt,
ConsumedAirtime: up.ConsumedAirtime,
PacketErrorRate: mac.LossRate(stored.MacState, matched.phy),
NetworkIds: ns.networkIdentifiers(ctx),
},
},
Expand Down
5 changes: 5 additions & 0 deletions pkg/networkserver/mac/adr.go
Expand Up @@ -712,3 +712,8 @@ func AdaptDataRate(ctx context.Context, dev *ttnpb.EndDevice, phy *band.Band, de
}
return adaptDataRate(ctx, dev, phy, defaults)
}

// LossRate calculates the loss rate of the recent uplinks in the provided MAC state.
func LossRate(macState *ttnpb.MACState, phy *band.Band) float32 {
return adrLossRate(adrUplinks(macState, phy)...)
}
2 changes: 2 additions & 0 deletions pkg/ttnpb/applicationserver.pb.paths.fm.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

793 changes: 403 additions & 390 deletions pkg/ttnpb/messages.pb.go

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions pkg/ttnpb/messages.pb.paths.fm.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions pkg/ttnpb/messages.pb.setters.fm.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions pkg/ttnpb/messages.pb.validate.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 13 additions & 0 deletions pkg/ttnpb/messages_flags.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions pkg/ttnpb/messages_json.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions sdk/js/generated/api-definition.json
Expand Up @@ -887,6 +887,7 @@
"up.uplink_message.network_ids.tenant_id",
"up.uplink_message.normalized_payload",
"up.uplink_message.normalized_payload_warnings",
"up.uplink_message.packet_error_rate",
"up.uplink_message.received_at",
"up.uplink_message.rx_metadata",
"up.uplink_message.session_key_id",
Expand Down
12 changes: 12 additions & 0 deletions sdk/js/generated/api.json
Expand Up @@ -36939,6 +36939,18 @@
"oneofdecl": "",
"defaultValue": ""
},
{
"name": "packet_error_rate",
"description": "Packet error rate of the recent uplinks in the current session.\nCalculated by the Network Server. The value is defined in the [0, 1] interval.",
"label": "",
"type": "float",
"longType": "float",
"fullType": "float",
"ismap": false,
"isoneof": false,
"oneofdecl": "",
"defaultValue": ""
},
{
"name": "locations",
"description": "End device location metadata, set by the Application Server while handling the message.",
Expand Down