While the primary focus of JMeter is on application-level HTTP-based testing, it also supports protocol-level TCP/IP testing using the TCP sampler. In this post, we will review the basic setup of the TCP Sampler, and how to use it in your JMeter tests.
This component allows JMeter testers to simulate network-level protocols and evaluate the performance of systems that rely on TCP/IP messaging, but not necessarily HTTP calls. Examples of these include internet of things (IoT) devices, embedded systems, and non-standard protocol communications.
Using the TCP Sampler
Conceptually, using a TCP Sampler is not significantly different from ordinary HTTP Requests. These samplers can be added to and controlled by the same thread groups as other types of samplers that test more conventional web applications. This means that TCP Samplers can be scaled and profiled in similar ways.
When setting up a TCP Sampler, there are a few required fields that must be configured in order to attain meaningful results. At a minimum, we must define our Server Name or IP address and Port Number that we intend to send TCP/IP packets to. In addition to this, a TCPClient
class name is also required. Per the official documentation for this component, the following implementations are supported:
TCPClientImpl
– this is a basic implementation which will read TCP data from a socket until an end-of-line byte (tcp.eolByte
) is encountered, or until the end of the transmitted stream is reached.BinaryTCPClientImpl
– this implementation reads binary data into a hexadecimal expression until an end-of-message byte (tcp.BinaryTCPClient.eomByte
) is encountered, or until the end of the transmitted stream is reached.LengthPrefixedBinaryTCPClientImpl
– this extends the aboveBinaryTCPClientImpl
implementation and prefixes message data with the binary length.
If no TCPClient
class name is specified, JMeter will use the default TCPClientImpl
class.
Use cases for the TCP Sampler
Low-level TCP/IP testing in JMeter enables testers to analyze the behavior and performance of network protocols beyond the application layer. It allows simulating the communication between client and server at the network protocol level, giving insights into how the application performs under various network conditions, packet loss scenarios, or even testing network equipment.
Some specific potential use cases for the TCP Sampler include:
- Evaluating Protocol Resilience – Challenging scenarios can be simulated which cause unreliable connections, high latency, or packet reordering. This enables identifying potential vulnerabilities or areas for improvement in the application’s protocol implementation.
- Realistic Network Simulation – TCP Samplers can be scaled using advanced thread groups and can simulate various network conditions to evaluate an application’s performance. By introducing latency, packet loss, or throttling the network bandwidth, testers can replicate real-world network scenarios and assess the application’s behavior and response time accordingly.
- Compatibility Testing – This type of testing can assess compatibility across different network protocols, versions, or implementations.
Conclusion
Low-level TCP/IP testing with JMeter using the TCP Sampler opens up unique possibilities for performance analysis for applications relying on non-standard, non-HTTP network protocols beyond the application layer. By simulating real-world network conditions, testers can identify bottlenecks, enhance protocol resilience, and ensure compatibility across different protocol versions, and ensure applications that can withstand varying network challenges.
Did you know that RedLine13 offers a full-featured, time-limited free trial? Sign up now and start testing today!