DEV Community

NaveenKumar Namachivayam ⚡
NaveenKumar Namachivayam ⚡

Posted on • Updated on

Network Time Protocol Performance Testing using Apache JMeter

Introduction

Recently, Cloudflare released its newer implementation of Network Time Security in Rust. Network Time Security (NTS) is the next iteration of Network Time Protocol (NTP). You can learn more about NTP in Wikipedia. Surprisingly there is no information found in the internet about NTP performance testing using Apache JMeter.

Do not perform high volume tests unless you are an authorized user.

Detailed instructions can be read in here

Prerequisites

  • Basic understanding of JMeter
  • Basic understanding of Wireshark

How to script NTP using Apache JMeter?

As many of the developers aware, that Apache JMeter is an 100% pure Java application and an open source load testing tool which supports most of the protocol including HTTP(S), DNS, NTP, FTP, Database via JDBC, SMTP(S) etc.

Scripting NTP in JMeter is not a straight forward like HTTP(S) or Web Services. By leveraging Wireshark tool, it is possible and easy to script NTP requests.

Wireshark is the widely used network protocol analyzer. It is simple to use and you can trace the requests by attaching your local interface.

For scripting purpose, we are going to leverage Cloudflare's time service URL time.cloudflare.com at the port 123.

JMeter Setup

You need to install Plugins Manager for JMeter to install the UDP Request Sampler.

Add the following elements to your test plan.

  • Thread Group
  • UDP Request
  • View Results Tree

In UDP Request, enter the Hostname/IP as time.cloudflare.com, Port as 123, and Data Encode/Decode Class as kg.apc.jmeter.samplers.HexStringUDPDecoder.

Now, launch Wireshark and attach your network interface (usually it will be your WiFi or LAN) and filter out the traffic using the filter udp.port == 123.

Fire up your cmd prompt and enter w32tm /stripchart /computer:time.cloudflare.com and hit enter. To stop getting time, hit Ctrl + C.

Go back to Wireshark to see the NTP requests and responses.

Copy the Hex Stream data of the NTP request and paste the data into JMeter UDP Request. Below image has the NTP request for time.windows.com.

JMeter UDP Request for time.windows.com

Hit Save and run your test plan for one thread. Now go to View Results Tree to check the response which will be in Hex Stream format.

If you compare your JMeter NTP request and response data in Wireshark, both should matchy.

If you keep firing the NTP requests, you could see the response data varies. It's because, every instance the current timestamp changes. All the responses will be in UTC.

Conclusion

By leveraging the Wireshark and JMeter, it is easy to test the performance of NTP servers.

Top comments (0)