Coding Challenge #28 - NTP Client
John Crickett
Helping you become a better software engineer by building real-world applications.
Coding Challenge #28
This challenge is to build your own Network Time Protocol client.
Network Time Protocol (NTP for short) is one of those protocols that is fundamental to the Internet and most modern computer systems but very rarely thought about by most of us.
Obviously we want our local computer’s time to be correct, but as we build distributed systems it also becomes important to ensure that all the computers within our systems are synchronised to the same, correct time. Sharing the correct time across servers is key for:
Coding Challenges Live Edition.
I'm thinking of running another Cohort based course in November. I'd love to know what would you like added to the course?
The previous course covered:
?? Breaking a project down into stages.
?? Selecting a tech stack for your project.
?? Documenting your decisions and explaining them using Architecture Decision Records.
?? Writing automated tests and running them in a CI pipeline.
?? Reviewing code (and having your code reviewed).
?? Understanding concurrency - async versus threads.
?? Optimising for performance.
Over a three week period as part of the process of building your own Redis Clone.
Full detains of the previous course are here: https://maven.com/coding-challenges/challenge-redis
What else would you like to see included in the course to help you become a better software engineer?
领英推荐
The Challenge - Building and NTP Client
NTP is a networking protocol for clock synchronisation between network attached devices. It is one of the oldest Internet protocols in current use.
NTP is intended to?synchronise computers to within a few?milliseconds of each other.?It uses the?intersection algorithm, a modified version of?Marzullo's algorithm, to select accurate?time servers?and is designed to mitigate the effects of variable?network latency.
Over the public?Internet NTP can usually maintain time to within tens of milliseconds and on a local area network can usually do better than one millisecond accuracy.
However, asymmetric?routes?and?network congestion?can cause the accuracy to decrease.
The protocol is usually described in terms of a?client–server model, but can also be used in?peer-to-peer?relationships.?Clients and servers using NTP send and receive?timestamps?as UDP packets on?port 123.
The full protocol is defined in the NTP RFC which is RFC 5905.
Step Zero
In this step you’re going to set your environment up ready to begin developing and testing your NTP client solution.
I’ll leave you to setup your editor and programming language of choice. I’d encourage you to pick a tech stack that you’re comfortable doing network programming in.
Step 1
In this step your goal is to send a request to an NTP server and receive the response back. You’ll need to contact the NTP server on port 123. The message you’ll need to send is defined in the RFC under section 7 on page 19. Take care to understand which fields you set for the outgoing message.
NTP uses a hierarchical, semi-layered system of time sources. Each level of the hierarchy is termed a?stratum?and is assigned a number starting with zero for the reference clock at the top.
A server synchronised to a stratum?n?server is considered to be a stratum?n?+ 1 server. The number represents the distance from the reference clock and is used to prevent cyclical dependencies in the hierarchy. The stratum is not always an indication of the quality or reliability of the server.
For this challenge you can find a list of time servers you can use here or you can use one from the NTP Pool Project.
The packet you get back will have the same structure as packet you sent, check that the first three fields are correct then proceed to Step 2.
Continued...
You can find Step 2 and beyond on the?Coding Challenges?website as Write Your Own NTP Client.
Or if you'd rather get the whole challenge delivered to you inbox every week, you can subscribe on the?Coding Challenges Substack.
AUM University, B.Sc in IST
1 年I agree, and I'm eager to tackle these listed challenges.
Manager, Software Engineering @ Disney Ad Platform ?? | Founding Member of Latinx in Tech ERG @ Disney ????
1 年Hehe I was just recommended this newsletter because coincidentally NTP bit me this weekend: https://www.dhirubhai.net/posts/ian-sherwood_raspberrypi-time-ntp-activity-7111789966518587392-Q4PT?utm_source=share&utm_medium=member_ios
Dreaming of electric sheep.
1 年I wrote my own basic game engine a while ago, and those skills have proven extremely useful in game design! I learnt about shader compilation, OpenGL, XML (I wrote my own basic shader schema), scene management and resource management. Did some python to import blender meshes into my own mesh format. A sh*t ton of research to be honest. I'm not a very mediatic person so it didn't make me famous, nor rich, but now I can tackle algorithmic, graphical and behavioral tasks with relative ease on probably any game engine. When you go and master the basic principles on which this world runs, everything can be made easy or at least easier.
Software Engineer @ Bank of America
1 年How much for the course on maven?