high precision frequency synchronization via ip networks

103
Institutionen för systemteknik Department of Electrical Engineering Examensarbete High Precision Frequency Synchronization via IP Networks Examensarbete utfört i elektroniksystem vid Tekniska högskolan i Linköping av Andreas Gustafsson Danijel Hir LiTH-ISY-EX--10/4394--SE Linköping 2010 Department of Electrical Engineering Linköpings tekniska högskola Linköpings universitet Linköpings universitet SE-581 83 Linköping, Sweden 581 83 Linköping

Upload: lamkhanh

Post on 31-Dec-2016

226 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: High precision frequency synchronization via IP networks

Institutionen för systemteknikDepartment of Electrical Engineering

Examensarbete

High Precision Frequency Synchronization via IPNetworks

Examensarbete utfört i elektroniksystemvid Tekniska högskolan i Linköping

av

Andreas GustafssonDanijel Hir

LiTH-ISY-EX--10/4394--SE

Linköping 2010

Department of Electrical Engineering Linköpings tekniska högskolaLinköpings universitet Linköpings universitetSE-581 83 Linköping, Sweden 581 83 Linköping

Page 2: High precision frequency synchronization via IP networks
Page 3: High precision frequency synchronization via IP networks

High Precision Frequency Synchronization via IPNetworks

Examensarbete utfört i elektroniksystemvid Tekniska högskolan i Linköping

av

Andreas GustafssonDanijel Hir

LiTH-ISY-EX--10/4394--SE

Handledare: Tomas BornefallEricsson

Examinator: Oscar Gustafssonisy, Linköpings universitet

Linköping, 16 February, 2010

Page 4: High precision frequency synchronization via IP networks
Page 5: High precision frequency synchronization via IP networks

Avdelning, InstitutionDivision, Department

Division of Electronics SystemDepartment of Electrical EngineeringLinköpings universitetSE-581 83 Linköping, Sweden

DatumDate

2010-02-16

SpråkLanguage

� Svenska/Swedish� Engelska/English

RapporttypReport category

� Licentiatavhandling� Examensarbete� C-uppsats� D-uppsats� Övrig rapport�

URL för elektronisk versionhttp://www.es.isy.liu.se

http://urn.kb.se/resolve?urn=urn:nbn:se:liu:diva-54015

ISBN—

ISRNLiTH-ISY-EX--10/4394--SE

Serietitel och serienummerTitle of series, numbering

ISSN—

TitelTitle

Högprecisions frekvens-synkronisering via IPHigh Precision Frequency Synchronization via IP Networks

FörfattareAuthor

Andreas Gustafsson Danijel Hir

SammanfattningAbstract

This report is a part of a master thesis project done at Ericsson Linköping incooperation with Linköpings Tekniska Högskola (LiTH). This project is divided intwo different parts. The first part is to create a measurement node that collectsand processes data from network time protocol servers. It is used to determinethe quality of the IP network at the node and detect potential defects on usedtimeservers or nodes on the networks.

The second assignment is to analyze the collected data and further improve theexisting synchronization algorithm. Ip communication is not designed to be timecritical and therefore the NTP protocol needs to be complemented with additionalsignal processing to achieve required accuracy. Real time requirements limit thecomputational complexity of the signal processing algorithm.

NyckelordKeywords synchronization, kalman, NTP, synch

Page 6: High precision frequency synchronization via IP networks
Page 7: High precision frequency synchronization via IP networks

AbstractThis report is a part of a master thesis project done at Ericsson Linköping incooperation with Linköpings Tekniska Högskola (LiTH). This project is divided intwo different parts. The first part is to create a measurement node that collectsand processes data from network time protocol servers. It is used to determinethe quality of the IP network at the node and detect potential defects on usedtimeservers or nodes on the networks.

The second assignment is to analyze the collected data and further improve theexisting synchronization algorithm. Ip communication is not designed to be timecritical and therefore the NTP protocol needs to be complemented with additionalsignal processing to achieve required accuracy. Real time requirements limit thecomputational complexity of the signal processing algorithm.

SammanfattningDen här rapporten är en del i ett examensarbete utfört för Ericsson AB i samarbetemed Linköpings Tekniska Högskola. Rapporten är uppdelat i två delar. Den förstadelen är att skapa en mätnod som används till att mäta och beräkna signalkvaliténöver IP vid en radiobas-station genom att samla NTP-paket. Den andra uppgiftenär att analysera uppmätt data och ytterligare förbättra synkroniseringsalgoritmen.

v

Page 8: High precision frequency synchronization via IP networks
Page 9: High precision frequency synchronization via IP networks

Acknowledgments

We would like to thank our supervisor Tomas Bornefall for all the help and guid-ance during this thesis and Oscar Gustafsson for being an excellent examiner. Wewould also like to thank Martin Enqvist and Fredrik Gustafsson at Automatic con-trol, Linköpings Tekniska Högskola, for assisting us with Kalman filter theoreticsand also Mikael Johansson, Richard Jönsson and Mikael Olofsson at Ericsson,Älvsjö, for supporting us in our work. Finally we would like to thank everyoneelse who has otherwise contributed to this thesis.

vii

Page 10: High precision frequency synchronization via IP networks
Page 11: High precision frequency synchronization via IP networks

Contents

1 Introduction 11.1 Background . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11.2 Problem definition . . . . . . . . . . . . . . . . . . . . . . . . . . . 1

1.2.1 Quality measurement . . . . . . . . . . . . . . . . . . . . . 21.2.2 Frequency synchronization . . . . . . . . . . . . . . . . . . . 2

1.3 Purpose of thesis . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21.3.1 Goal 1 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21.3.2 Goal 2 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3

2 Concepts, clarifications and abbreviations 52.1 Concepts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52.2 Clarification . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52.3 Abbreviations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6

3 STN 73.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 73.2 SIU . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 73.3 Pico-station . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 83.4 Design of the STN . . . . . . . . . . . . . . . . . . . . . . . . . . . 8

3.4.1 Local terminal . . . . . . . . . . . . . . . . . . . . . . . . . 83.4.2 Time server . . . . . . . . . . . . . . . . . . . . . . . . . . . 93.4.3 NTP handler . . . . . . . . . . . . . . . . . . . . . . . . . . 93.4.4 Remote calibration . . . . . . . . . . . . . . . . . . . . . . . 9

4 NTP 114.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 114.2 Precision . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 114.3 Description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 124.4 PTP . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14

5 Existing Algorithm 15

ix

Page 12: High precision frequency synchronization via IP networks

x Contents

6 Measurement Instrument 176.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 176.2 Implementation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17

6.2.1 Functionality . . . . . . . . . . . . . . . . . . . . . . . . . . 176.2.2 Important changes . . . . . . . . . . . . . . . . . . . . . . . 186.2.3 Prerequisites . . . . . . . . . . . . . . . . . . . . . . . . . . 196.2.4 Activation . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20

6.3 Functional description for measurement mode in synchronization . 206.4 Measurement mode SW . . . . . . . . . . . . . . . . . . . . . . . . 20

6.4.1 Description . . . . . . . . . . . . . . . . . . . . . . . . . . . 206.5 Data analysis . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27

7 Configuration Management 317.1 SYN_1.16 Administration of Measurement Mode . . . . . . . . . . 31

7.1.1 General . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 317.1.2 Pre-conditions . . . . . . . . . . . . . . . . . . . . . . . . . 317.1.3 Initiation . . . . . . . . . . . . . . . . . . . . . . . . . . . . 317.1.4 Description . . . . . . . . . . . . . . . . . . . . . . . . . . . 317.1.5 Termination . . . . . . . . . . . . . . . . . . . . . . . . . . . 327.1.6 Fault Handling . . . . . . . . . . . . . . . . . . . . . . . . . 327.1.7 Capacity . . . . . . . . . . . . . . . . . . . . . . . . . . . . 327.1.8 Performance . . . . . . . . . . . . . . . . . . . . . . . . . . 327.1.9 Administration . . . . . . . . . . . . . . . . . . . . . . . . . 32

7.2 Function: OAM_3.8 Send Measurement data . . . . . . . . . . . . 337.2.1 General . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 337.2.2 Actors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 337.2.3 Pre-condition . . . . . . . . . . . . . . . . . . . . . . . . . . 337.2.4 Post-condition . . . . . . . . . . . . . . . . . . . . . . . . . 337.2.5 Main Flow . . . . . . . . . . . . . . . . . . . . . . . . . . . 337.2.6 Alternative Flows . . . . . . . . . . . . . . . . . . . . . . . . 337.2.7 Performance and Characteristics . . . . . . . . . . . . . . . 33

7.3 Function: OAM_3.9 Clear Measurement data . . . . . . . . . . . . 347.3.1 General . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 347.3.2 Actors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 347.3.3 Pre-condition . . . . . . . . . . . . . . . . . . . . . . . . . . 347.3.4 Post-condition . . . . . . . . . . . . . . . . . . . . . . . . . 347.3.5 Main Flow . . . . . . . . . . . . . . . . . . . . . . . . . . . 347.3.6 Alternative Flows . . . . . . . . . . . . . . . . . . . . . . . . 347.3.7 Performance and Characteristics . . . . . . . . . . . . . . . 34

8 Kalman filter 358.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 358.2 General Kalman filter . . . . . . . . . . . . . . . . . . . . . . . . . 358.3 The discrete steady-state Kalman filter . . . . . . . . . . . . . . . . 378.4 Variable sample time adaptive (VSTA) Kalman filter implementation 388.5 Investigation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41

Page 13: High precision frequency synchronization via IP networks

Contents xi

8.5.1 Investigation of the implemented Kalman filter . . . . . . . 418.5.2 Investigation of the adaptive Kalman filter . . . . . . . . . 418.5.3 Investigation of the VSTA Kalman filter . . . . . . . . . . . 44

9 Data Selection 479.1 Selecting good measurements . . . . . . . . . . . . . . . . . . . . . 479.2 Comparative Data Selection Algorithm (CDSA) . . . . . . . . . . . 479.3 Investigation of CDSA . . . . . . . . . . . . . . . . . . . . . . . . . 509.4 CDSA with adaptive vector length . . . . . . . . . . . . . . . . . . 539.5 Separate minimum selection SMS (minUD and minDD) . . . . . . 569.6 Comparison of SMS relative the minRTD selection . . . . . . . . . 569.7 SMS error approximation . . . . . . . . . . . . . . . . . . . . . . . 59

9.7.1 Tilted value selection . . . . . . . . . . . . . . . . . . . . . . 599.8 Investigation of using SMS with the implemented algorithm . . . . 61

9.8.1 Tilting effect in fixed window size . . . . . . . . . . . . . . . 629.9 CDSA with SMS and lookback . . . . . . . . . . . . . . . . . . . . 63

9.9.1 Look-back . . . . . . . . . . . . . . . . . . . . . . . . . . . . 649.9.2 Investigation of reusing samples . . . . . . . . . . . . . . . . 70

9.10 Comparison . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 709.11 Computational effort . . . . . . . . . . . . . . . . . . . . . . . . . . 779.12 Simulation data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 799.13 Outlier detection . . . . . . . . . . . . . . . . . . . . . . . . . . . . 829.14 Rapid synchronization . . . . . . . . . . . . . . . . . . . . . . . . . 85

10 Conclusions and Discussion 8710.1 Conclusions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 87

10.1.1 Estimation . . . . . . . . . . . . . . . . . . . . . . . . . . . 8710.1.2 Data selection . . . . . . . . . . . . . . . . . . . . . . . . . . 88

10.2 Future Studies . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 88

Bibliography 89

Page 14: High precision frequency synchronization via IP networks
Page 15: High precision frequency synchronization via IP networks

Chapter 1

Introduction

1.1 BackgroundToday’s mobile communication has very strict requirements on maintaining a sta-ble and controlled radio frequency. Depending on the type of base station (BTS)the accuracy requirements are between 50 and 100 parts per billion (ppb). Thesestrict requirements demand extreme precision and stability of the clock generator.

The radio frequency in today’s BTS is controlled by a crystal oscillator that iskept in an oven (OCXO) to keep the right temperature and thereby minimizingdeviation. Even though the crystal is of high quality and at constant temperatureit ages and thus drifts over time. This means that it occasionally has to synchronizeto an external time source to keep the correct frequency. There are primarily twoways of connecting to an external time source. The first way is via GPS that candeliver time stamps with an accuracy of ± 340 ns [1] and the second one is toconnect a BTS to a frequency reference using a wired connection.

The GPS alternative is already fast and accurate enough to synchronize basestations. Although there exists some problems with GPS that make it inadequateto use as the only synchronization source. One problem is that it requires a clearline of sight in order to function and that is not always possible. Another reason isthat the GPS signals can be jammed. This is why synchronization via IP is usedinstead.

1.2 Problem definitionOld and large BTS have a separate time division multiplex (TDM) connection tobase station controllers that provide the accurate time. Because of this separateand synchronous direct connection the BTS can synchronize in a few hours.

In modern and smaller BTS the synchronization data is sent via IP over anethernet connection instead, mostly due to cost optimization. This creates someproblems for the frequency synchronization because IP is not designed for timecritical communication. This means that it may take long time to synchronize.

1

Page 16: High precision frequency synchronization via IP networks

2 Introduction

