Performance Testing Network Time Protocol using Apache JMeter

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.

NTP is intended to synchronize all participating computers to within a few milliseconds of Coordinated Universal Time (UTC).

NTP was designed by David L. Mills of the University of Delaware. It is one of the oldest protocol in use even today.

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.

  1. Wireshark (latest version)
  2. Apache JMeter 5.1.1

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
Wireshark Capture Filter
Wireshark Capture Filter

Open command prompt and enter the below command which will get captured in Wireshark.

nslookup qainsights.com

Above command will give you below output.

nslookup
nslookup

Now, head back to Wireshark, you could see below trace.

Wireshark DNS Trace
Wireshark DNS 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.

Performance Testing Network Time Protocol using Apache JMeter  - UDP Protocol Support
Performance Testing Network Time Protocol using Apache JMeter – UDP Protocol Support

We need to leverage UDP Request to test DNS and NTP protocols.

Add the below elements to your test plan and save it.

  1. Thread Group
  2. jp@gc – UDP Request
  3. View Results Tree

In this example, we will script for DNS Cloudflare’s 1.1.1.1 server. Configure below details in the UDP request.

  • Hostname/IP as 1.1.1.1
  • 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.

Copy as Hex Stream
Copy as Hex Stream

Hit Save and click on Run and then head to View Results Tree.

In the Response Data, you will see something as below.

0002818000010002000000000a7161696e73696768747303636f6d0000010001c00c000100010000012c000468123d7ec00c000100010000012c000468123c7e

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	104.18.61.126
qainsights.com.		110	IN	A	104.18.60.126

;; 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.

time.windows.com
time.windows.com

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.

NTP Response
NTP Response

Paste the Hex Stream into JMeter UDP request.

UDP Request for NTP
UDP Request for NTP

Save your script and hit run. You could see the response data in JMeter as shown below.

1c0300e90000004c000007cd1942e602e169c18be3b980bfe169bdfa1817367de169c1951398a9afe169c1951398c635

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.

Conclusion

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.

About the Author

1 thought on “Performance Testing Network Time Protocol using Apache JMeter”

  1. Hi Naveen
    Found this article very useful. Is there any way to load test Network Time Security(NTS) protocol using Apache JMeter or any other tool available?
    Thanks.

    Reply

Leave a Comment

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

Hamster - Launch JMeter Recent Test Plans SwiftlyDownload for free
+
Share via
Copy link