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

Uplink MAC state handling fixes #858

Merged
10 changes: 8 additions & 2 deletions pkg/networkserver/downlink.go
Original file line number Diff line number Diff line change
Expand Up @@ -548,7 +548,7 @@ func downlinkPathsForClassA(rxDelay ttnpb.RxDelay, ups ...*ttnpb.UplinkMessage)
maxDelta := time.Duration(rxDelay) * time.Second
for i := len(ups) - 1; i >= 0; i-- {
up := ups[i]
delta := time.Now().Sub(up.ReceivedAt)
delta := time.Since(up.ReceivedAt)
rx1, rx2 := delta < maxDelta, delta < maxDelta+time.Second
if paths := downlinkPathsFromMetadata(up.RxMetadata...); len(paths) > 0 {
return rx1, rx2, paths
Expand Down Expand Up @@ -722,9 +722,15 @@ loop:
return phy.DataRates[maxUpDRIdx].DefaultMaxSize.PayloadSize(fp.DwellTime.GetUplinks())
}

const gsScheduleWindow = 30 * time.Second
// downlinkRetryInterval is the time interval, which defines the interval between downlink task retries.
const downlinkRetryInterval = time.Second

// gsScheduleWindow is the time interval, which is sufficient for GS to ensure downlink is scheduled.
const gsScheduleWindow = 30 * time.Second

// nsScheduleWindow is the time interval, which is sufficient for NS to ensure downlink is scheduled.
var nsScheduleWindow = time.Second

// processDownlinkTask processes the most recent downlink task ready for execution, if such is available or wait until it is before processing it.
// NOTE: ctx.Done() is not guaranteed to be respected by processDownlinkTask.
func (ns *NetworkServer) processDownlinkTask(ctx context.Context) error {
Expand Down
3 changes: 2 additions & 1 deletion pkg/networkserver/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,11 @@ import (
var (
errABPJoinRequest = errors.DefineInvalidArgument("abp_join_request", "received a join-request from ABP device")
errCIDOutOfRange = errors.DefineInvalidArgument("cid_out_of_range", "CID must be in range from {min} to {max}")
errClassAMulticast = errors.DefineInvalidArgument("class_a_multicast", "multicast device in class A mode")
errClassBCForClassA = errors.DefineInvalidArgument("class_b_c_for_class_a", "class B/C downlink queued for device in class A mode")
errComputeMIC = errors.DefineInvalidArgument("compute_mic", "failed to compute MIC")
errConfirmedDownlinkTooSoon = errors.DefineUnavailable("confirmed_too_soon", "confirmed downlink is scheduled too soon")
errConfirmedMulticastDownlink = errors.DefineInvalidArgument("confirmed_multicast_downlink", "confirmed downlink queued for multicast device")
errClassBCForClassA = errors.DefineInvalidArgument("class_b_c_for_class_a", "class B/C downlink queued for device in class A mode")
errCorruptedMACState = errors.DefineCorruption("corrupted_mac_state", "MAC state is corrupted")
errDataRateNotFound = errors.DefineNotFound("data_rate_not_found", "data rate not found")
errDecodePayload = errors.DefineInvalidArgument("decode_payload", "failed to decode payload")
Expand Down
3 changes: 0 additions & 3 deletions pkg/networkserver/grpc_asns_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,11 @@ import (
"go.thethings.network/lorawan-stack/pkg/networkserver/redis"
"go.thethings.network/lorawan-stack/pkg/rpcmetadata"
"go.thethings.network/lorawan-stack/pkg/ttnpb"
"go.thethings.network/lorawan-stack/pkg/types"
"go.thethings.network/lorawan-stack/pkg/unique"
"go.thethings.network/lorawan-stack/pkg/util/test"
"go.thethings.network/lorawan-stack/pkg/util/test/assertions/should"
)

func eui64Ptr(eui types.EUI64) *types.EUI64 { return &eui }

func TestLinkApplication(t *testing.T) {
a := assertions.New(t)

Expand Down
Loading