Another limitation is that in some cases it is not possible to synchronize at all dueto poor quality of the net, high traffic load or other factors. This creates a needto measure whether or not it is possible to synchronize on certain locations. Thisrequest has also been issued by potential customers that want to decide if certainlocations are suitable for IP BTS placement.

1.2.1 Quality measurement

Due to unsteadiness and irregularities in IP networks there is a need to decide thequality of the connection at different places. The definition of quality in the caseof synchronization with NTP is the stability of the transport delay. This meansthat there are no problems to synchronize over IP if the transport delay is largeas long as it is constant and there are no large variations in uplink and downlinkdelay, which means that the time it took for the packet to go from A to B is thesame as the time for the packet from B to A. In order to decide the quality of thesignal it is important to know what kind of variations can be expected and howthese variations affect the ability to calculate correct values. With the informationit is possible to calculate the time it takes to synchronize or if it is possible at all.

1.2.2 Frequency synchronization

The crystal oscillator that controls the frequency drifts over time and have tobe synchronized with the assistance of an external time source. This is calledfrequency synchronization.

The device described in this document is currently able to synchronize via theIP network. The main issue with it today is that it is very sensitive for specificirregularities. One specific example being temporal high load on a server during agranularity period. This issue can contaminate all the collected data and therebyforce the device to discard the data and change timeserver. Another issue isthat the algorithm is rigid and does not consider the quality of the signal in thecalculations. In some cases this results in an unnecessary long synchronizationperiod.

1.3 Purpose of thesis

1.3.1 Goal 1

The purpose of this part is to create a measurement instrument. The measurementinstrument (MI) will be used to measure the signal quality at potential future BTSlocations and thereby decide if it is possible to place an IP-connected BTS on thatlocation or not. The plan is that the MI will be placed at the desired location andleft there to collect measurement data. When enough data has been collected inorder to decide the quality, the data will be analyzed and/or sent to an externalfilestore for further analysis.

Page 17: High precision frequency synchronization via IP networks

1.3 Purpose of thesis 3

1.3.2 Goal 2The purpose of this assignment is to improve the existing synchronization algo-rithm. To do this assignment it is required to investigate and analyze the existingalgorithm in order to identify any existing areas that can be further improved. Themost important improvement requested is the ability to synchronize in networkswith poor signal quality and/or high load.

Page 18: High precision frequency synchronization via IP networks
Page 19: High precision frequency synchronization via IP networks

Chapter 2

Concepts, clarifications andabbreviations

2.1 Concepts

ABIS: The interface between the Base Transceiver Station (BTS) and the BaseStation Controller (BSC) in a GSM system is called ABIS.Granularity Period: One measurement period when data is being collected.Stratum: The quality of a clock used for synchronization, generally the lower thenumber, the better precision.TOWA:Time Offset Wander Amplitude is a measurement of the maximal disper-sion of values. It is calculated by using least squares fitting in order to estimatea straight line from available data. Then both the positive and the negative max-imum deviations from the line are extracted and summarized. This gives us theabsolute maximal possible difference between two values.MAFE: Mean Absolute Forecast Error is a measurement of the mean dispersionof the values. Like in the TOWA case least squares fitting is used in order to ap-proximate a straight line from the data. The difference is that MAFE calculatesthe mean absolute value deviation from the line.

2.2 Clarification

The sample time mentioned in the text refers to the distance between two selectedmeasurements and not the sample time of incoming NTP packages.Chapter 7 is an standard Ericsson configuration management form and will notbe useful for anyone outside Ericsson.

5

Page 20: High precision frequency synchronization via IP networks

6 Concepts, clarifications and abbreviations

2.3 AbbreviationsAPI Application Programming InterfaceBSC Base Station ControllerBSU Base Station UnitBTS Base Transceiver StationCDSA Comparative Data Selection AlgorithmCDSAWSMS CDSA with Windowed SMSCDSAWSMSL CDSAWSMS with Look-BackCLI Command Line InterfaceDSA Data Selection AlgorithmGPS Global Positioning SystemHW HardwareIP Internet ProtocolLT Local TerminalMI Measurement instrumentMSQF Mean Square FitNA Not ApplicableNTP Network Time ProtocolOaM Operation and Maintenance Software PackageOCXO Oven Controlled Crystal OscillatorODC Old Data CompensationOS Operating SystemOSP On-Site PersonelOSS Operation and Support SystemPM Performance Managementppb Parts per BillionRF Radio FrequencyRS Requirement SpecificationRTD Round Trip DelaySIU Site Integration UnitSMS Separate Minimum SelectionSSH Secure ShellSTN Site Transport Node for BTSSW SoftwareTDM Time Division MultiplexerTO Time OffsetTS Time ServerUDP User Datagram ProtocolVCXO Voltage Controlled Crystal Oscillator

Page 21: High precision frequency synchronization via IP networks

Chapter 3

STN

3.1 Introduction

The Site Transport Node (STN) is a node in a BTS site that handles communica-tion over IP between a BTS and a Base station controller (BSC). The STN can beimplemented on various platforms, E.g. a Site Integration Unit (SIU), or it can bean integrated part of a Base Station Unit (BSU) such as a Pico-station. Becauseof the fact that the measurement part of this thesis has been implemented andtested on the STN in SIU, each time the STN is mentioned the reference is to theSTN in SIU.

3.2 SIU

Figure 3.1: SIU

The SIU, seen in Fig. 3.1 is a physical unit that adds transport sharing func-tionality for a radio base station (BTS) site. For example ABIS over IP andsite-LAN functionality. The SIU contains a STN that maintains the synchroniza-tion and current time of BTS’s over Ip by Network Time Protocol (NTP) or IEEE1588-2008 (PTP).

7

Page 22: High precision frequency synchronization via IP networks

8 STN

3.3 Pico-stationThe pico station is a small BTS designed to be used inside facilities. For examplelarge supermarkets, office buildings, tunnels etc. The pico-station has an internalSTN that is connected to a BSC through IP and is synchronized with NTP-packets.This is mainly done because a connection to the macro-net or GPS can not beguaranteed inside buildings and basements and it is very expensive to make aseparate E1/T1-line on various small office complex.

3.4 Design of the STNThe STN can handle a lot of interfaces as can be seen in Fig. 3.2, although theonly system dealt with in this thesis is the synchronization subsystem

Figure 3.2: Design of the STN.

Expanding the box including Synchronization and timeserver from Fig. 3.2,Fig. 3.3 is revealed. It describes how the synchronization subsystem is designed.The parts used in this thesis are marked in a box and described below

3.4.1 Local terminal

The local terminal is used to configure the STN. It is accessible through the consoleport or through SSH. All the necessary commands described in chapter 7 can beexecuted from the local terminal.

Page 23: High precision frequency synchronization via IP networks

3.4 Design of the STN 9

Figure 3.3: Synchronisation subsystem of the STN.

3.4.2 Time serverA time server is a server that holds correct time. The STN needs a timeserverwith accuracy of stratum-1. NTP-requests are sent from the NTP-handler to atimeserver and the timeserver will send a response containing timestamps.

3.4.3 NTP handlerThe NTP-handler sends NTP-requests to a timeserver and calculates the response.More about NTP in chapter 4

3.4.4 Remote calibrationThe filtering software calculates the Roundtrip delay, the timeoffset and controlsthe frequency of the VCXO given these variables. The basic frequency is givenby the OCXO and deviates over time. The OCXO is internally connected to aVCXO that delivers a frequency depending on the voltage input. When adjustingthe frequency only the voltage of the VCXO is changed to compensate for thefrequency error of the OCXO.

Page 24: High precision frequency synchronization via IP networks

10 STN

The Remote synch calibration algorithm calibrates the frequency of the SIUwith the help of an OCXO. The interconnection between the OCXO and the VCXOcan be seen in Fig. 3.4. It is also possible to see the connection between incomingNTP-packages and the corresponding frequency.

Figure 3.4: Block diagram of the synchronization procedure

Page 25: High precision frequency synchronization via IP networks

Chapter 4

NTP

4.1 IntroductionNTP stands for Network Time Protocol and is a standard protocol for synchroniz-ing computers over the internet. NTP time synchronization servers are availableon the internet. NTP exists in different levels where each level is represented bya stratum number. Stratum-0 is a national time source. Stratum-1 is directlysynchronized to a national time source, Stratum-2 is synchronized to stratum-1and so on. Extended information about the network time protocol can be foundin [7].

4.2 PrecisionThere exists a lot of public timeservers on the internet but they can not deliverextremely precise time stamps and the expected accuracy is about between 50 µsand 1.4ms[2]. This precision is not very adequate for synchronizing BTS’s.

To get accurate time stamps it is essential to have accurate timeservers. Therequired accuracy for BTS’s is hard to achieve in public timeserver mainly becausethere are occasionally high loads on timeservers and the net in general that causedelays and thereby decreases the accuracy. For this reason Ericsson has deployedprivate timeservers where they are needed.

It is not enough to only eliminate delays on the timeservers, the NTP packageshave to be sent and received on the STN without software delay. This is solvedby introducing hardware time stamping on the SIU. This means that the NTPpackages that are sent and received get their timestamp directly in the hardwaree.g. in the form of an FPGA before being sent and will not get affected byIP package queues. By taking these precautions, possible error sources on thereceiving and transmitting end can be minimized. But there is still one source oferror left. Although there exists some possible ways of prioritizing certain packagesin the IP network, the sent NTP packages will be delayed when passing throughdifferent nodes, like routers and switches on the way. This will cause the NTP

11

Page 26: High precision frequency synchronization via IP networks

12 NTP

packages transport delay to vary depending on the different load of the nodes.

4.3 DescriptionThe information sent in a NTP package can be seen in Fig. 4.1. It starts with theSTN (client) sending one time stamp (T1) corresponding to the local time on theSTN. The timeserver receives the message and marks when it arrived (T2). Thenthe timeserver sends a response containing T1, T2, the time when the responsewas sent (T3) and a reference timestamp. When the STN receives the message itmarks the time when it was received (T4) and saves T1-T4 to the memory. Usingthese, it is possible to calculate the round trip delay (RTD) and the time offset(TO).

Figure 4.1: NTP message timestamps.

T1 can be written as the correct time t1 plus a time error ε1 where ε1 is thedifference between the STN clock and the timeserver clock. T2 can be written ast1 plus transport delay δ1 from STN to the timeserver. T3 is the correct time t2when the message was sent.

T4 is t2 plus the time error ε1 plus the transport delay δ2 from the timeserverto the STN.T1=t1+ ε1T2=t1+ δ1T3=t2T4=t2+ ε1 + δ2

Page 27: High precision frequency synchronization via IP networks

4.3 Description 13

RTD = (T4 - T1) - (T3 - T2) = t2 + ε1 + δ2 − t1− ε1 − t2 + t1 + δ1 = δ1 + δ2RTD can be divided in three different delay categories as can be seen in Fig. 4.2.Constant delay: This is the minimum amount of time spent by the package trav-eling to and from the timeserver. If the connection was ideal then this would bethe total RTD.Wander delay: This delay origin from different traffic loads on the network.Random delay: This is the random variation and is produced by a variety ofdifferent reasons, some of them being temporal node delays and queues.

Figure 4.2: Round trip delay variations.

Time offset (TO) is the difference between the time on the STN and the timeon the timeservers2TO = (T2 -T1) - (T4 -T3) = (t1 + δ1−t1−ε1)−(t2−t2+ε1+δ2) = −2ε1+δ1−δ2As seen in the equation above the difference in transport delay creates an error inthe calculation of the time offset. TOerror = δ1−δ2

2The size of the error is half the transport delay difference. [4]

Page 28: High precision frequency synchronization via IP networks

14 NTP

4.4 PTPThe precision of NTP can be increased by the use of the Precision Time Protocol(PTP or IEEE 1588). PTP and NTP are very similar to each other but the maindifference is that PTP has the ability to log the delays in all nodes through thenetwork. When a PTP packet arrives to a node that supports it, it receives a timestamp of when it arrived to the node and another time stamp when it leaves thenode. This feature makes it possible for the client to deduct the time spent inqueue and thereby minimize the difference in transport delay. However althoughqueuing delays are minimized, as long as there exist software timestamping in thenodes the scheduling delays still exist and can still cause some problems. Anotherdrawback of this method is that it assumes that all IP packages travel the sameway to and from the timeserver and this is not always the case. [3]

The reason why this is not being used yet is that the nodes of today do nothave PTP support which is essential for this method to work. The good news isthat PTP support is growing and in the future it might be possible to get bettertime precision through the IP network.

Page 29: High precision frequency synchronization via IP networks

Chapter 5

Existing Algorithm

There is already an implemented synchronization algorithm on the STN that isgood enough to synchronize the oven controlled crystal oscillator (OCXO) overNTP. The assignment was to investigate how this solution could be improved orif there are some better ways of solving this problem. The assignment of improv-ing something can be interpreted in many different ways. The algorithm can beimproved in order to synchronize faster, it can be more stable, have the abilityto synchronize with worse signal quality or just run faster or use less memory.The initial goal was to investigate in what way the existing algorithm could beimproved considering the ability to synchronize in networks with poor qualityand synchronizing faster in better quality networks without sacrificing stability.Furthermore some different methods of synchronization should be investigated inorder to map the different advantages and disadvantages. The description of thecurrently implemented solution is classified and thereby will not be described inthis report.

