D.2 Clock skew estimation algorithm

26.1323GPPRelease 18Speech and video telephony terminal acoustic test specificationTS

function Skew = EstimatePPM(DelayVsTime, StepSize, DiffMaxPPM=500)

  % Difference threshold from which on a difference is assumed to be a packet

  % loss or insertion.  With larger step sizes, the normal clock skew

  % results in higher differences between steps and therefore requires a

  % larger threshold.

  DelayDiffThreshold = min( max( DiffMaxPPM*1e-6*StepSize, 1e-3 ), 4e-3 );

  % Calculate median filter of length 3 to smooth away small spikes without

  % soften the steps.

  DelayMedian = DelayVsTime(:);

  for i = 2:numel(DelayVsTime)-1

    DelayMedian(i) = median(DelayVsTime(i-1:i+1));


  % Calculate delay difference per time step.

  DelayDiff = diff( DelayMedian );

  % Exclude all indices with high delay differences as well as some

  % transition range before and after.

  Mask = true(size(DelayDiff));

  Jumps = find( abs(DelayDiff) > DelayDiffThreshold );

  for i = 1:length(Jumps)

    Mask(Jumps(i)-1:Jumps(i)+1) = false;


  % Generate "continuous" delay vs. time series

  Delay = [ 0; cumsum( DelayDiff(Mask) ) ];

  Time = ( 0:numel(Delay)-1)’;

  % Estimate clock skew in PPM as slope of linear regression line

  P = polyfit( Time, Delay, 1 );

  Skew = P(1) / StepSize * 1e6;

Annex E (normative):
Packet delay and loss profiles for UE delay testing of MTSI-based speech with LTE access