使用 Linuxptp 读取时间戳

reading timestamp using Linuxptp

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

在使用 ptp4l 和 phc2sys 脚本同步时钟后,我想编写简单的 Talker 应用程序。

如何 use/read 已执行应用程序中的时间戳?

此同步如何在多个以太网接口 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);