15

Page 30: High precision frequency synchronization via IP networks
Page 31: High precision frequency synchronization via IP networks

Chapter 6

Measurement Instrument

6.1 IntroductionOne assignment for this thesis was to create a measurement instrument (MI) thatcollects NTP measurements through IP in order to find out if it is possible tosynchronize a STN from specific physical locations. To avoid creating completelynew hardware and software which is a huge and expensive project for a small MI,existing technology is modified and reused.

6.2 ImplementationThe implementation of this MI has been in C and testing of the code has been doneon a SIU. The operating system of the SIU has been used in combination withadditional functions and modifications. Detailed information about the differentfunctions is described in this chapter.

6.2.1 FunctionalityThere are two primary ways to use something as a MI. The first alternative is to dothe signal processing directly on the hardware. The second alternative is to collectmeasurement data and send it where it can be stored and processed. The secondalternative is possible because the SIU is connected to an IP Network and it has alot of available bandwidth to send the data. The advantage of this alternative isthat more advanced data processing algorithms can be applied and thereby detectanomalies or temporal variations. The disadvantage is that the data have to beanalyzed by someone using Matlab or a similar application.

To summarize, the first alternative is simpler and the second is more flexible.There are pros and cons with both alternatives but after careful consideration anddiscussions with the project manager it was decided to implement both alterna-tives. Mostly in order to not sacrifice functionality that may be useful in certainsituations. In some cases it is important to analyze all the data to get a more

17

Page 32: High precision frequency synchronization via IP networks

18 Measurement Instrument

detailed analysis of the network and in some cases only the information whetherit is possible to synchronize on a specific location is of interest.

Figure 6.1: Setup of the measurement instrument.

The requirement for the STN to be able to synchronize is that the differencebetween the maximum and the minimum deviation from the mean square fit calcu-lation for each measurement is less than a predefined limit, otherwise the frequencyerror could be too large. This is also a reason why it is the only signal processingalgorithm on the STN. If this requirement is satisfied then the result will be thatthe timeserver is accurate enough for synchronization. There are only two differ-ent modes to classify the timeservers: good enough and not good enough. Thereason for having this strict classification is that the STN only differs betweengood and bad timeservers. If a timeserver fulfills the requirement it is used forsynchronization. Otherwise it switches to another more appropriate timeserver.

In the measurement mode, a too high time offset wander or too few valid mea-surements will also result in an invalid timeserver but with one difference. Thedata in the granularity vector will be discarded and it will be noted that the SIUhas failed the TOWA test. The collected measurement data will on the otherhand not be discarded for that timeserver and the measurement will continue asusual. When the information about the timeservers is collected it will be pos-sible to see how many deviating measurements that have been received from aninvalid timeserver. This feature might be useful for future improvements of thesynchronization algorithms that can filter contaminated data through e.g. outlierdetection (see chapter 9.13).

6.2.2 Important changesSome changes in the current code needed to be implemented and some functionswere created to minimize the extra amount of data needed to be processed toimplement a measurement node.

Page 33: High precision frequency synchronization via IP networks

6.2 Implementation 19

Store measurement data in RAM

One major difficulty was how to store the collected measurement data. The firstapproach would be to store it in vectors on the STN, although this was not agreat idea because it had to be stored in a way that both the Operation andMaintenance system (OAM) and the STN could find it. The STN needs to collectmeasurement data and the OAM is required to send it to a filestore. Using thisapproach means that large signals will be sent between these processes, whichtakes a lot of unnecessary resources. One solution to this problem is that theSTN stores the measurement data in temporary files on the RAM. When the CLI-command sendmeasdata <filestore> later is executed the OAM can send thesefiles to filestore. The command clearmeasdata can later on remove the files fromthe RAM.

Changed vector sizes

Previously the TO_Cal_Vector, RTD_Cal_Vector, and all the other vectorsneeded for synchronization were as large as needed. They are now extended sothat they can contain values from all six timeservers. Before measurement modethey were allocated to a size of 300 but contained at most 90-96 values becauseonly one timeserver was active at a time. After measurement mode has been im-plemented this vector is increased to a size of 600, with all the synchronizationdata inside. Data from the first timeserver is stored from index 0 to [size of storeddata-1], data from the second timeserver is stored from index [size of stored data]to index [(2*size of stored data)-1] and so on. In normal operations this will notcause a problem because the amount of storage needed for calibration data hasonly been slightly increased. There is a possibility that the current test programshave to be altered a bit to support this increased vector length. But in generalthe remote synch calibration functions as usual.

6.2.3 PrerequisitesIf the STN is to be used as a MI, there are a few prerequisites that needs to befulfilled if measmode is able to perform as requested.

• testmode in combination with measmode has not been thoroughly testedand therefore should not be used together. If a faster measurement periodis desired, it is possible to use the pboot parameter MeasModeAccelerationset to 1 by default.

• Timeservers (if any) need to be configured in order, i.e. timeserver 0 needsto be configured if timeserver 1 is configured etc.

There are also some prerequisites that need to be fulfilled before measmode is acti-vated. When these are fulfilled and measmode is enabled, measmode is activated.

• synchtype must be of type timeserver.

• At least one timeserver needs to be configured.

Page 34: High precision frequency synchronization via IP networks

20 Measurement Instrument

6.2.4 ActivationTo make the MI easy to use for the on site personnel (OSP) it is necessary tostay consistent when implementing new functionality on the STN. The STN hasa mode that is called testmode that is used to test the STN’s functionality. Whatit does is to accelerate everything that is associated to synchronization over IPby 100 times. This functionality is very useful for quickly ensuring correct func-tionality. The testmode is activated on site through the local terminal or throughremote login via SSH to the SIU. It is very intuitive and easy to use. By typingtestmode enable/disable the state of testmode is changed. This is also how the MIfunctionality is implemented.

When typingmeasmode enable/disable the MI functionality is activated/deactivated.When measmode is enabled all other remote synchronization functions are dis-abled. This means that the STN is completely dedicated to collect measurementdata. During normal operation the STN is connected to one of up to six time-servers. When measmode is enabled the STN receives data from all configuredtimeservers. For example if two timeservers are configured, a measurement isrequested twice as fast as if only one was configured.

In measmode the timestamps T1-T4, TO, RTD, "if the measurement was valid"and "if a warm restart has been issued" are stored continuously in the memory. Ifmeasmode is enabled it is suggested that no or few functions that require memoryaccess are used at the same time.

6.3 Functional description for measurement modein synchronization

Several flowcharts for how the measurement mode is implemented can be seen inFig. 6.2 to Fig. 6.5

6.4 Measurement mode SWThe Measmode SW is an alternative program flow of the Process Measurement SWwhich collects measurements for a configured timeserver and stores the values in afile on RAM. The main difference between Process Measurement when running inMeasurement Mode is that Measurement Mode stores T1-T4, RTD, TO, validmeasand warmrestart in a file instead of saving RTD and TO in a vector (see chapter4.3). Several different functions have been created/altered to be able to executein Measurement Mode. Unused in table 6.1 means that Measurement mode neveruses that input/output

6.4.1 DescriptionMore detailed information about the different implemented and altered functions.

Page 35: High precision frequency synchronization via IP networks

6.4 Measurement mode SW 21

Figure 6.2: Flowchart for remoteSynchCalibrationHandler.

calcTOandRTD

This function calculates the time offset and the round trip delay from the times-tamps. The only changes made in this function is that the current timeserver andthe number of timeservers is passed on as an input to this function otherwise themeasurement mode will not function correctly.

getMeasModeTimeMeas

New function that calculates the timestamps received from the NTP-server. If nomeasurement was received, it stores the current timeserver instead.

initialization

Executes when the first measure for each timeserver is received. Initiates all thenecessary data and sets the first time offset to zero.

Page 36: High precision frequency synchronization via IP networks

22 Measurement Instrument

Figure 6.3: Flowchart for remoteSynchCalMeas.

processMeasurement

The only thing changed in this function is that if the TOWA fails, the measfaileddata for that timeserver is increased and no reset is requested. It also has thecurrent timeserver as an input so that measmode will function correctly. Executesthe function timeOffsetWanderSupervision.

remoteSynchCalibration

Not executed in measmode, changed to take a timeserver ID as an input becauseprocessMeasurement need that variable.

Page 37: High precision frequency synchronization via IP networks

6.4 Measurement mode SW 23

Figure 6.4: Flowchart for getMeasModeTimeMeas.

Figure 6.5: Flowchart for writemeasdata.

remoteSynchCalibrationHandler

This function is called by the OAM every measurement period if the currentsynchtype is timeserver. A measurement period in measmode is the standard

Page 38: High precision frequency synchronization via IP networks

24 Measurement Instrument

measurement period divided by the number of configured timeservers. This is themain function for the remote synch calibration.

remoteSynchCalMeas

This function has two new inputs, the number of timeservers and a boolean meas-Mode. It also executes initialization, calcTOandRTD, processMeasurement, re-moteSynchCalibration and updateMeasData.

requestNTPMeas

Requests a NTP measurement for the current timeserver.

setMeasVar

Updates state variables to NVRAM.

SNC_getMeasmodeReq_handler

Handler for the CLI command measmode.

SNC_setMeasmodeReq_handler

Handler for the CLI command measmode enable/disable/status

timeOffsetWanderSupervision

Calculates the mean square fit and finds out if the time offset wander is to largefor the current timeserver.

updateMeasData

If measmode is activated, this function updates the measurement data each mea-surement period. Measdata is stored in the following format in a file:<T1>,<T2>,<T3>,<T4>,<TO>,<RTD>,<validmeas>,<reset><T1>,<T2>,<T3>,<T4>,<TO>,<RTD>,<validmeas>,<reset>. . .<T1>,<T2>,<T3>,<T4>,<TO>,<RTD>,<validmeas>,<reset>

writeMeasData(1-6)

Writes the measurement data to RAM when measmode is enabled.

Page 39: High precision frequency synchronization via IP networks

6.4 Measurement mode SW 25

Name Description Input OutputcalcTOandRTD Calculates the TO and

the RTD.bool validMeas,bool saveMeas,U8 TSid,U8 noTS

NONE

getMeasMode-TimeMeas

Requests an NTP-measurement from atimeserver and storesthe response in astructure packet_t.

U8 noTS,packet_t ?time,bool firstmeas

bool valid-Meas

initialization Initiates all variables af-ter the first valid mea-surement has been re-cieved.

U8 TSid NONE

processMeasurement Evaluates the TO andRTD-vector to find avalue to save in the cal-ibration vector.

U16 TSid NONE

remoteSynch-Calibration

Used when measmodeis disabled, changed sothat it now needs thetimeserver id to regulateon the correct data.

U8 TSid NONE

remoteSynch-CalibrationHandler

This is the main pro-gram of the remotesynchronization, whensynchtype=timeserverand at least one time-server is configured,this function is calledperiodically.

NONE NONE

remoteSynch-CalMeas

Calculates TO and RTDand stores the measure-ment data in measmode.

bool validMeas,bool measRestart,bool calRestart,unusedFLregOK,unused ?TSchanged,unused ?switchToNext,unused testMode,bool measMode,U8 noTS,packet_t ?time

NONE

Page 40: High precision frequency synchronization via IP networks

26 Measurement Instrument

requestNTPMeas This function is calledfrom the RemoteSynch-CalibrationHandlerto request a mea-surement from thetimeserver. Previouslythis functionality wasincluded in functiongetTimeMeas, but dueto timestamping in SWit was better to put thisfunctionality at the endof RemoteSynchCali-brationHandler.

NONE NONE

setMeasVar Changes the parametervalues in the NVRAM.

U8 TSid NONE

SNC_getMeasmodeReq_handler

Handler for CLI com-mand measmode.

*rec_p NONE

SNC_setMeasmodeReq_handler

Handler for CLI com-mand measmode en-able/disable/status.

*rec_p NONE

timeOffset-WanderSupervision

calculates the wanderamplitude, which is thelargest value that de-viates from the meansquare fit calculation.

U16 TSid NONE

updateMeasData Updates the measure-ment data in measmode,Sets the T1-T4, RTD,TO and validmeas vari-ables correctly in thecurrent timeserver data.

bool resetMeasMode,U8 TSid,U8 noTS

NONE

writeMeasData(1-6)

depending on whichtimeserver being mea-sured, this functionwrites measdata tothe RAM. Called fromRemoteSynchCali-brationHandler whenmeasmode is activated.

NONE NONE

Table 6.1: New and changed functions for measMode.

Page 41: High precision frequency synchronization via IP networks

6.5 Data analysis 27

6.5 Data analysisThe data file sent from the SIU contains the RTD and the TO calculated bythe STN. In addition to that it also contains the separate timestamps (T1-T4)received by the STN, the notation if a measurement has been classified as validand if the SIU has performed a warm restart. The values are stored in colonvectors separated by a comma and in descending time order.

The reason for storing the data in colon vectors is that it will be easy to extractthe data in Matlab. By using the command data=load(filename) the file will besaved as the variable data and then it is easy to extract separate colons by writingfor example: TO=data(:,5). To avoid writing this manually a function that doeseverything automatically has been implemented. The plot_data function readsthe data from a file, extracts necessary information, reports number of invalidmeasurements, calculates separate time offset wander supervision (TOWA) andplots the data.

