Hello All,

Here is my setup and what I observe:

An intel i350 NIC with two RJ45 Ports is connected to a simple 4 Core PC with 
Linux (Ubuntu 20). A cable is connected between the two ports (this is what I 
call a loopback connection). When I run a PTP Source (Master) on one port and a 
PTP Sink (Slave) on the other with the latter in free_running mode, I see that 
the Sink reports a constant offset - for a test I ran for 3 hours. Since I dont 
adjust the time or frequency on the sink port, and I get a constant offset for 
an extended period of time, I assume that the clocks on both the ports are 
running on the same Oscillator (what the Datasheet seems to suggest as well). 
Is this assumption correct?

The reported offset value changes every time I reboot. It also changes after I 
assign each port to a separate namespace.


What I want to do:

Now I want to find this offset value without running PTP4l because the Loopback 
connection will be done with a DUT in the middle. Assuming that the offset 
between the two ports is constant, I assume that a mechanism that gets the 
clock values from the two ports repeatedly and one after the other should help 
in finding this value.

However, trying to reuse the pieces of code from phc2sys.c "read_phc" did not 
give satisfactory results.


Here is my rough piece of code.


static int64_t read_phc_offsets(clockid_t clkid1, clockid_t clkid2)
{
struct timespec tdst1, tdst2, tsrc;
int i;
int64_t interval, best_interval = INT64_MAX;
int readings = 10;
int64_t offset,ts;
/* Pick the quickest clkid reading. */
for (i = 0; i < readings; i++) {
if (clock_gettime(clkid2, &tdst1) ||
clock_gettime(clkid1, &tsrc) ||
clock_gettime(clkid2, &tdst2)) {
printf("Failed to read clock");
return 0;
}

interval = (tdst2.tv_sec - tdst1.tv_sec) * NS_PER_SEC +
tdst2.tv_nsec - tdst1.tv_nsec;

if (best_interval > interval) {
best_interval = interval;
offset = ((tdst1.tv_sec - tsrc.tv_sec) * NS_PER_SEC) + (tdst1.tv_nsec - 
tsrc.tv_nsec);
ts = tdst2.tv_sec * NS_PER_SEC + tdst2.tv_nsec;
}
}
ts = best_interval;
return offset;
}


Where clkid1 is the Clock ID of the first port and clkid2 is the Clock ID of 
the second port.


I know that PPS loopback is probably the best way going forward - but i was 
wondering if there is any easier and more obvious way that I am missing out.


Best Regards

Yash Deshpande



Yash Deshpande
Lehrstuhl für Kommunikationsnetze
Technische Universität München
Arcisstr. 21, 80333 München

Fon: +49 89 289 23511
yash.deshpa...@tum.de
www.lkn.ei.tum.de<http://www.lkn.ei.tum.de>
_______________________________________________
Linuxptp-users mailing list
Linuxptp-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linuxptp-users

Reply via email to