9 ms·
FPGA NTP Server
- lxe 6y agoDoesn't jitter depend more on the network latency, rather than the real-timeliness of the process?
- mlyle 6y agoJitter is the variation in latency of all sources. The latency of the A) delay in the original packet being sent + B) the latency of the network itself + C) latency of the ntp server receiving the packet + D) latency of the process answering the packet + E) latency of the kernel sending the response + F) the latency of the network itself for the return pack + G) the latency of the client receiving the return packet and giving it an accurate local time mark. On a uncongested LAN, B & F can be very low in absolute terms and low in variation. This server constrains C, D, & E to basically nothing. So only A & G-- the limitations of the client itself -- remain. How long does it take to receive the frame, get it to system RAM, dispatch an interrupt (which may be coalesced), service the interrupt, and context switch to/wake up the right client process? Alternatively, the network driver can capture a timestamp at the moment the packet is received, eliminating a lot of this variation. NTP clients assume half of the delay is client->server and half is server->client, for the purpose of computing offset. That is, they subtract half the roundtrip delay off the received time. So reducing delay in C, D, & E further reduces the amount that this guess can be wrong by.
- fortran77 6y agoWhy not PTP too?
- wmf 6y agoPTP seems like a telco/enterprise thing; hackers don't care about it.
- jbronn 6y agoI personally enjoyed the challenge of setting up PTP at home. Why would a hacker scoff at nanosecond-level timekeeping —- isn’t the entire internet a “telco/enterprise” thing?
- jstrong 6y agodid you write about your experience? I am interested in this but have very limited knowledge about it at this point.
- varjag 6y agoInstall linuxptp on the boxes you designate as grandmaster and client. On your grandmaster clock host: ptp4l -i eth0 -m On the client: ptp4l -i eth0 -s & If you want to sync client system clock and watch the synchronization process: phc2sys -a -r -m
- wmf 6y agoTo do PTP "right" requires every switch to support it and a NIC with hardware timestamps. Also, I've seen claims that PTP is no more precise than a good implementation of NTP.
- markfeathers 6y agoptp is <1us synchronization. From my testing NTP is ~20-60us after about 10 minutes of sync, but it intentionally drifts the phase around. On average, NTP is pretty close. If you look at the white rabbit FPGA PTP updates, its in the ns range. Any kind of GPS + most intel nics will get you PTP with an accurate clock. If you didn't need to sync too many devices you could use a single system with a bunch of nics as your "switch".
- willis936 6y agoThis post didn’t sound right to me, but I realized that my raspi4 GPS NTP server has been running ntp and not chrony. Chrony is better at modeling non deterministic timing behavior, so I swapped to that. It’s been ten minutes now and chronyc tracking has been marching the offset down. It’s sub 1 us at this point. System time : 0.000000123 seconds fast of NTP time Last offset : +0.000000366 seconds How to get this precise time out of a non deterministic OS? Beats me. Once I figure that out I can finish my clock project. My best lead is to step through the different python timing and scheduler implementations and see which has the lowest jitter relative to the PPS on an oscilloscope.
- mobilemidget 6y agothe reason I read hacker news comments, I never heard of PTP. So I started google'ing. And now I know more and am happier :) thanks for that quick link for those like me https://linux.die.net/man/8/ptp4l https://linux.die.net/man/8/ptp4l
- fortran77 6y agoThe reason I asked was if you’re already taking packets apart with an FPGA and you have the accuracy, it’s a logical next step.
- williesleg 6y agoYou can build a stratum 1 pretty easy with sdr
- jstrong 6y agohow much would it cost to buy the underlying hardware?
- jsolson 6y agoLess than $200. The board there is overkill -- if you really want something with a Zynq including an Arm Cortex A9 that can run Linux, the Arty Z7 from Digilent is another Zynq board that's essentially a one-stop shop for this: https://store.digilentinc.com/arty-z7-zynq-7000-soc-development-board/ https://store.digilentinc.com/arty-z7-zynq-7000-soc-developm... However, for something as simple as an NTP server you could easily get away with an Arty A7: https://store.digilentinc.com/arty-a7-artix-7-fpga-development-board/ https://store.digilentinc.com/arty-a7-artix-7-fpga-developme... From there you can instantiate either Xilinx's Microblaze MCU _or_ you could stick to Arm and use one of Arm's DesignStart cores (Cortex-M1 or Cortex-M3): https://developer.arm.com/ip-products/designstart/fpga/fpga-xilinx https://developer.arm.com/ip-products/designstart/fpga/fpga-... Glancing around Digilent's catalog, they've got an even cheaper Zynq board: https://store.digilentinc.com/cora-z7-zynq-7000-single-core-and-dual-core-options-for-arm-fpga-soc-development/ https://store.digilentinc.com/cora-z7-zynq-7000-single-core-...
- jstrong 6y agothank you for providing all this info! as someone who doesn't know much about fgpa boards, what does it mean when you write "From there you can instantiate either Xilinx's Microblaze MCU"? Also, one thing that is confusing to me is that the source code that is linked on this page is a .h and .c file, is the fgpa on these zynq boards programmable with C code?
- deleted 6y ago[deleted]
- Cyph0n 6y agoThey mean putting a “soft” CPU core on the FPGA. “Soft” means the CPU is added to your overall design as a block and is compiled along with your design to the FPGA bitstream. This way, the CPU ends up being implemented (instantiated) on the FPGA. This approach eats into your overall FPGA resource budget and leads to lower CPU performance due to the FPGA overhead. The alternative to a soft core is a “hard” CPU core, which simply means that the CPU is included in a separate area of silicon (usually on the same die). The Zynq 7000 is a good example.
- hummo56 6y agoInteresting project, especially to gain insights into the FPGA programming part. I think it is essentially a mixture of PTP and NTP now. I guess this will work within the same local network, as the major inaccuracy of NTP comes from the asymmetric path delays at the network layer over the Internet. PTP solves this by incorporating these hardware timestamps exactly. But this works only within the same LAN. Here is an interesting PTP core: https://github.com/freecores/ha1588 https://github.com/freecores/ha1588 Yes it is "old" but that is typically fine with HW projects.
- mlichvar 6y agoThe main difference between PTP and NTP is that PTP relies on hardware support in switches and routers. Those are not cheap. If they had the same support for NTP, it would perform as well. A highly accurate stratum-1 NTP server can be build with a common computer NIC. No need to mess with FPGAs (unless that's your thing). The Intel I210 is about $50. It has a PPS input and output. With some calibration, the timestamping can be accurate to few tens of nanoseconds. NTP can work very well between directly connected NICs. But without hardware support in the switches/routers, that accuracy degrades quickly in the network. A single switch can easily add hundreds of nanoseconds worth of jitter and tens of nanoseconds worth of asymmetry.
- varjag 6y agoPTP at this point is ubiquitous and cheap. It is hard to source a PHY that has no support for it in 2021. > If they had the same support for NTP, it would perform as well. Unless you'd extend NTP to become PTP, it absolutely wouldn't.
- mlichvar 6y agoYes, NICs with support for hardware timestamping are common (it's typically in the MAC, not PHY), but switches that have a good support for PTP, either as a boundary clock, or transparent clock, are not cheap. At least I have not seen one yet. Do you have any examples? Some switches support NTP as a server and client (equivalent to the PTP boundary clock), but there don't seem to be any using hardware timestamping. It's just the classic ntpd using software timestamps, good to few tens of microseconds at best. And yes, NTP could definitely perform as well as PTP if the switches had a proper support. In my tests with directly connected NICs the synchronization is stable to few nanoseconds, same as with PTP. At the protocol level, they use the same timestamps.
- JoachimS 6y agoThere exists an open source NTP server project by Netnod in Sweden. The servers has been up and running, providing NTP including NTP AUTH services since about 2015. The FPGA based platform also provides experimental NTS services since about last summer. https://www.netnod.se/ntp/connect-to-ntp-servers https://www.netnod.se/ntp/connect-to-ntp-servers https://github.com/Netnod/FPGA_NTP_SERVER https://github.com/Netnod/FPGA_NTP_SERVER
- magicalhippo 6y agoFor less demanding users, a Raspberry Pi and a cheap GPS module can do the trick[1]. I get less than +/-300us in error according to chronyc on the clients. Note that if you get one of the GPS modules, some do not expose the PPS pin to the headers, so might require some board modification (they use it just to drive a LED). I got one like this[2] that has it exposed. Also note that the small antennas only work outside, the slightly larger square ones work inside but very near a window. I got an active antenna[3] as I wanted it more inside the room. And finally the NEO-6M module I linked to is quite old, the newer NEO-7M and NEO-8M lock on faster etc, but for me this was sufficient. Oh and I had to disable serial echo[4], almost forgot about that. [1]: https://n4bfr.com/2020/04/raspberry-pi-with-chrony/2/ https://n4bfr.com/2020/04/raspberry-pi-with-chrony/2/ [2]: https://www.aliexpress.com/item/4001136384325.html?spm=a2g0s.9042311.0.0.27424c4d9irCeq https://www.aliexpress.com/item/4001136384325.html?spm=a2g0s... [3]: https://www.aliexpress.com/item/33059221782.html?spm=a2g0s.9042311.0.0.27424c4d9irCeq https://www.aliexpress.com/item/33059221782.html?spm=a2g0s.9... [4]: https://raspberrypi.stackexchange.com/a/104296 https://raspberrypi.stackexchange.com/a/104296
- LeonenTheDK 6y agoThat reminded me of Mitxela's GPS clock[0]. Using GPS modules to get an incredibly accurate time is really interesting, I need to find some time to make one of these. [0]https://mitxela.com/projects/precision_clock_mk_iii https://mitxela.com/projects/precision_clock_mk_iii
- lmilcin 6y ago> Microprocessor based Network Time Protocol (NTP) servers suffer from a large amount of timestamp jitter, due to the hardware and Operating System (OS) being shared among other applications. So instead of configuring Linux correctly and dedicating a core for your NTP you have created custom hardware. Congratulations, now you have two problems. I have been working on algorithmic trading and it is not that hard to reliably (like 100% of the time) respond within couple microseconds. You will never notice it, though, because your network will introduce way more variability. This is especially the case with NTP which usually is a single box shared between large number of servers throughout your network.
- varjag 6y agoYes, doing things fast is the unremarkable part. Doing things fast and synchronously over the network is the trickier one.
- gbrown_ 6y ago> dedicating a core for your NTP Heh as soon as I read this I thought "algo trader?". If you don't mind me asking outside of trading how often do you see systems seriously manage jitter (specifically I'm thinking about interrupt management). I'm in HPC and whilst some such management is present it seems seldom thought about.
- lmilcin 6y agoHeh, I already thought somebody will point it out. See, they decided to create custom hardware just to do NTP. How is instead dedicating a single core a worse solution? Setting dedicated core is basically configuration detail. There are no gains from custom hardware as network variability would mask them. If you want really good time guarantee because having right time is critical for your application, you put atomic clocks in your servers as one well known company does. Also, it is customary to have dedicated machines for various functions. You would not normally want to mix some different types of loads that conflict with each other, for example high security with low security, high throughput with real time, etc. You could just configure a single machine dedicated to NTP (which is customary), but instead of sharing cores between OS and NTP (and introducing jitter) you can have separate core for the OS and separate for NTP so that NTP can work undisturbed. So if you maintain an NTP instance and have problem with jitter and you red this article my hint is: don't set up custom FPGA to fix your problem, just dedicate single core on a machine you already have and you will get as good results as you can.
- pjmlp 6y agoThe ultimate unikernel. :)
- traceroute66 6y agoBoy is this a timely thread ! I've been looking into doing a little COVID lockdown project consisting of a multi-GNSS timeserver. Does anyone have examples of projects using something like the UBlox ZED-F9T [1] which can do concurrent connections to 4 GNSS constellations ? I'm not an electrical engineer, so unfortunatley I lack the skills to design a PCB from scratch. ;-( [1]https://www.u-blox.com/en/product/zed-f9t-module https://www.u-blox.com/en/product/zed-f9t-module