In order to plot the data received from the SIU while in measurement mode,(measmode) type the following in the Matlab console window plot_data(’filename’)Example: plot_data(’server1.txt’) or plot_data(’filepath\server1.txt’)

In the Matlab console it will be displayed how many invalid measurementsthere are and how many times the TOWA supervision has failed in Matlab.

It is also possible to remove the highest RTD and TO values in order to geta more detailed plot. By typing plot_data(’filename’, percentage) the functionwill only plot the percentage of the lowest RTD values and remove the highestvalues. This is necessary because some packages are extremely delayed and thiswill reduce the clarity of the plots. As seen in Fig. 6.6 where the RTD is plottedit is impossible to get any relevant information.

Removing two percent of the highest RTD values gives a more clear plot ascan be seen in Fig. 6.7

Example: plot_data(’server1.txt’, 80) or plot_data(’server1.txt’, 98). Whennot specified the default percentage value is 100.

When using the procedure described above, the plotted RTD and TO valuesare calculated on the SIU. It is also possible to calculate RTD, TO, uplink de-lay (UD) and downlink delay (DD) by using the T1-T4 timestamps. By typingplot_data(’filename’, percentage, calc_RTD_TO), e.g.: plot_data(’server1.txt’,80, 1) three plots will be displayed. The usual RTD and TO but also the UD andDD.

Important to know is that it is not possible to get the exact size of the UDand DD values. The difference relative the first measurement will be exact butthe amplitude is not correct. In order to get more realistic plots the UD and DDvalues are initiated to half of the first RTD value. It is possible to change this andinitiate UD and DD to zero. An example of how the UD and DD plot can looklike can be found in Fig. 6.8.

Page 42: High precision frequency synchronization via IP networks

28 Measurement Instrument

Figure 6.6: Every measurement collected in measurement mode.

Figure 6.7: The 98 lowest percent of the measurements collected in measurementmode.

Page 43: High precision frequency synchronization via IP networks

6.5 Data analysis 29

Figure 6.8: UD and DD of the 98 lowest percent of the measurements collected inmeasmode.

Page 44: High precision frequency synchronization via IP networks
Page 45: High precision frequency synchronization via IP networks

Chapter 7

Configuration Management

7.1 SYN_1.16 Administration of Measurement Mode7.1.1 GeneralThis function applies to the SIU. This function is used from the Local Terminalor the SSH interface to activate, terminate and retrieve the Measurement Mode.It is also used to retrieve the status of the timeservers.

7.1.2 Pre-conditionsOSP or OSS has logged on in accordance with function Local User Login or func-tion Remote User Login.Testmode is disabled.

7.1.3 InitiationBy OSP or OSS command.

7.1.4 DescriptionMeasurement Mode is used to collect data in the Remote Synch Calibration func-tion for purpose of examine the quality of the configured timeservers or rather thequality of the IP-network that it is connected to. The Remote Synch Calibrationis by default not in Measurement Mode and the Measurement Mode parameter isused only by the Remote Synch Calibration function. When the Remote SynchCalibration function is not active, changing of the Measurement Mode parameterhas no influence. If the Remote Synch Calibration function is then later activated,i.e. synchType changed to timeServer, this Measurement Mode parameter valuewhich was entered earlier will be used.

When the Remote Synch Calibration function is already active (i.e. synchType== timeServer) and the Measurement Mode value is changed then the RemoteSynch Calibration function is restarted using this new measurement Mode value.

31

Page 46: High precision frequency synchronization via IP networks

32 Configuration Management

Measurement Mode survives warm start, e.g. STN node restart due to configura-tion change. Measurement Mode does not survive cold start (Power Off, restartcommand etc.)

Command Syntax

To activate the Measurement Mode from the Local Terminal entermeasmode enableTo terminate the Measurement Mode entermeasmode disableTo get the status from the Measurement Mode entermeasmode statusThe response isServer1:<Number of times failed>Server2:<Number of times failed>Server3:<Number of times failed>Server4:<Number of times failed>Server5:<Number of times failed>Server6:<Number of times failed>

To retrieve if measurement mode is enabled entermeasmodeThe response ismeasmode enabled ormeasmode disabled

7.1.5 TerminationThe command is terminated when the OSmon command prompt is shown.

7.1.6 Fault HandlingNA

7.1.7 CapacityNA

7.1.8 PerformanceThe measurement data is only stored in RAM, which means that it will not survivea cold restart.

7.1.9 AdministrationNA

Page 47: High precision frequency synchronization via IP networks

7.2 Function: OAM_3.8 Send Measurement data 33

7.2 Function: OAM_3.8 Send Measurement data

7.2.1 GeneralThis function describes how the OSS or OSP requests sending of measurementdata

7.2.2 ActorsOSS, OSP

7.2.3 Pre-conditionOSS or OSP is logged in and has access to the command prompt.

7.2.4 Post-conditionThe measurement data has been sent to a filestore.

7.2.5 Main Flow1. OSS or OSP issues a sendmeasdata command with fileStore parameter.

2. OAM requests that the measurement data from all six timeservers should besent to the fileStore location.

3. The security manager sends measurement data from all timeservers to file-store

4. STN returns OperationSucceeded.

7.2.6 Alternative Flows1. Measdata do not exist for all timeservers

(a) the security manager will fail to send data for these servers.

(b) the log will say that the security manager failed to send.

7.2.7 Performance and CharacteristicsThe fileStore given by the sendmeasdata command contains the user name andpassword used for sFTP. The fileStore value is not stored after this function isfinished.

Page 48: High precision frequency synchronization via IP networks

34 Configuration Management

7.3 Function: OAM_3.9 Clear Measurement data7.3.1 GeneralThis function describes how the OSS or OSP requests clearing of the measurementdata

7.3.2 ActorsOSS, OSP

7.3.3 Pre-conditionOSS or OSP is logged in and has access to the command prompt.

7.3.4 Post-conditionNo measurement data exists on the SIU, although if measurement mode still isactive, new data will be stored as before.

7.3.5 Main Flow1. OSS or OSP issues a clearmeasdata command without additional parameters.

2. OAM requests and deletes the measdata for all timeservers.

3. STN returns OperationSucceeded.

7.3.6 Alternative Flows1. Measdata do not exist for all timeservers

(a) the OAM will fail to delete measurement data for that timeserver.(b) the log will say that the file did not exist.

7.3.7 Performance and CharacteristicsNA

Page 49: High precision frequency synchronization via IP networks

Chapter 8

Kalman filter

8.1 IntroductionA Kalman filter is a recursive estimation filter that estimates a value from aseries of noisy measurements. It is an important tool in control theory and signalprocessing because it is reliable and well-tested. Because of the recursiveness nolarge history of old measurements is needed. All that is required are the gain, theestimated value from previous time step and the current measured value. Thesethree are used to calculate the estimated value for the current time step. If themeasurement noise error is estimated to be constant, the gain can be approximatedwith a constant that is optimal to exactly that error. However, if the noise isfluctuating, the gain will also fluctuate[9][10].

8.2 General Kalman filterThe Kalman filter addresses the problem of estimating the state xk by solving thelinear stochastic difference equation:xk = Fkxk−1 + Bkuk + wk

where xk is the state at the current time step.xk−1 is the state at the previous time step.Fk matrix is the state transition model that relates the state at the previous timestep k-1 to the state at the current time step k.uk is the control vector.Bk matrix is the control input model that relates the control vector to the currentstate xk.wk is the random process noise which is assumed to be white and with normalprobability distribution with covariance Q.wk ∼ N(0, Q)The measurements are modeled as:zk = Hkxk + vkWhere zk is the actual measured state at the time step k.

35

Page 50: High precision frequency synchronization via IP networks

36 Kalman filter

Hk is the observation model that maps the true state space to the observed statespace.vk is the random measurement noise which is assumed to be white and with normalprobability distribution with covariance Rk.vk secN(0, R)

The Kalman filter is divided in two phases, predict and update. The predictphase uses the state estimate from the previous time step in order to estimate thecurrent state. It is also called the priori state estimate because it does not includethe current measurement in its estimation. The update phase combines the pri-ori estimate and the current measurement in order to refine the current estimate.This procedure is continuously repeated as long as the estimation proceeds.

Writing notations:

x̂n|m is the estimate of x at time n using observations up to and including m.Pn|m is the error covariance matrix at time n using observations up to and includ-ing m. It is a measurement of the estimated accuracy of the state estimate.Kk = Pk|k−1HT

k S−1k

Figure 8.1: Prediction and Update of the K and P values.

This is the optimal Kalman gain and hence the value that returns the minimummean square error.

Pk|k = (I −KkHk)Pk|k−1 is a simplification of the posterior error covarianceformula and is only valid if the optimal Kalman gain is used. It is computationallycheaper and thereby the dominating implementation in practice. If a non-optimalKalman gain is used the error covariance formula is:Pk|k = (I −KkHk)Pk|k−1(I −KkHk)T + KkRkKT

k

Page 51: High precision frequency synchronization via IP networks

8.3 The discrete steady-state Kalman filter 37

8.3 The discrete steady-state Kalman filterBy analyzing the general Kalman filter structure it is possible to identify the mainparameters [8]. A general Kalman filter is constructed so that all the parameterscan be variable and the filter adapts itself depending on the variable values. Ifall parameters are constants it is unnecessary to treat them as variables. In thisKalman filter the matrixes F, H and B are constant. B = 0

Fk = F =(

1 Ts0 1

)= constant.

This is the standard F matrix with regular sampling intervals.Ts = sample period.

Hk = H =(

1 0)

= constant.

x0 =(eTOeFO

)=

(00

)x0 start at time zero with time and frequency offset set to zero.The steady-state model is:

xk+1 = Fxk + K(zk −Hxk)

Since the measurement errors at time Tk are uncorrelated, Q and R can bedenoted as scalars. The only variable parameter is the error covariance R. Thisvariable affect the covariance matrix P. The process noise variation Q is in thiscase limited by the minimum value that the current algorithm is able to manage. Qis set by the VCXO DAC limitations. Variance is the standard deviation squared[5].

This is the calculated size of the standard deviation but this parameter canalso be used to size the gain. By setting the standard deviation smaller than theactual value, the gain will decrease and the filter will be less wavering. This isequivalent to increase the magnitude of the observation noise standard deviation.The observation noise variance R can be extracted from the measured data. Dueto limitations in calculating the correct noise it is recommended to set R a littlehigher than the estimated error. Rk is modeled as the time offset wander amplitudesquared.

Larger Rk results in lower gain and lower gain leads to a slower estimation.In this case there are no problems with unnecessarily slow algorithms becausethe OCXO is quite stable. There are potentially more severe problems relatedto underestimating the error but these problems can be solved by identifying themagnitude of the error and if it turns out to be too large, either suspend the cali-bration until the error is within acceptable limits or try switching synchronizationsource. By rewriting some equations it is possible to derive the discrete time Ric-cati equation.P = FTPF− (FTPH)(R + HTPH)−1(HTPF) + Q

Page 52: High precision frequency synchronization via IP networks

38 Kalman filter

The solution to the matrix equation is the covariance matrix for the optimalgain given a specific estimation error. A solution to the algebraic Riccati equationmay not always exist and even if it does, it is not guaranteed to result in a stableKalman filter. The stability of discrete filters can be confirmed by controlling ifthe poles are inside the unit circle and if the eigenvalues of (F−KH) have negativereal parts. By using the calculated covariance matrix it is possible to calculate theoptimal gain. K = (HTPH + R)−1HTPF

To decrease the computational effort it is possible to solve the Riccati equationin advance and only save the results. This is possible because there is only onevariable. Solving the Riccati equation for different magnitudes of the standarddeviation gives Fig. 8.2 that shows the gain for standard deviation between 1msand 100ms. This implementation is further on called the adaptive Kalman filter.

Figure 8.2: K values.

8.4 Variable sample time adaptive (VSTA) Kalmanfilter implementation

This implementation consider the difference in sample time, the actual measure-ment noise, the control parameter and the delay between the control and themeasured result. The state model is the same as for the steady-state Kalman filterexcept that the sample time is variable and the gain has to be calculated for everynew measurement.

P0|0 is tricky to set because it is impossible to know the initial time andfrequency offset. The safe way to choose P0|0 is to set its diagonal to a verylarge value. This is the recommended procedure when the initial conditions are

Page 53: High precision frequency synchronization via IP networks

8.4 Variable sample time adaptive (VSTA) Kalman filter implementa-tion 39

unknown and means that the filter will be more receptive for measurements in thebeginning to get a faster first estimation of the initial values. The Pk matrix willchange very fast to a more accurate value due to the update phase.

P0|0 =(∞ 00 ∞

)Control parameter and old data compensation (ODC)

The data is collected approximately 24 hours before it is used to make an estima-tion and the state of the estimated values might have changed during that time.The reason for using 24 hours old data is that the data selection algorithm willhave more time in order to select good measurements. One big problem that oc-curs when making an estimation based on old data is that it might not be accurateanymore. This is usually the case when a frequency adjustment has been made.Especially important knowledge is that after a frequency adjustment is made theestimated frequency value is also adjusted. This causes some problems becausethe incoming data during the future 24 hours is inaccurate. The data that hasbeen collected when there was a frequency offset will still indicate that there is afrequency offset present.

