我已经开始了解TSN以及开放源码项目Linuxptp在Linux下的使用。
在使用ptp4l和phc2sys脚本同步时钟之后,我想编写简单的Talker应用程序。
如何在执行的应用程序中使用/读取时间戳?
这种同步是如何在多个以太网接口Linux环境下工作的。如果一个端口通过一个以太网端口同步到主时钟,它会同步linux主时钟吗?也就是说,对于一个linux环境,PTP只能同步到一个主?
谢谢!
发布于 2022-04-07 11:51:23
In Time Sensitive Networks there will be 1 Grandmaster(GM) Node and several Slaves nodes
So, How this time synchronization works is that On every boot up all the devices in the network will share their capability information such as their time source, priority values, mac address info etc.,
based on those information shared by all the devices they'll select the most accurate time providing device as Grandmaster(GM)(usually device with GPS as its time source)
Once this is done GM would start sending Sync and Follow Up message which is used by all the Slaves nodes to calculate the time difference between slave node clock and Grandmaster clock
Similarly, Slave nodes would send PDelay Request messages to calculate Link Delay and adjust the Slave Clock to Grandmaster Clock
So, coming to reading the synchronized time from the Slave Node would be through
man page of clock_gettime:
https://linux.die.net/man/3/clock_gettime
// Calculate time taken by a request
struct timespec requestStart, requestEnd;
clock_gettime(CLOCK_REALTIME, &requestStart);
function_call();
clock_gettime(CLOCK_REALTIME, &requestEnd);
https://stackoverflow.com/questions/67042520
复制相似问题