使用Linuxptp读取时间戳



我已经开始学习TSN以及开源项目Linuxptp在Linux下的使用。

我想写一个简单的Talker应用程序,在使用ptp4l&phc2sys脚本。

如何在执行的应用程序中使用/读取时间戳?

这种同步是如何在多个以太网接口Linux环境下工作的。如果一个端口通过一个以太网端口同步到主时钟,它会同步linux主时钟吗?对于一个linux环境,PTP只能同步到一个Master?

谢谢!

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);

最新更新