Few weeks ago Cloudflare released its newer implementation of Network Time Security (NTS) protocol in Rust. NTS protocol is the next iteration of Network Time Protocol (NTP). This blog post will talk about the performance testing Network Time Protocol using Apache JMeter. I will post another article once NTS is matured for Windows platform.
Before I started writing about NTP, I searched it in world wide web, (basically Googled/Binged) surprisingly there is no reference, blog posts or article about performance testing Network Time Protocol using any available tools. This urged me to do some research and publish my findings.
What is Network Time Protocol?
Here is the definition from Wikipedia:
The Network Time Protocol (NTP) is a networking protocol for clock synchronization between computer systems over packet-switched, variable-latency data networks.
Now let’s first deal about DNS performance testing in Apache JMeter. The same approach for DNS performance testing helped me to test the NTP protocol.
DNS Performance Testing
Below are the tools that you need to download for DNS and NTP performance test scripting in Windows 10.
Fire up Wireshark and attach the interface, usually it will be your WiFi or LAN. In the capture filter, enter the below syntax and hit ENTER.
Click on Start icon (blue one, just below to File menu) to start capturing the trace.
udp.port == 53
Open command prompt and enter the below command which will get captured in Wireshark.
Above command will give you below output.
Now, head back to Wireshark, you could see below trace.
Optionally, you can save this trace for future reference.
It’s time for scripting
Launch JMeter, and make sure you have installed JMeter Plugins Manager. In Plugins Manager, you need to install UDP Protocol Support sampler. You can learn more about UDP Protocol here.
We need to leverage UDP Request to test DNS and NTP protocols.
Add the below elements to your test plan and save it.
- Thread Group
- [email protected] – UDP Request
- View Results Tree
In this example, we will script for DNS Cloudflare’s 126.96.36.199 server. Configure below details in the UDP request.
- Hostname/IP as 188.8.131.52
- UDP Port 53
Now, head back to Wireshark and click on client request where it says A qainsights.com
Once you selected that row, Wireshark will display the details in the below pane.
You need to right click on the Domain Name System (query) as shown below, go to Copy > … as a Hex Stream.
Paste the copied Hex Stream in UDP Request Data.
Hit Save and click on Run and then head to View Results Tree.
In the Response Data, you will see something as below.
It is not in readable format. Go to https://codebeautify.org/hex-string-converter and enter the hex stream to convert into text format. You will see qainsights.com text and some other gibberish characters.
You can compare the hex stream data from Wireshark and JMeter to see the difference. Make sure that you are selecting the correct request and response in Wireshark.
Other way to test DNS is, by using DNS encoder/decoder class kg.apc.jmeter.samplers.DNSJavaDecoder
If you are using kg.apc.jmeter.samplers.DNSJavaDecoder class, make sure the Request data is set to qainsights.com. A IN.
The response data would be
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 44044 ;; flags: qr ra ; qd: 1 an: 2 au: 0 ad: 0 ;; QUESTIONS: ;; qainsights.com., type = A, class = IN ;; ANSWERS: qainsights.com. 110 IN A 184.108.40.206 qainsights.com. 110 IN A 220.127.116.11 ;; AUTHORITY RECORDS: ;; ADDITIONAL RECORDS: ;; Message size: 64 bytes
Performance Testing Network Time Protocol using Apache JMeter
To test the NTP, you can use UDP Request sampler. In JMeter, add another UDP Request and configure below details.
- Hostname/IP as time.windows.com
- Port as 123
You can check this link for NTP servers across the world. By default, Windows uses time.windows.com, Apple uses time.apple.com, Cloudflare uses time.cloudflare.com and so on.
Next in our action item is to create a NTP request using Wireshark. before that, we need to capture the NTP traffic using Wireshark.
Open Wireshark and configure the filter as udp.port == 123 and hit Start capture icon.
Launch command prompt and enter the below command which will hit time.windows.com and gives you the current time.
w32tm /stripchart /computer:time.windows.com
You will series of time stamps, to stop receiving the time, press CTRL + C.
Now, head back to Wireshark where you will see the trace. Select the request row and right click on Network Time Protocol and copy as Hex Stream as shown below.
Paste the Hex Stream into JMeter UDP request.
Save your script and hit run. You could see the response data in JMeter as shown below.
Run your JMeter script multiple times, every time the response data will vary.
To validate, go to Wireshark, and copy the NTP server response’s hex stream and compare it with your JMeter response. Both should be identical.
Server response time will be in UTC, you can validate the UTC time with your local time zone. Just google, utc time now
Please do not run high volume load unless you are authorized to do so.
Here is my GitHub repository where you can download the sample JMeter test plan for your reference.
By leveraging UDP Request, you can test DNS and NTP protocol in Apache JMeter. In couple months, DNS over HTTPS and Network Time Security will reach to the masses and it will be ubiquitous, it is critical to early test the performance and be ready for the future.
Please do not forget to subscribe QAInsights.com newsletter.