@@ -376,10 +376,10 @@ void Gptp::processFollowUp(Packet *packet, const GptpFollowUp* gptp)
376
376
void Gptp::synchronize ()
377
377
{
378
378
simtime_t now = simTime ();
379
- clocktime_t origNow = clock->getClockTime ();
380
- clocktime_t residenceTime = origNow - syncIngressTimestamp;
379
+ clocktime_t oldLocalTimeAtTimeSync = clock->getClockTime ();
380
+ clocktime_t residenceTime = oldLocalTimeAtTimeSync - syncIngressTimestamp;
381
381
382
- emit (timeDifferenceSignal, CLOCKTIME_AS_SIMTIME (origNow ) - now);
382
+ emit (timeDifferenceSignal, CLOCKTIME_AS_SIMTIME (oldLocalTimeAtTimeSync ) - now);
383
383
384
384
/* ************* Time synchronization *****************************************
385
385
* Local time is adjusted using peer delay, correction field, residence time *
@@ -393,19 +393,20 @@ void Gptp::synchronize()
393
393
if (oldPeerSentTimeSync == -1 )
394
394
gmRateRatio = 1 ;
395
395
else
396
- gmRateRatio = (peerSentTimeSync - oldPeerSentTimeSync) / (origNow - newLocalTimeAtTimeSync) ;
396
+ gmRateRatio = (peerSentTimeSync - oldPeerSentTimeSync) / (syncIngressTimestamp - receivedTimeSync) ;
397
397
398
398
auto settableClock = check_and_cast<SettableClock *>(clock.get ());
399
399
ppm newOscillatorCompensation = unit (gmRateRatio * (1 + unit (settableClock->getOscillatorCompensation ()).get ()) - 1 );
400
400
settableClock->setClockTime (newTime, newOscillatorCompensation, true );
401
401
402
- oldLocalTimeAtTimeSync = origNow;
403
402
newLocalTimeAtTimeSync = clock->getClockTime ();
403
+ timeDiffAtTimeSync = newLocalTimeAtTimeSync - oldLocalTimeAtTimeSync;
404
404
receivedTimeSync = syncIngressTimestamp;
405
405
406
406
// adjust local timestamps, too
407
- pdelayRespEventIngressTimestamp += newLocalTimeAtTimeSync - oldLocalTimeAtTimeSync;
408
- pdelayReqEventEgressTimestamp += newLocalTimeAtTimeSync - oldLocalTimeAtTimeSync;
407
+ adjustLocalTimestamp (pdelayRespEventIngressTimestamp);
408
+ adjustLocalTimestamp (pdelayReqEventEgressTimestamp);
409
+ adjustLocalTimestamp (receivedTimeSync);
409
410
410
411
/* ************* Rate ratio calculation *************************************
411
412
* It is calculated based on interval between two successive Sync messages *
0 commit comments