xl4-shiro / excelfore-gptp

gPTP, IEEE 802.1AS-REV implementation
GNU General Public License v2.0
63 stars 38 forks source link

recommend the algorithm for neighborPropDelay calculation #13

Open liuzuanmin opened 2 years ago

liuzuanmin commented 2 years ago

Thanks the great project firstly, even through I haven't run it all well. The code from project is: rts = (((sm->ppg->forAllDomain->neighborRateRatio)*(int64_t)((sm->t4ts64 - sm->t1ts64)) - (sm->t3ts64 - sm->t2ts64)))/2;

I think neighborRateRatio is miss used, dividing it may be more better, like: rts = (((double)(sm->t4ts64 - sm->t1ts64)/(sm->ppg->forAllDomain->neighborRateRatio)) - (sm->t3ts64 - sm->t2ts64))/2; since neighborRateRatio is calculated by the following simply expression: neighborRateRation = (t1 - t1_prev) / (t2 - t2_prev) t1 && t1_prev is the slave freq time t2 && t2_prev is the master freq time so ((double)(sm->t4ts64 - sm->t1ts64)/(sm->ppg->forAllDomain->neighborRateRatio)) converts the slave time-diff to master time-diff, then the following subtract is meaning.

Expect your feedback sincerely.

xl4-shiro commented 2 years ago

Thank you for the comment. You are right, we made a mistake. the mistake is not in the pdelay calculation, but in the neighborRateRatio calculation.

We will change, from this wrong formula pDelayRateRatio = (double)(sm->t1ts64-sm->prev_t1ts64)/(sm->t2ts64-sm->prev_t2ts64); to this corrected one. pDelayRateRatio = (double)(sm->t2ts64-sm->prev_t2ts64)/(sm->t1ts64-sm->prev_t1ts64);

liuzuanmin commented 2 years ago

absolutely agree!

Thank you for the comment. You are right, we made a mistake. the mistake is not in the pdelay calculation, but in the neighborRateRatio calculation.

We will change, from this wrong formula pDelayRateRatio = (double)(sm->t1ts64-sm->prev_t1ts64)/(sm->t2ts64-sm->prev_t2ts64); to this corrected one. pDelayRateRatio = (double)(sm->t2ts64-sm->prev_t2ts64)/(sm->t1ts64-sm->prev_t1ts64);