Windows Subsystem for Linux for testing Windows 10 PTP Client

This post has been republished via RSS; it originally appeared at: Networking Blog articles.

Hi Folks,

 

Program Manager Dan Cuomo here to chat about setting up one of the most important new features outlined in #10 on our Top 10 Networking features in Windows Server 2019, Precision Time Protocol (PTP).

 

As a quick refresher, you can visualize the benefit of PTP (IEEE 1588v2) by thinking back to the last thunderstorm you experienced.  The further away you are from the lightning, the larger the audible delay in the thunder (you don’t see AND hear at the same time unless you’re very close to the lightning).  This is not just the difference in speed of sound vs the speed of light, but the delay introduced by the environment such as nearby cars and buses, buildings, and many others.PTPthunderstorm.png

 

In timing, latency (delay) is a killer – If you’re in the financial services, video broadcasting, gaming, or numerous other industries you’re painfully aware of this.  As timing is distributed in the network, the accuracy and certainty of that measurement degrades like the sound of the lightning as you move further from the source.

 

PTP is a new (to Windows) time synchronization protocol that helps to remove the noise and asymmetry in the network that reduces the accuracy of a traditional time synchronization protocol. 

PTPSwitch.png

 

One of the challenges customers have is setting up and testing the Windows Client as it requires a time server that can speak PTP; you cannot use an NTP server to speak to a PTP client.  So, in this blog, we’ll show you how to easily setup and test PTP with a linux grandmaster – All on a single physical machine!

 

Disclaimer: These instructions are point-in-time; at the time of writing (3/27/19), these instructions work however future changes to the various components included here might affect your success in the future.

 

Video

Let me first prove this works then you can use the instructions below to try it out yourself!

Instructions

These instructions reference three different locations where you will need to perform an action.

 

Windows 10 Client: This is a Windows 10 version 1809 or later physical host system.  This is the only physical system needed for this exercise.

 

Windows Server 2019 VM: This is a virtual machine installed on the Windows 10 Client and will be the PTPv2 (IEEE 1588v2) slave.  In this example we use a Windows Server 2019 system as the PTP slave, however a Windows 10 system can also work.  Creating this virtual machine is outside of the scope of these instructions.

 

Ubuntu on WSL: This is a Windows Store app that runs the Windows Subsystem for Linux on the Windows 10 Client and will operate as the PTP Grandmaster.

 

On the Windows 10 Client navigate to our GitHub Repo - In this example we will use the unicast configuration file in this repo.

 

Click on the unicast configuration for PTPd (last one in the list shown below)Annotation 2019-03-31 154900.jpg

 

 

Next, click Raw and copy the contents into notepad and save the file in your preferred location with a .conf extension. In this example, we’ve saved the file to c:\temp\PTPd\PTPdUnicast.conf.  You will later access this file directly, from within the /mnt folder on the Ubuntu on WSL instance.14.jpg

 

Important Note: Please make sure that the file has a blank line at the end of the file

 

Open Hyper-V Manager on your Windows 10 Client and attach the VM to a virtual switch. In this example, we use the default switch however any virtual switch can be used so long as it is not a private virtual switch.4.png

 

In Hyper-V Manager, select the virtual machine and note the assigned IP Address. If you’re not using the default virtual switch, you may need to assign one.5.png

 

Open the Windows Store on the Windows 10 Client and search for Linux or Ubuntu and install the Windows Subsystem for Linux application6.png

 

Once installed, select start and launch Ubuntu7.png

 

Ubuntu on WSL

 

First launch will take a few minutes; please be patient.8.png

 

Enter a username, then a password9.png

 

Run sudo apt-get update.  This updates the packages that are on the system and will require internet access.10.png

 

Run sudo apt-get install ptpd.  This installs the PTP package that will operate as the PTP grandmaster11.png

 

Run ls /mnt. WSL mounts the local file system inside the Ubuntu instance.  c indicates the drive letter that is shared between this WSL Linux system and your Windows 10 client.12.png

 

Next, run ls /mnt/c/temp/PTPd13.png

 

Run ifconfig

ifconfig.png

 

Identify the interface on the same subnet as your Windows Server 2019 VMinterface.png

 

Windows 10 Client

Modify the line ptpengine:interface = eth0 to use the interface identified in the last stepa.png

 

Next modify the ptpengine:unicast_destinations value with the IP address of the Windows Server 2019 VMb.png

 

Ubuntu on WSL

Run sudo ptpd -c /mnt/c/temp/PTPd/PTPdUnicast.conf to start the PTPd grandmaster.c.png

 

Next, run ps -aux | grep ptpd to identify the PID of the PTPd.  If you want to restart PTPd, you use this PID to kill the process.

 

Windows Server 2019 VM

Modify the registry to Configure PTP. This step also disables the VMIC and NTP Client in order to guarantee we’re getting time using the correct provider.

 

This is the IP from Ubuntu on WSL (eth2 in the example above)

Root Key

HKLM\SYSTEM\CurrentControlSet\Services\W32Time\TimeProviders\PtpClient

Type

Name

Value

REG_SZ

PtpMasters

172.17.75.17

REG_DWORD

Enabled

1

REG_DWORD

InputProvider

1

REG_SZ

DllName

"c:\windows\system32\ptpprov.dll"

REG_DWORD

DelayPollInterval

0x3e80

REG_DWORD

AnnounceInterval

0x0fa0

REG_DWORD

EnableMulticastRx

0

Root Key

HKLM\SYSTEM\CurrentControlSet\Services\W32Time\TimeProviders\NtpClient

REG_DWORD

Enabled

0

Root Key

HKLM\SYSTEM\CurrentControlSet\Services\W32Time\TimeProviders\VMICTimeProvider

REG_DWORD

Enabled

0

 

Next, restart the Windows Time Service and open the PTP ports in the Windows Firewall using an elevated PowerShell prompt.

New-NetFirewallRule -DisplayName 'PTP-319' -Name 'PTP-319' -LocalPort 319 -Direction Inbound -Action Allow -Protocol UDP

 

New-NetFirewallRule -DisplayName 'PTP-320' -Name 'PTP-320' -LocalPort 320 -Direction Inbound -Action Allow -Protocol UDP

Install and Launch Wireshark.  Start a capture and filter using the following filter: udp.port in {319 320}d.png

 

You should see Announce, Sync, and Delay_Req, Delay_Resp messages.e.png

 

Note: Be patient ? You should see Announce and Sync messages immediately however you may need to wait a few minutes to see the Delay_Req and Delay_Resp.  While you’re waiting, you can go on to the next step.

 

Open the Event Viewer > Applications and Services > Microsoft > Windows > Time-Service-PTP-Provider > PTP-Operational.  First verify you see event 512 which will occur once announce messages are received.

f.png

 

Next verify that you receive event 513 which indicates that you have successfully selected the PTP Master as the source of time.g.png

 

 

That’s it!  Now that you’re system has chosen the PTP master, you’re synchronizing time.  You can further verify this by running w32tm /query /status /verbose to verify that the last synchronization was successful.

h.png

 

If you’re trying to test out PTP, you can get your feet wet using the Windows Subsystem for Linux which is a nifty little tool that enables Linux to run natively on Windows.  Obviously this approach will not yield high accuracy however if you’re looking to easily demonstrate the functionality, this might be the easiest approach for you!

 

Thanks for reading,

Dan Cuomo

Leave a Reply

Your email address will not be published. Required fields are marked *

*

This site uses Akismet to reduce spam. Learn how your comment data is processed.