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:

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:
- In the presence of a
settings.gps_time field, use that.
- If not found, walk through the
rx_metadata slice and use the first gps_time found.
- 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
Code of Conduct
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:
lorawan-stack/pkg/networkserver/mac/device_time.go
Lines 34 to 43 in 70d88dd
The standard is both misleading and clear regarding this in both the 1.0.3 and 1.0.4 specification:

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:
settings.gps_timefield, use that.rx_metadataslice and use the firstgps_timefound.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
Code of Conduct