* New translations index.md (Korean) * New translations payload.md (Korean) * New translations traffic_management.md (Korean) * New translations define_xml_element.md (Korean) * New translations mavlink_version.md (Korean) * New translations index.md (Korean) * New translations faq.md (Korean) * New translations contributing.md (Korean) * New translations generate_libraries.md (Korean) * New translations installation.md (Korean) * New translations mavlink_2.md (Korean) * New translations message_signing.md (Korean) * New translations packet_loss.md (Korean) * New translations serialization.md (Korean) * New translations wireshark.md (Korean) * New translations xml_schema.md (Korean) * New translations crc.md (Korean) * New translations index.md (Korean) * New translations howto_requestmessages.md (Korean) * New translations mission.md (Korean) * New translations offboard_control.md (Korean) * New translations parameter.md (Korean) * New translations timesync.md (Korean) * New translations arm_authorization.md (Korean) * New translations battery.md (Korean) * New translations camera_v1.md (Korean) * New translations command.md (Korean) * New translations events.md (Korean) * New translations gimbal_v2.md (Korean) * New translations component_metadata.md (Korean) * New translations index.md (Chinese Simplified) * New translations payload.md (Chinese Simplified) * New translations traffic_management.md (Chinese Simplified) * New translations define_xml_element.md (Chinese Simplified) * New translations mavlink_version.md (Chinese Simplified) * New translations index.md (Chinese Simplified) * New translations faq.md (Chinese Simplified) * New translations contributing.md (Chinese Simplified) * New translations generate_libraries.md (Chinese Simplified) * New translations installation.md (Chinese Simplified) * New translations mavlink_2.md (Chinese Simplified) * New translations message_signing.md (Chinese Simplified) * New translations packet_loss.md (Chinese Simplified) * New translations serialization.md (Chinese Simplified) * New translations wireshark.md (Chinese Simplified) * New translations xml_schema.md (Chinese Simplified) * New translations crc.md (Chinese Simplified) * New translations index.md (Chinese Simplified) * New translations howto_requestmessages.md (Chinese Simplified) * New translations mission.md (Chinese Simplified) * New translations offboard_control.md (Chinese Simplified) * New translations parameter.md (Chinese Simplified) * New translations timesync.md (Chinese Simplified) * New translations arm_authorization.md (Chinese Simplified) * New translations battery.md (Chinese Simplified) * New translations camera_v1.md (Chinese Simplified) * New translations command.md (Chinese Simplified) * New translations events.md (Chinese Simplified) * New translations gimbal_v2.md (Chinese Simplified) * New translations component_metadata.md (Chinese Simplified) * New translations common.md (Korean) * New translations common.md (Chinese Simplified)
4.9 KiB
Time Synchronization Protocol v2
This protocol is used to synchronize clocks on MAVLink components by estimating their time offset.
The protocol uses just one message TIMESYNC, which has two int64_t fields: tc1 and ts1.
A component that wants to synchronize clocks sends out a TIMESYNC request with its current timestamp in ts1.
A remote system that supports the protocol sends a TIMESYNC response, including both the original timestamp and its own timestamp.
The original system can use this information to determine the round-trip time, and estimate the timestamp offset.
This sequence is run multiple times and filtered/averaged to reduce the transient effects of the channel and processor usage on the offset calculation.
:::info This version replaces Time Synchronization Protocol v1. :::
Message/Enum Summary
| 消息 | 描述 |
|---|---|
| TIMESYNC | Time synchronization message. |
Sequences
The sequence is:
-
A component that needs time synchronization sends a
TIMESYNCrequest that includes its current nanosecond timestamp ints1(andtc1 = 0, indicating it is a request). This message may be broadcast, or targeted to a particular component. -
A component that receives a
TIMESYNCrequest (TIMESYNC.tc1 == 0) responds with aTIMESYNCresponse (tc1 ≠ 0) that includes the original timestamp from the request ints1(mirrored), and its own timestamp intc1. -
When the synchronizing component gets a
TIMESYNCresponse with its owntarget_systemandtarget_componentit knows it is a reply to a timesync request that it sent.From the message the system can:
- determine the round trip time (by comparing its current timestamp with the original stamp that was returned in the message in
ts1). - estimate the offset between system timestamps, using the round trip time and the timestamp sent back by the remote system.
::: info TIMESYNC` responses to the broadcast address indicate that the remote system supports Time Synchronization Protocol v1. Synchronization may be unreliable if there are multiple synchronising components on the network (report/log an error and upgrade the remote system). The component should ignore responses to all other addresses. :::
- determine the round trip time (by comparing its current timestamp with the original stamp that was returned in the message in
The offset is an estimate because the time spent, both inbound and outbound, will change over time based on things like link congestion and processing time. Therefore the above sequence might be run a significant number of times, and filtering used to remove outlying estimates. Therefore the above sequence might be run a significant number of times, and filtering used to remove outlying estimates.
A graph showing the "noise" when estimating the offset is given below (from PX4).
Time Synchronization Protocol v1
Version 1 of the timesync protocol uses the same message and sequences as version 2.
The difference is the TIMESYNC message in version 1 did not have target_system and target_component fields, and so the message was always broadcast.
This could result in unreliable timesync if there are multiple synchronizing components on the network, because there is no way for a component to know whether a TIMESYNC response is to its request.
:::info
ArduPilot encodes the system id in TIMESYNC.ts1 of the request.
This allows filtering of the response to a particular system (but not component), reducing the risk of clashes.
:::
:::info Version 2 adds the target address, so a syncing system can filter on just the responses to its requests. :::