This means that the Kalman filter will believe that there is still a frequencyoffset and will still try to adjust for it even though it has already been compensatedfor. This creates some unwanted characteristics. In the worst case it could resultin an unstable system. In the normal case it will only result in an overshoot of theestimated value as seen in Fig. 8.3.

Figure 8.3: Regulating frequency before ODC.

The reason for the overshoot is that the estimated TO (eTO) is calculatedby both the estimated FO and the TO error as seen in the equation below. To

Page 54: High precision frequency synchronization via IP networks

40 Kalman filter

get a better overview the gain calculation and the predict/update phases are notconsidered.

(eTOi+1eFOi+1

)=

(1 Ts0 1

(eTOieFOi

)+

(k1k2

)× (eTOi − TO) =

(eTOi + Ts× eFOi + k1× (eTOi − TO)eFOi + k2× (eTOi − TO)

)Reducing the eFO implicates that eTO calculations will be reduced by Ts ×

(FOreduction). Furthermore the difference between TO and eTO will increaseand the eFO calculation will also start to increase. Because of that the eFO willbe reduced further which leads to further decrease of the eTO and so on. Thesolution to this problem lies in the control vector uk by modeling B and uk as:

B =(Ts0

),uk =

(rFOi0

)As seen in the equation below the eFO will be reduced with the same size as thereduced FO (rFO) will increase and therefore there will be no difference in theeTO calculations.

(eTOi+1eFOi+1

)=

(1 Ts0 1

(eTOieFOi

)+

(Ts0

(rFOi0

)+

+(k1k2

)× (eTOi − TO) =(

eTOi + Ts× eFOi + Ts× rFOi + k1× (eTOi − TO)eFOi + k2× (eTOi − TO)

)The problem in this case is that every reduction of the FO is different and at

different times. It is important to keep track of when it is no longer necessaryto compensate for the reduction. There are several different ways to solve thisbut in order to reduce the computational effort the least computational expensivesolution is used. Creating a control vector uk with the same size as the averagenumber of samples during a 24h period and place it inside the automatic controlfunction that is responsible for reducing the FO makes it possible to add thereduction to all the elements in the vector.

When a new sample arrives and the estimation is completed the first elementin uk is removed. A new element is inserted at the end of the vector that containsthe value zero. The value zero indicates that it is correct data and no frequencyadjustment has been done since the data has been collected. Because the reductionis done in small steps it will be added to all the elements in the vector and the firstvalue is the sum of all the small reductions done during the last 24h period. Thedrawback of this simplified solution is that the average number of samples during

Page 55: High precision frequency synchronization via IP networks

8.5 Investigation 41

Figure 8.4: Regulating frequency after ODC.

a 24h period is used. Comparisons to exact and more computationally expensivesolutions shows that there are no noticeable differences between the results. Theresults when using ODC can be seen in Fig. 8.4

The improvement is significant in this case because the difference between theestimated TO and the actual measured TO is reduced. This is because the filterwill continue to estimate a TO based on the actual measured data and the actualFO and not the new FO which is inaccurate for the next 24 hours. It is importantto observe that this does not allow us to adjust the FO more often because theactual frequency is not visible until 24 hours later. This only reduces the errorthat is introduced when compensating for the FO reduction directly. Therefore itis only necessary to use when the gain is large. A Kalman filter with a very smallgain will not be affected by this because the estimation of the frequency offsettakes longer time than 24 hours.

8.5 Investigation8.5.1 Investigation of the implemented Kalman filterIn order to investigate how to further improve the implemented Kalman filterit was necessary to do a detailed analysis of the implementation. The detailedanalysis is not included in this report.

8.5.2 Investigation of the adaptive Kalman filterA request was to create an adaptive filter that has the ability to consider thequality of the signal and thereby adapt itself. In order to be able to make a fair

Page 56: High precision frequency synchronization via IP networks

42 Kalman filter

comparison a steady-state Kalman filter was designed with the difference that thegain is continuously calculated considering the error. In order to model the errorthe TOWA is used as the standard deviation. The TOWA is not correct to useas a measurement of the signals standard deviation because it is a measurementof the maximal difference. The reason for using it is to minimize the chance thatthe error is underestimated. By modeling the standard deviation as the maximalamplitude a margin is introduced in the estimation. The initial difference betweenthese two filters is that the adaptive filter is faster.

Figure 8.5: Currently implemented Kalman filter.

This was not the primary goal of this implementation but nevertheless a posi-tive side effect. The reason for the increased speed is that the rise time decreaseswith the decreased estimated error. When increasing the error above the maximumlimit a difference is noticed between these two filters. The gain in the adaptivefilter is smaller than the gain of of the implemented filter. This means that it istheoretically possible to use this filter in networks with worse signal quality. InFig. 8.7 the adaptive Kalman filter is synchronizing with an extremely bad signalquality.

In the simulation shown in Fig. 8.7 and other simulations where there is aconstant frequency offset the estimated frequency does not converge to zero. Thisis due to the large continuous frequency drift used in the simulations. A largecontinuous drift in combination with poor signal quality will result in a continu-ous offset in the frequency estimation. The timescale in figure 8.7 is about threetimes longer compared to figure 8.6 due to the slow rise time which is a result fromthe signal quality. The downside of this algorithm is that it requires continuousdata input and that the Riccati equation has to be solved with every new gaincalculation. The Riccati equation is a computationally expensive nonlinear differ-ential matrix equation that calculates the optimal gain value. It is not reasonable

Page 57: High precision frequency synchronization via IP networks

8.5 Investigation 43

Figure 8.6: Adaptive Kalman filteralgorithm with low TOWA.

Figure 8.7: TOWA of about 100 ms with a large frequency drift.

to calculate this equation during runtime but there is a solution to that problem.The solution is to pre-solve the Riccati equation for different error magnitudes andsave the calculated gain values. Later on it is simple to extract the correspondinggain value when the magnitude of the error is known.

In Fig. 8.8 it is possible to see how the rise time will change depending on

Page 58: High precision frequency synchronization via IP networks

44 Kalman filter

the magnitude of the error. Because of the direct relation between the expectederror, gain and the rise time, it is easy to calculate how long it will take for thealgorithm to be ready for calibration.

Figure 8.8: Step responses for different standard deviations.

8.5.3 Investigation of the VSTA Kalman filterThe reason for choosing a Kalman filter is due to its low computational cost,stability and the fact that it is the best linear unbiased filter. There are a fewdifferences between this Kalman filter and the adaptive Kalman filter. The firstdifference is that this Kalman filter has the ability to start with a large gainand thereby makes a faster estimation of the offset. The gain is reduced duringruntime in order to make a more accurate estimation as seen in Fig. 8.9. Anotherdifference is that with this implementation it is not required to have a constantinput of data which makes it possible to use more advanced selection algorithms.The final difference is that this estimator considers the fact that old data is usedwhich affects the control parameter.

The only negative about this filter compared to the steady state Kalman filteris the increased computational cost. The positive thing is that it initially hassubstantially shorter rise time which makes it possible to use as a fast calibratingfilter. More about that in section 9.14. The main reason for developing this filterand its most valuable feature is that it is compatible with variable window lengthdata selection algorithms.

Page 59: High precision frequency synchronization via IP networks

8.5 Investigation 45

Figure 8.9: The K value relative time.

Page 60: High precision frequency synchronization via IP networks
Page 61: High precision frequency synchronization via IP networks

Chapter 9

Data Selection

In this chapter, two different selection criterium called minRTD (section 9.1) andSMS (section 9.5) will be compared. The comparative selection algorithm (sec-tion 9.2) will be compared to the currently implemented selection algorithm incombination with different selection criterium.

9.1 Selecting good measurementsWhile trying to adapt the filter it became clear that there is not much to gainby only adjusting the filter. The results will not improve significantly unless thesignal quality is improved. One way of improving the signal quality is to improvethe data selection algorithm. In order to improve this it is necessary to have a wayof determining which values are good and should be selected. It turned out thatthe strongest relation between good values is also the most obvious correlation.Measurements with minimum RTD have least variation in the TO calculations.This conclusion can be confirmed by Fig. 9.1. The reason for this is that NTPworks under the assumption that the transport delay to and from the timeserveris equally long and any difference in the transport delay will be noticeable asvariations in the TO. The shortest RTD is most probable to have shortest transportdelays and thereby minimal difference between them.

9.2 Comparative Data Selection Algorithm (CDSA)The main purpose of the CDSA is to select which values that should be forwardedto the Kalman filter. To know which values that are good it is necessary to classifythem in some way. Due to limited information about the measurements it is hardto classify the data in an ideal manner. In this case data was classified by the mostevident relation between good and bad data. The relation between minimum RTDand accuracy of the measurements. This means that the measurements with theshortest RTD are classified as the ones with best accuracy as can be seen in section9.1 and thereby forwarded to the Kalman filter. It is not possible to use constant

47

Page 62: High precision frequency synchronization via IP networks

48 Data Selection

Figure 9.1: Roundtrip delay in increasing order with corresponding time offset.

RTD values as a reference due to different variations in the network that depend onphysical location, different delay in the network and different load on timeserversetc. This makes it problematic to decide if a RTD measurement is large or small.It is also strongly recommended not to measure the RTD on a network and use thisvalue as a reference because of possible large temporal variations on the network.The CDSA uses actual real time measurements and compares them with eachother in order to only choose the best, meaning the ones with shortest RTD.

CDSA uses a vector with an variable size that is currently set to 100. Thereare both positive and negative side effects with increased or decreased size. Moreabout that in section 9.4. This vector is called calibration vector and is usedto store measurements with the shortest RTD. Whenever a new measurementarrives its RTD is compared with the maximal RTD in the vector and if the newone is smaller, then the maximal RTD from the vector is removed and the newmeasurement is inserted at the end of the vector. Three values are stored for eachmeasurement: RTD, TO and a timestamp. The timestamp can be either the timewhen it arrived or the time difference between this measurement and the previousin the vector. When starting the measurement, all valid measurements are insertedin the vector until it is filled. After that there is a period of time where no valuesare sent to the Kalman filter and new arriving values are compared with the valuesin the vector in order to decide if they should be inserted or not. This amount oftime is called setup-time and it can be sized in different ways depending on how

Page 63: High precision frequency synchronization via IP networks

9.2 Comparative Data Selection Algorithm (CDSA) 49

"good quality" that is desired of the measurements. A long setup-time means thatthe minimum RTD measurements in the vector have been chosen from a largeamount of measurements and thereby have better accuracy.

After the setup-time the calibration-loop begins. This means that the wandersupervision test is applied on the vector and if passed then the first measurementin the vector is sent to the Kalman filter. After that the time difference betweenthe first and the second element in the vector (sample period) is used to compareif a new measurement is better than any of the existing in the vector and shouldbe included. A reserve value is kept and put into the vector as soon as a value hasbeen sent to the Kalman filter to always have the vector filled with values. Thereserve value is a measurement that is not good enough to replace an existing valuein the vector but that is the best value of all the values that have been comparedwith the vector.

When executing this selection algorithm only values with the shortest RTDwill be selected. In order for this to work it is essential to keep track of the times-tamps in the vector and continuously send measurements to the Kalman filter.The amount of time between two measurements sent to the Kalman filter must bethe same as the difference between their timestamps. The corresponding Kalmanfilter have to support variable sample size for this implementation to function. Thesample time in this case is the time difference between two consecutive measure-ments in the calibration vector. This solution does not suffer from the limitationsof a fixed window size for selecting values.

Initially it seems as if this solution does not have a window size but a closer lookat it makes it possible to identify the mean window size and the parameters thatcontrol it. The main feature is that the mean window size is variable dependingon the measurements and if a poor window size has been selected then there is apossibility to correct it. The parameters that control the mean window size are thecalibration vector size and the setup-time. The calibration vector size dictates howmany elements exists in the vector. A large amount of elements in the calibrationvector leads to a smaller mean window size. A large setup-time implicates thatthe time difference between the measurements are generally longer and therebya larger mean window size. As noticed, both parameters can change the meanwindow size independently. In this implementation the calibration vector size isset to a fixed value and only the setup-time is dimensioned in order to choose thedesired mean window size. For example by choosing the setup-time to be 1000measurement intervals and the calibration vector size to 100 it will result in amean window size of 100+1000

100 =11 measurements.It is also possible to implement the ability to change the mean window size

during runtime. The easiest way to achieve this is by changing the size of thevector. Reducing the size of the vector means that the mean window size willincrease and by increasing the size of the vector the mean window size will decrease.This is easy to realize by looking at the calculations above. A reduction of thevector size to 50 will result in 50+1000

50 = 21. Meaning that the new mean windowsize will be 21. The opposite follows for an increased vector of 200 ( 200+1000

200 = 6).Using this functionality enables the algorithm to further adapt the mean windowsize depending on the quality of the signals.

Page 64: High precision frequency synchronization via IP networks

50 Data Selection

9.3 Investigation of CDSAThe comparative data selection algorithm chooses the best available measurementsduring the setup time. Our usual setup time limit is at 24h. It is possible to extendor reduce this time limit but there are pros and cons in doing so. By reducing thesetup time, the CDSA has a shorter amount of time to choose values from. Thisleads to reduced quality of the values and the ability to avoid wander is reduced.By expanding the setup time, it is possible to choose better values and avoidlonger wander periods but the time for detecting the results from calibration isincreased. Meaning that it takes at least the setup time to detect the resultfrom the frequency adjustment that has been made. In order to guarantee bestfunctionality one should not calibrate more often than the setup time.

A positive feature about the CDSA is the ability to adjust the amount ofselected values, the vector length. A larger vector means that more values willbe selected during the setup time. This obviously leads to a reduced quality butif the reduction in quality is small and the number of increased samples is largethen it might be worth implementing. In the same way it is possible to reduce thesize of the vector and thereby increase the quality. The most interesting part withthe ability to change size during runtime is that the selection algorithm has theability to increase the number of samples when there are many good samples andreduce when there are few good samples. It sounds simple enough but has turnedout to be much harder then expected. The reason is that there is no simple wayof determining if the incoming samples are of good quality or bad.

Another useful feature with a variable vector size is that it is possible to makean filter that is adapted for a certain estimated error and let the CDSA changethe vector size according to the expected error. If the deviation of the collecteddata is less then the expected then it is possible to increase the size of the vectoruntil the deviation is as expected. If it increases above the limit then it is possibleto reduce the size of the vector until the deviation is within acceptable limits. Inthis case more samples are selected if the values are good and less samples if theyare bad. More details about this in section 9.4.

A downside is that this algorithm is more computationally expensive then theexisting one. Our measurements show that it is about three times slower. It ispossible to remove the reserve value part of the algorithm and thereby increasethe speed. Without the reserve value it is only about two times slower and thedecrease in quality is marginal.

Another drawback is that this DSA does not select values periodically and thusmakes it impossible to use with a steady state Kalman filter. It requires a filterthat can handle variable sample intervals. This means an additional increase incomputational cost due to continuous time calculations made by the filter.

In Fig. 9.3 the comparative data selection algorithm is compared to the stan-dard algorithm. In this comparison real collected data is used. The data is from asatellite link connection. It is easy to see that the CDSA manages to select bettermeasurements then the standard algorithm. In this case no TO calculations areavailable to compare but a reduction of the RTD usually means an improvementof the TO dispersion.

Page 65: High precision frequency synchronization via IP networks

9.3 Investigation of CDSA 51

Figure 9.2: Flowchart for the CDSA.

Figure 9.3: Satellite link data with high RTD.

In Fig. 9.4 the same comparison has been made but in this case simulated datais used. In this plot it is possible that a reduction of RTD results in less dispersionamong TO measurements.

Page 66: High precision frequency synchronization via IP networks

52 Data Selection

Figure 9.4: Simulated data with high RTD.

Page 67: High precision frequency synchronization via IP networks

9.4 CDSA with adaptive vector length 53

9.4 CDSA with adaptive vector lengthOne requirement was to develop a selection algorithm that has the ability to selectmore values if the signal quality is good and fewer values if the signal quality isbad. This is possible to achieve by CDSA. The biggest problem is to decide ifthe signal quality is good or bad. Potential ways of deciding this is by lookingat the TOWA or MAFE. By predefining an expected error and designing a filterthat is adapted for this error it is possible to change the size of the CDSA vectordepending on the actual error.

If our filter is adapted for an estimated error X and the actual measured error isat X/2 then it is possible to loosen the selection conditions and increase the size ofthe vector until the actual measured error is at X. If the signal quality deterioratesand the actual measured error becomes larger then X then it is possible to tightenthe selection conditions by reducing the size of the vector. The vector size dictateshow many samples are selected. In Fig. 9.5 it is possible to see how the numberof selected values differs depending on the TOWA limitations.

Figure 9.5: Difference in number of samples and precision.

Figure 9.6 shows a comparison between the standard selection algorithm, thestandard CDSA and the CDSA with variable vector size. In this simulation aninstant increase of the variation and amplitude is included in both uplink anddownlink in order to show the benefits of variable vector size.

Page 68: High precision frequency synchronization via IP networks

54 Data Selection

Figure 9.6: Comparison between standard selection algorithm,standard CDSA andCDSA with variable vector size.

Figure 9.7 represents the vector size at different times and by looking at it, it ispossible to see how the algorithm avoided the sudden increase simply by reducingthe sample rate.

The positive feature with this algorithm is the ability to become more selectivewhen the data is bad. The biggest negative issue is that the limits have to bepredefined. There are some scenarios where this algorithm is not recommended tobe used. This issue could be solved with some limitations but this also affects theresult of the algorithm.

Page 69: High precision frequency synchronization via IP networks

9.4 CDSA with adaptive vector length 55

Figure 9.7: Changes in the vector size.

Page 70: High precision frequency synchronization via IP networks

56 Data Selection

9.5 Separate minimum selection SMS (minUD andminDD)

One way of decreasing the difference between the uplink delay and the downlinkdelay is to extract them separately within a fixed period. This results in a decreaseof the roundtrip delay. In fact this will always result in lowest roundtrip delay andthereby indirectly a more precise time offset calculation. Uplink and downlinkdelay are defined as follows:Uplink delay = T2-T1 = t1+δ1− t1− ε1 = δ1− ε1Downlink delay = T4-T3 = t2 + δ2 + ε1 - t2 = δ2 + ε1This is the ideal case where uplink and downlink delay are calculated from thesame measurement time. By definition RTD = uplink delay + downlink delay.Minimum RTD measurement are of interested because simulations have shownthat smaller RTD generally means a more precise measurement of the time offset.This is mostly due to that the difference between the transport delays is smaller andthereby the time offset error becomes smaller (see Fig. 9.1). Instead of selectingthe minimum RTD, the minimum uplink delay value and the minimum downlinkdelay value will be selected. This will ensure that the difference between them iseven smaller than by choosing the minimum RTD. Simulations have shown verypositive results in decreasing the time offset error.

9.6 Comparison of SMS relative the minRTD se-lection

In order to demonstrate the improvement that the SMS delivers the comparisonwill be done to the min RTD value selection seen in Fig. 9.8. It is easy to see thatthe improvement is significant and that this is an selection method with a lot ofpotential. Not only is the RTD reduced but also the difference in TO calculationsis significantly reduced. The data in this case is simulated but resembles real data.

In Fig. 9.10 and Fig. 9.11 the same comparison as in the previous example aremade, except that the data used here is collected on an ADSL connection. Evenhere it is possible to notice a significant improvement.

Page 71: High precision frequency synchronization via IP networks

9.6 Comparison of SMS relative the minRTD selection 57

Figure 9.8: Current filter implementation vs. minUD/minDD selection.

Figure 9.9: Histogram over time offset values.

Page 72: High precision frequency synchronization via IP networks

58 Data Selection

Figure 9.10: Current filter implementation vs. minUD/minDD selection.

Figure 9.11: Histogram over time offset values for an ADSL connection.

Page 73: High precision frequency synchronization via IP networks

9.7 SMS error approximation 59

9.7 SMS error approximationA drawback with this approach is that another source of error is introduced inthe calculations. The positive thing is that this error can be approximated andit is also possible to compensate for it in the Kalman filter calculations. This isillustrated by the following example:Assume a frequency offset of the OCXO of 50 ppb (it is a worst case scenario).This will cause a time offset drift of 50ns/s and a difference of 500ns betweenmeasurements. Assuming a worst case scenario where the time difference betweentwo selected measurements is 20 min. This will result in a maximum difference of60µs between time measurements.This results in:Uplink delay = δ1− ε1Downlink delay= δ2 + ε2 = δ2 + ε1 + rr = 60µsTO=uplinkdelay−downlinkdelay

2 = −ε1− r2

As seen in the calculations above an error is introduced in the TO calculations.The error r is directly dependent to the time difference between the uplink anddownlink delay measurements and the current frequency offset. It would be easyto extract the difference between the measurements because all the measurementsare inserted in a vector as they arrive and therefore are sorted in ascending timeorder. Once it is known how many elements there are between the measurementsit is only necessary to multiply that amount with Ts (sample time) and the timethat has passed between them is known.

A second drawback is the current frequency offset. This can be approxi-mated with the frequency offset from the previous measurement period and thisis achieved by introducing feedback of the frequency offset in the Kalman filter.

H =(

1−Ts×L

2

)Where L is the number of elements between the two measurements in the

vector. This will compensate for eventual errors that arises due to selecting theuplink and downlink delay at different times. A relatively small source of errorwill still remain due to the approximation of the frequency offset. This error isunfortunately impossible to eliminate.

9.7.1 Tilted value selectionBy allowing the DSA to select minimum UD independently of the selection ofminimum DD there is no way to guarantee a maximum time difference betweenthe two values. There is also no way of knowing how the time difference betweenthe values is distributed. Calculations show that the time distance between thevalues will eventually converge to zero if the data collection is infinitely long. Theproblem is that it in the short term there is a high probability that the timedifference will only be single sided and this could lead to a wrongful estimation.

Page 74: High precision frequency synchronization via IP networks

60 Data Selection

In the example below the sampling has begun with the DD and UD is continuallybehind which results in an continuous error.

Figure 9.12: Illustration of how the samples can be selected.

The scenario in the example above turns out to be very common. Under aperiod of time the measurements seem to be tilted one way in order to tilt theother way during another period of time. This introduces a continuous offset inthe time offset calculations.

Figure 9.13: The sum of the time difference due to a large FO.

Considering a worst case scenario where all values are tilted one way duringthe whole measurement period. This could only happen if a large FO is presentwhich has created a large TO. Because UD = transport_delay − TO and DD =transport_delay + TO. This will eventually lead to that the TO grows and theUD values will only get smaller. Looking at the selection of UD and DD values itis easy to see that the smallest UD values are located at the end of the selectionlimit and the smallest DD values are located at the beginning of the selection limit.The larger selection limit the bigger the chance is that this will occur. But at thesame time the larger the selection limit the bigger the chance is that good valueswill be selected.

Page 75: High precision frequency synchronization via IP networks

9.8 Investigation of using SMS with the implemented algorithm 61

The time difference between selections is easy to follow. By always calculatingthe difference as UD_time−DD_time it is possible to observe the time differenceover time. In figure 9.13 there is a large FO and a selection limit of 100 values.The top plot shows the number of values between a selected UD value and thecorresponding DD value. The difference is not single sided even though a largeTO is present. But at the bottom plot it is possible to se that the sum off allthe deferens’s is tilted in one direction. This means that the scenario above ispossible. Simulations have shown that the tilting effect is most noticeable if thequality of the data is good. With a very stable network connection and low trafficthe change of the TO will have a bigger impact on the UD and DD values thenthe transport delay. In networks with a large TOWA the tilting effect will not benoticeable.

9.8 Investigation of using SMS with the imple-mented algorithm

It is possible to combine the current implementation together with minUD andminDD. The main difference will be that instead of selecting a value with minimumRTD two values will be selected, one with minimum UD and one with minimumDD. The simulations show that the only difference between selecting the min RTDand minUD and minDD is that the time offset wander amplitude is smaller. Thiscan be seen in the simulation Fig. 9.14 and Fig. 9.15.

Figure 9.14: Estimated time offset with values selected by minRTD.

These two comparisons were made with the same data and the same controlalgorithm. This is why there is no difference in the estimated TO. The controlalgorithm will not be able to estimate a value faster because the expected error

Page 76: High precision frequency synchronization via IP networks

62 Data Selection

Figure 9.15: Estimated time offset with values selected by SMS.

is still the same. It will instead make a more precise estimation due to moreprecise data and it will be possible to make an estimation with a lot worse datathan before. Looking at the time offset wander supervision it is possible to se animprovement. The time offset wander amplitude is a lot smaller which means thatthe chance of failing the TOWA supervision test is smaller.

The difference in computational effort will only be positive. The positive thingwith using a fixed window size is that the maximum time difference between twomeasurements is fixed and does not have to be controlled. Another positive sideeffect is that it is not necessary to consider the tilting effect.

9.8.1 Tilting effect in fixed window sizeConsidering a worst case scenario where the TO is so large that the tilting effectis completely dictating the selection of the UD and DD values and the DD valueselected is the first value in the vector and the UD value selected is the last valuein the vector.td = transport delayA = td +TO1B= td -TO2TO2=TO1+(TO2-TO1)=TO1+dd is the increase in TO that has occurred during the time passed from A to B thisis because the increase in TO is considered to be linear during that time.TO = B−A

2 = −TO1− d2

TO1− d2 is the time offset in the middle of the window.

This is ideal because the implemented Kalman filter only supports fixed samplingintervals and assumes that the values are in the middle of the window.

Page 77: High precision frequency synchronization via IP networks

9.9 CDSA with SMS and lookback 63

9.9 CDSA with SMS and lookbackTo further improve the selection process the CDSA can be combined with SMS.Based on the knowledge that CDSA will select the best measurements possibledepending on the selection criteria and based on the proven fact that SMS isa better criterion for good measurements then the minimum RTD will lead to abetter selection algorithm. Simulations show that this assumption was correct andthat the improvements are significant. The positive features from both methodscomplement each other well but there is also a risk of introducing additional errorif one is not careful enough. There is an essential reason why it is necessary tocontrol which values are selected by CDSA. A flowchart of the CDSAWSMS canbe found in Fig. 9.16

Figure 9.16: Flowchart for the CDSA with SMS.

There are different ways of controlling how the CDSA will choose differentvalues but simulations show the obvious conclusion that the CDSA will select thebest values if there are no restrictions on the algorithm. But with no restrictionson the algorithm in combination with SMS the results might be fatal. One simpleexample is when there is a large FO. UD consists of the transport delay minusthe TO while DD consists of the transport delay plus the TO. This leads to thatnew incoming UD values will become smaller as the TO drifts due to an existing

Page 78: High precision frequency synchronization via IP networks

64 Data Selection

frequency offset. In the same way the new incoming DD will get larger.In the best case this leads to an increasing difference between two separate

UD and DD values. In the case where a large FO is present the selected UDvalues will always be the latest and the selected DD values will always be theoldest. This will lead to fatal errors due to that the difference between two UDand DD measurements will be approximately 24 hours. The conclusion is that ifthe algorithm is going to work we have to restrict its selection process.

With the previous scenario in mind it is obvious that the restriction can notbe implemented at the end of the vector. The restriction has to be implementedin the beginning of the vector. Another conclusion to be drawn from the previousscenario is that the UD and DD values can not be compared to each other. The sizeof these values will depend on the actual TO. By adding these two values togetherand calculating the RTD the contribution from the TO is eliminated. This meansthat the UD and DD values could be collected separately but the comparison hasto be done with the calculated RTD.

Another limitation that has to be implemented is that the difference betweentwo different UD and DD values can not exceed a predefined limit. Simulationswere done with a maximum limit of 100 measurements between UD and DD values.Simulations show that this limit is rarely reached. The distance between UDand DD is for the most of the time shorter. Instead a lower limit of how manyvalues have to be compared before another value in the vector is replaced has tobe introduced. This limit is not mandatory because the algorithm will functionwithout. Without this limit there will be unnecessarily many replacements in thevector and with somewhat worse results. By setting this limitation to between10 and 40 elements the results will be reduced computational effort and betterresults.

9.9.1 Look-backThe idea with this method is to use the additional information available by usingSMS. The idea is to use both the previous and the next coming value to cal-culate the TO. It is best demonstrated in Fig. 9.17. The comparison betweenCDSAWSMS with and without look-back shows that there is only a small im-provement as seen in Fig. 9.18.

Figure 9.17: Illustration of how the samples can be selected with look-back.

Page 79: High precision frequency synchronization via IP networks

9.9 CDSA with SMS and lookback 65

Figure 9.18: Comparison between CDSAWSMS and CDSAWSMS with look-back.

The benefit with using Look-back is that the error r that is introduced everytime TO is calculated from UD and DD that come from different measurementsin time might be reduced. As previously mentioned the definition of UD and DDare:Uplink delay = T2−T1 = t1 + δ1− t1− ε1 = δ1− ε1Downlink delay = T4−T3 = t2 + δ2 + ε1− t2 = δ2 + ε1δ is the transport delay and ε is the TOWhen the UD and DD are from different measurements in time then an error r isintroduced. In the calculations only the two first UD values (A and B) and thefirst DD value (C) will be considered and the exact time is the time of C. Meaningthat A is sampled before C. B is sampled after both A and C. In order to easierdemonstrate the calculations the transport delay is assumed to be the same inboth A, B and C.A=d-e-raC= d+eB=d-e+rbTOa = A−C

2 = d−e−ra−d−e2 = −e− ra

2TOb = B−C

2 = d−e+rb−d−e2 = −e+ rb

2As seen in the calculations above the error r in the two TO calculations is of theopposite sign and will reduce the introduced error. In Fig. 9.19 it is possible tosee how the sum of the time difference increases because of the lack of balance

Page 80: High precision frequency synchronization via IP networks

66 Data Selection

between the selected UD and DD values. By using look-back together with theCDSAWSMS the sum is reduced. In Fig. 9.19a it is possible to see that the sumof CDSAWSMSL is smaller.

The problem with this comparison is that although the same data is used thesame selection algorithm is not used. In order to have a fair comparison twosimilar selection algorithms should be used. In this case there is also a significantdifference between the mean of the absolute time difference (MATD) between thesetwo. It is very important when comparing the time difference sum as will becomeclear later on. The MATD of figure 9.19b is 32 while MATD for the CDSAWSMSLin figure 9.19a is 14.

The comparison result between two CDSAWSMS with and without look-backis more relevant. Figure 9.20a shows CDSAWSMS without look-back and thedifference compared to the previous plot is not as large as before. This shows thatlook-back does not have a large impact on the sum of the time difference. TheMATD affects the sum in a more distinct way. In order to have a fair comparisonthe MATD is approximately the same in Fig. 9.19a as in figure 9.20a

By looking at Fig. 9.19b and 9.20b it is easy to see that the main control factorwhen it comes to the time difference sum (TDS) is the MATD. Figure 9.19b is aplot with MATD at 24 and Fig. 9.20b is a plot with MATD at 9. The sum hasincreased significantly with an increase in MATD and vice versa.

Considering the simulation results above the conclusion is that MATD has abigger influence on the TDS than the look-back. In most simulations Look-backbehaves as expected and reduces the error but there are also some simulationswhere the TDS is smaller when not using look-back. It depends entirely on thedata and is impossible to predict. The flowchart for the CDSA with SMS andLook-back can be seen in figure 9.21

Page 81: High precision frequency synchronization via IP networks

9.9 CDSA with SMS and lookback 67

(a) The sum of the time difference with look-back and MATD 14

(b) The sum of the time difference with MATD at 32

Figure 9.19: Comparison between CDSAWSMS with and without look-back.

Page 82: High precision frequency synchronization via IP networks

68 Data Selection

(a) The sum of the time difference with MATD at 24

(b) The sum of the time difference with MATD at 9

Figure 9.20: Comparison between MATD 24 and MATD 9.

Page 83: High precision frequency synchronization via IP networks

9.9 CDSA with SMS and lookback 69

Figure 9.21: Flowchart for the CDSA with SMS and Look-back.

Page 84: High precision frequency synchronization via IP networks

70 Data Selection

9.9.2 Investigation of reusing samplesIn the case of look-back sampling the same DD or UD is used in order to calculatetwo different TO values. This is something to be careful with. In the followingexample it is described why it is possible to do and what needs to be considered.In this case the difference between two different DD and one UD is used as can beseen in Fig. 9.22.

Figure 9.22: Difference between two samples.

Due to the fact that the TO is changing linearly it is possible to calculate theexpected TO between two known values. When using UD and DD from differentmeasurements it is essential to consider that the actual time of the calculated TOis between the two measurements. In the case above, the time of the calculated TOfrom C and B is time_cb and time_db is the time of TO calculated with D andB. This is important to consider when calculating the sample period. The calcu-lated TO_cb=−e+ r

2 is sent to the Kalman filter at time_cb and the calculatedTO_db=-e- r2 is sent to the Kalman filter at time_db with the notion that thetime passed between them is time_db− time_cb. This leads to that an estimatedTO at an estimated time is used.

The obvious downside is that if one value is not correct then this will result intwo incorrect values. Besides to this there seem to be no potential errors relatedto this procedure.

9.10 ComparisonThe simulation results from the CDSAWSMSL is shown in Fig. 9.23. In this plotit is possible to see the benefits from the combination. While the SMS is limitedby the minimum possible values the selected values will have a bottom limit wherethey will not descend further. Similar properties are identified in the CDSA. Thedifference in the CDSA is that the limitation is set by the maximum value inthe vector. This results in an upper limitation of the values. The positive thingwith combining these two is that the measurements will have both a lower and anupper limitation. The end result is that the dispersion of the measurements willbe reduced from both sides and thereby result in better values. The comparisonin Fig. 9.23, Fig. 9.24 and Fig. 9.25 is done with simulated data. The data usedin these figures is sinus_data and is shown in section 9.12.

Page 85: High precision frequency synchronization via IP networks

9.10 Comparison 71

Figure 9.23: Roundtrip delay when simulating uplink and downlink delay with asinusoidal.

Minimizing the dispersion of the RTD values will also result in minimizing thedispersion of the TO values as seen in the Fig. 9.24.

The histogram in Fig. 9.25 shows that it is easier to see how the selected TOvalues are gathered around a specific value. The black staples are CDSAWSMSLvalues. In the comparison between the CDSAWSMSL and SMS it is possible to seea slight displacement of the centered value. This is because the data has sinusoidalvariations on the UD and because SMS can not avoid this like CDSAWSMSL itwill result in a variation in the TO calculations. In table 9.1 is a mathematicalcomparison between the different algorithms. The definition of TOWA and MAFEis in chapter 2.

Method Time Offset Wan-der Amplitude(TOWA) ms

Mean AbsoluteForecast Error(MAFE) ms

Standard DSA 9.91 0.7864Comparative DSA 3.78 0.62Separate Min Search(SMS) 3.6 0.377CDSAWSMS 1.78 0.22CDSAWSMS with Look-back 1.383 0.198

Table 9.1: Mathematical comparisons between different algorithms with simulateddata.

Page 86: High precision frequency synchronization via IP networks

72 Data Selection

Figure 9.24: Time offset when simulating uplink and downlink delay with a sinu-soidal.

Figure 9.25: Time offset comparison between CDSAWSMSL and SMS.

Page 87: High precision frequency synchronization via IP networks

9.10 Comparison 73

In this case ADSL_data is used. Seen in Fig. 9.26 is the RTD, Fig. 9.27 showsthe TO and Fig. 9.28 compares the TO with histograms. The improvement inthis case is not substantial. The reason is that the quality of the data in this caseis good and it is not that important to choose the best values because most of thethem will produce good results.

Figure 9.26: Round trip delay for ADSL-data.

As seen in Fig. 9.27 and in table 9.2 the SMS (fixed window size) performedbest with this data. These were somewhat unexpected results considering thelarge difference in the previous comparison. In this comparison the CDSAWSMSwithout look-back performed somewhat better than look-back which was not ex-pected. The difference between these algorithms in this case is so small that itis not possible to draw a conclusion from the results. The main reason why thiscomparison is in the report is that it is important to make a comparison withreal data and not only simulated data. The important part to notice is that dataselected using SMS methods resulted in better TO values even with real data.

Page 88: High precision frequency synchronization via IP networks

74 Data Selection

Figure 9.27: Time offset for ADSL-data.

Figure 9.28: Histogram for different comparisons.

Page 89: High precision frequency synchronization via IP networks

9.10 Comparison 75

Method Time Offset Wan-der Amplitude(TOWA) ms

Mean AbsoluteForecast Error(MAFE) ms

Standard DSA 1.15 0.169Comparative DSA 1.14 0.16Separate Min Search(SMS) 0.756 0.087CDSAWSMS 0.752 0.099CDSAWSMS with Look-back 0.76 0.1

Table 9.2: Mathematical comparisons between different algorithms with ADSL-data.

Page 90: High precision frequency synchronization via IP networks

76 Data Selection

In Fig. 9.29 and Fig. 9.30 the comparison is performed with drift_data. Itis necessary to see how the selection algorithms behave when there is a large FOand the TO is increasing constantly. This comparison will show if a constantlydecreasing UD and an increasing DD will effect the SMS algorithms ability tochoose good values.

Figure 9.29: Round trip delay variations with drifting data.

The simulations show that the SMS algorithms are not affected by a large FOand still choose better values than the standard DSA.

Method Time Offset Wan-der Amplitude(TOWA) ms

Mean AbsoluteForecast Error(MAFE) ms

Standard DSA 6.77 0.83Comparative DSA 4.22 0.68Separate Min Search(SMS) 2.295 0.32CDSAWSMS 1.79 0.2785CDSAWSMS with Look-back 1.79 0.2785

Table 9.3: Mathematical comparisons between different algorithms with driftingdata.

Page 91: High precision frequency synchronization via IP networks

9.11 Computational effort 77

Figure 9.30: Time offset variations with drifting data.

The conclusion from the comparisons is that SMS is a better selection criteriathan minimum RTD and that the benefits of using CDSAWSMSL are greatestwhere the signal quality is very poor. These conclusions are based on many dif-ferent comparisons with different data and not only the comparisons above.

9.11 Computational effortThere is an increased computational effort for the introduced data selection algo-rithms compared to the current implemented selection algorithm. An increase isexpected mostly due to the low computational cost of the current implementation.The question is if the increase in computational cost is motivated by the improve-ment in the ability to select more and/or better measurements. The comparisonfollows in table 9.4.

These comparisons were made in Matlab by measuring the cpu-time elapsedwhile doing the computations required by the algorithm. These numbers cannot be trusted completely. During performance testing some irregularities werediscovered in the cpu-time measurements. One example is while measuring on thecurrent implemented algorithm extreme variations in CPU-time were discovered.CPU-time varied from 0.005 to 0.78 depending on the selected approach and CPU

Page 92: High precision frequency synchronization via IP networks

78 Data Selection

load. The difference in CPU load was eliminated by running many continuoustests and calculating a mean time.

The second problem encountered was that there was a huge difference in timedepending on how the data was compared. If the data was compared one elementat a time the CPU-time required to complete the algorithm has approximately0.015. If the data was inserted small vectors and a min search was applied thenthe CPU-time became greater between 0.29 and 0.55. The large difference in timeprobably depends on while doing continuous comparison the compared value isstored in CPU cache memory and that results in a huge performance increase.

One large difference in the CPU-time measurements derived from using differ-ent ways of inserting values in vectors in Matlab. Depending on which method wasused the CPU-time differed. One kind resulted in CPU-time of 0.29 and the otherin 0.55. In the other cases there was no comparison between different methods.They contain a mix of both types. The result can be viewed in table 9.4. All thecomparisons were made on the same data and the number of elements used perrun was 86400.

Name Properties CPU-time ComparedImplemented DSA Fast method 0.29 1Implemented DSA Slow method 0.55 1minUD and minDD Fast method 0.2 0.7 timesCDSA Mixed 1.1 2-4 timesCDSA Mixed without reserve value 0.7956 1.5-3 timesCDSAWSMS Mixed 1.064 2-4 timesCDSAWSMSL Mixed 1.056 2-4Implemented Kalman filter - 0.25 1VSTA Kalman filter Ordinary 1.48 6 timesVSTA Kalman filter Optimized 1.0764 4 times

Table 9.4: Computational effort for described algorithms.

MinUD and minDD results in a faster selection algorithm than the imple-mented. The reason is that minUD and minDD does not calculate RTD and TOfor every measurement. It only calculates RTD and TO for the selected UD andDD. Other than that these two algorithms are practically the same. In table 9.4the case "CDSA without the reserve value" the storing of reserve values has beeneliminated in order to increase the performance. The reserve value is not an es-sential part of the CDSA and the results are not affected significantly by removingthis functionality. In the optimized adaptive Kalman filter some simplificationshave been implemented to make it more efficient. One example is replacing thecalculation of HPHT where P is a 2x2 matrix and H = [1 0] is a 1x2 matrixcontaining only a one in the first element. The simplification in this case is thatonly the first element in the P matrix is selected and the matrix calculation isreduced.

The total computational increase is the one from the DSA and from the Kalmanfilter calculations together. Due to the variable sample period it is not possible

Page 93: High precision frequency synchronization via IP networks

9.12 Simulation data 79

to continue using the steady-state Kalman filter. Variable sample period leads tovariable gain parameters that have to be calculated before every estimation. Theconclusion is that in order to implement more advanced features such as adaptivefiltering or CDSA the low computational cost steady-state Kalman filter is notadequate.

9.12 Simulation dataThe majority of the simulations are done with generated data. In order to havereliable simulations it is important that the data used resembles real data. In Fig.9.31 there are four histograms that show the RTD from different data. The reasonfor this is to compare the distribution of real measurements and the distributionof the generated data. In the first histogram the data from an ADSL connection ispresented. The second is from a satellite link and the third contains data collectedby the measurement node on Ericsson’s local network. The last histogram containstypical distribution of the generated data that is used in the simulations and it hasbeen generated with a Matlab random variates generator that is called randraw.The distribution selected to generate the data is a Weibull distribution where theparameters have been configured in order to resemble the real distributions.[5]

Figure 9.31: Histogram over different generated/measured data.

Figure 9.32 shows real data collected from an ADSL line. This data has pre-

Page 94: High precision frequency synchronization via IP networks

80 Data Selection

viously been normalized and is why it was necessary to add a constant portion toboth the UD and the DD in order to avoid negative RTD.

Figure 9.32: ADSL data.

Figure 9.33 shows the sinus_data as it is called in the rapport. This is the datain the forth histogram in Fig. 9.31. It has been generated in order to simulate ahigh load on the network during the day and a lower load during the night, therebyexplaining the sinus pattern on the UD plot. It has different transport delays inthe different directions. The transport delay of the UD is much grater than of theDD.

In the drift_data shown in Fig. 9.34 there is a large FO which leads to thatthe data received will drift in some direction. There is a small difference betweenthe UD and DD transport delay. The reason for generating this data is to simulatereal conditions where the TO is not constant.

Page 95: High precision frequency synchronization via IP networks

9.12 Simulation data 81

Figure 9.33: Simulated sinus data.

Figure 9.34: Simulated drifting data.

Page 96: High precision frequency synchronization via IP networks

82 Data Selection

9.13 Outlier detectionA very common way of discarding values that are not satisfiable is called outlierdetection and is principally a way of statistically determining if a value is incorrector not.[6] The ξ-2 test looks like this: T = (zk−Hxk)2

Rk+HPkHtThe variables have the same

names as in the Kalman filter section 8.3. After calculating the value T it shouldbe compared to the acceptable probability and decided if the value is an outlieror not. If it is classified as an outlier it should be removed to not contaminatethe rest of the data. The main problem with the outlier detection that needs tobe solved to make it work is that it is crucial to have an accurate estimate of theerror covariance R. The error covariance R in the case of measuring through NTPis hard to estimate correctly due to large variations of network delays.

Outlier detection is mostly used to detect occasional anomalies on the mea-surements. This makes it ideal to use with the calibration vector. In contrast tothe granularity vector that contains a lot of bad measurements where the majorityshould be removed, the calibration vector contains only good measurements. Theidea is to apply outlier detection on the calibration vector. This should eliminatethe problem where one bad granularity period can contaminate the whole calibra-tion vector. R can be approximated by calculating the mean deviation from themean square fit calculation. The value T dictates how certain the outlier detectorhas to be in order to eliminate a value.

It is not hard to show where outlier detection could be useful. One examplewhere it can be useful is if the data looks like in Fig. 9.35. Relatively good dataexcept for some random spikes.

Figure 9.35: Measured real data.

In Fig. 9.36 it is possible to see that these random spikes have also made their

Page 97: High precision frequency synchronization via IP networks

9.13 Outlier detection 83

way through to the selected data. The data in the plot has been selected by theimplemented selection algorithm.

Figure 9.36: Current algorithm.

The outlier detection in this case has been done depending on the mean squarefit calculation.Zk is the actual value. Hxk has been modeled as the corresponding mean squarefit value ktk + M. Where tk is the corresponding time in the mean square fit(MSQF) vector. The standard deviation in this case is modeled as the absolutemean deviation from the MSQF. The HPHT is neglected in this implementationdue to its small size.

Results from the outlier detection can be found in Fig. 9.37 In this case thecovariance R is set to four times the standard deviation squared in order to notmodel the error with a too small value. By setting the T value to one and filterout all values that have T larger then one it is possible to identify and eliminateall the outliers in both cases. This implementation is proposed for use in the timeoffset wander supervision. By using this it is possible to remove outliers that wouldcause the time offset wander test to fail.

Page 98: High precision frequency synchronization via IP networks

84 Data Selection

Figure 9.37: Before, during and after outlier detection.

Page 99: High precision frequency synchronization via IP networks

9.14 Rapid synchronization 85

9.14 Rapid synchronizationWhile trying to improve the synchronization in bad quality networks it becameobvious that the same algorithm could be used for fast synchronization if thesignal quality is good. The main reason is that the variable sample time adaptive(VSTA) Kalman filter is initiated with an uncertain start condition. This meansthat the initial measurements will be used in order to make a rough estimation.After that the gain will successfully be reduced in order to make a more exactestimation. By using this method the estimation time will be shorter relativeto other estimation methods where the initial value is assumed to be correct. Ifthe synchronization time is reduced then it is possible to simplify the handlingof SIU:s. The idea is to combine the measurement node together with the rapidsynchronization procedure. Below follows a proposed implementation of how it ispossible to combine these two.

By placing a SIU on site and activating the measurement mode the SIU willcontact all the timeserver it has access to and start collecting data. After a periodof time it will have all the required information in order to decide if it is possibleto do a rapid synchronization. First of all decide if it is possible to rate thequality of the connections to the different timeservers and choose the best forsynchronization.

With the collected data during the measurement period it is possible to decideif the signal quality is good enough to do a rapid synchronization. If the disper-sion of the data is within predefined limits. It is also possible to make a roughestimation of the FO and decide if it is within acceptable limits of if the rapidsynchronization should be initiated. If the signal quality is too bad or the FO isextremely large then it might not be recommended to do a rapid synchronization.In this case the SIU could send a message that the rapid synchronization failed andthe synchronization must be done manually. If the conditions are met then themeasurement is continued with the best timeserver and together with the collecteddata it is possible to make a rapid synchronization.

In Fig. 9.38 it is possible to see how a rapid synchronization could synchronizeten times faster than the current implementation.

Page 100: High precision frequency synchronization via IP networks

86 Data Selection

Figure 9.38: Fast synchronization.

Page 101: High precision frequency synchronization via IP networks

Chapter 10

Conclusions and Discussion

10.1 Conclusions

10.1.1 EstimationThe investigation of the implemented Kalman filter has shown that it is possibleto loosen the existing limitations. Calculations and simulations show that it istheoretically possible to handle TOWA larger than five times the maximum limitwithout changing the current implementation. Unfortunately it has not been pos-sible to verify these results in practice but we have been able to partially confirmthese theories thanks to our associates in Älvsjö. They have tried using this al-gorithm at worse signal quality than the maximum limit and achieved positiveresults. Our conclusion is that the limit could be raised to at least the doublewithout any problems, it should also be possible to raise it to three times the limitand still have a safety margin. Our theory of why this limit is used is that thesignal quality of the connection should be better then that and if it is not thenthere must be a better connection to another timeserver. So the point of the limitis probably only a recommendation to change to another timeserver.

Investigation of how the synchronization could be improved by using an adap-tive Kalman filter that considers the signal quality in its estimation shows thatthere are some potential benefits with this method. The positive thing is that dou-bling the limit does not correspond to doubling the rise time. If the same safetymargin is used as in the current implementation it is possible to synchronize withtwice the limit at the cost of increasing the rise time to by a third. In order touse the same safety margin it is necessary to either significantly overestimate theerror or considerably increase the required accuracy in the adaptive Kalman fil-ter. Otherwise the only difference will be a large reduction in rise time and anestimation that is more susceptible to wander variations compared to the currentimplementation. The conclusion is that it is possible to synchronize with worsesignal quality by using an adaptive Kalman filter but due to the very low gain ofthe current implementation it will only be beneficial if the signal quality is muchworse then the current TOWA limit.

87

Page 102: High precision frequency synchronization via IP networks

88 Conclusions and Discussion

The main benefit of using the VSTA Kalman filter is that it is compatible withmore advanced selection algorithms that return data sporadically. Another benefitis that it considers both the frequency adjustment and uses old data compensationwhich will reduce the overshoot significantly. Best results are achieved when usedin combination with the comparative data selection algorithm as it was designedfor. The conclusion is that it should only be implemented together with thecomparative selection algorithm.

10.1.2 Data selectionThe investigation of the current selection algorithm shows that there is room forimprovement. One improvement is a better selection criterion than selecting val-ues with minimum RTD. A better selection criterion is the separate minimumselection of the UD and DD measurements. The measurements selected using thiscriterion usually have less dispersion and are more precise, as has been verified inboth generated random data and real collected data. The investigation of possibleerror introduced by this method show that it is not necessary to consider it in thecalculations. The reason is that the frequency is stable which leads to that theTO will change linearly and by setting the common time of the measurement inbetween the UD and DD measurements there will be no introduced error. Con-sidering that this requires a small change to the current selection algorithm andis compatible with the current Kalman filter our conclusion is that this changeshould be implemented.

Another improvement that should be implemented is to change the selectionmethod so it is able to sample when there is a low network load and reduce thesampling when there is a high network load. This is possible by using the com-parative selection algorithm at the cost of an increased computational effort. Thecombination of the comparative selection and the separate min selection comple-ment each other well and the end result is a much better selection algorithm. Inorder to use this selection method it is necessary to implement a more advancedKalman filter e.g. VSTA.

10.2 Future StudiesField testing should be done in order to investigate if the simulations are correctand the maximum limit could be increased. Preliminary studies show that byanalyzing the changes in UD and DD it is possible to trace the change in TOcalculations. An increase in UD will result in a increase of the TO and a in-crease in DD will result in a decrease of the TO. This makes it possible to relateseparate changes in UD and DD to the changes in TO and thereby increase theaccuracy. This implementation is computationally expensive and therefore notfurther investigated in this report.

Page 103: High precision frequency synchronization via IP networks

Bibliography

[1] GPS Time Server, February 2010,URL: http://www.ntp-time-server.com/gps-time-server/gps-time-server.htm.

[2] NTP Time Server Accuracy, February 2010,URL: http://www.atomic-clock.galleon.eu.com/support/ntp-time-server-accuracy.html.

[3] IEEE 1588 Website, February 2010,URL: http://ieee1588.nist.gov.

[4] Ericsson AB. Internal documentation.

[5] Gunnar Englund Jan Grandell Lars Holst Gunnar Blom, Jan Enger. San-nolikhetsteori och statistikteori med tillämpningar. 5 edition, 2005. ISBN91-44-02442-8.

[6] Fredrik Gustafsson. Statistical Sensor Fusion. LIU tryck, 2008.

[7] David L Mills. Network time protocol (version 3) specification, implementa-tion and analysis, february 2010. URL: http://www.ietf.org/rfc/rfc1305.pdf.

[8] Kannan M. Moudgalya. Digital Control. John Wiley & sons, 1 edition, 2007.ISBN 978-0-470-03143-8.

[9] Patrick Y.C. Hwang Robert G. Brown. Introduction to random signals andapplied kalman filtering. John Wiley & sons, 3 edition, 1997. ISBN 0-471-12839-2.

[10] Lennart Ljung Torkel Glad. Reglerteori. 2 edition, 2003. ISBN 91-44-03003-7.

89