Skip to content

DeviceTimeAns timestamp is not corresponding to the specification #5586

@adriansmares

Description

@adriansmares

Summary

References #2471
References #2478
References #5585

The Network Server should not use the Network Server receive time as a response to DeviceTimeReq, but instead the timestamp of the end of the transmission.

Current Situation

The Network Server received timestamp is used:

func HandleDeviceTimeReq(ctx context.Context, dev *ttnpb.EndDevice, msg *ttnpb.UplinkMessage) (events.Builders, error) {
ans := &ttnpb.MACCommand_DeviceTimeAns{
Time: msg.ReceivedAt,
}
dev.MacState.QueuedResponses = append(dev.MacState.QueuedResponses, ans.MACCommand())
return events.Builders{
EvtReceiveDeviceTimeRequest,
EvtEnqueueDeviceTimeAnswer.With(events.WithData(ans)),
}, nil
}

The standard is both misleading and clear regarding this in both the 1.0.3 and 1.0.4 specification:
image

I think that #2471 is caused by the phrasing of 'current Network time', but the below sentence (GPS time at the end of the transmission) should be hopefully clearer.

Why do we need this? Who uses it, and when?

We need this for proper class B support.

Proposed Implementation

This requires #5585 first.

I think we need the following fallback system:

  1. In the presence of a settings.gps_time field, use that.
  2. If not found, walk through the rx_metadata slice and use the first gps_time found.
  3. If not found, use the Network Server receive time.

I think that option 2 can become more sophisticated later on, but for now this should suffice.

cc @johanstokking

Edit:
Also https://github.com/TheThingsNetwork/lorawan-stack/pull/2478/files#diff-9ba913e113eb0e0a51b8c6b091c237d7af5d797e29720b3fea84410ece5a99c5L666-L671 should be reverted, as the handler should run after deduplication.

Contributing

  • I can help by doing more research.
  • I can help by implementing the feature after the proposal above is approved.
  • I can help by testing the feature before it's released.

Code of Conduct

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingc/network serverThis is related to the Network Server

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions