How to simulate network speed in JMeter?

Following are the steps to simulate the network speed (data transfer speed) in JMeter:

1. Open the jmeter.properties file located in the /bin folder of JMeter

Simulate Network Speed in JMeter
Figure 01: ‘jmeter.properties’ file

2. Search for the keyword “cps”

Simulate Network Speed in JMeter
Figure 02: Search with ‘cps’ keyword

3. If you search using “cps” then you will get two properties:

  • httpclient.socket.http.cps=0
  • httpclient.socket.https.cps=0

Remove “#” to enable the properties

Simulate Network Speed in JMeter
Figure 03: Remove ‘#’

The first property simulates the speed when you use the HTTP method (protocol) and the second property is used to simulate the speed for the HTTPS method.

4. Calculate the value using the below formula or use CPS Calculator:

CPS = RB * 128

where:
CPS = Characters per second
RB = Required Bandwidth that you need to set for the load test. The input value of the required bandwidth should be in kbps.

Simulate Network Speed in JMeter
Figure 04: Calculate and insert the value for CPS (say 64000)

5. Save and close the file

Example:

To understand the calculation let’s take an example: If you want to simulate 500 kbps speed for your test then the calculation will be:
=> cps = 500 x 128
=> cps = 64000

So, you need to set:

httpclient.socket.http.cps=64000

Hence JMeter will send the data with a speed of 64000 characters per second and you will achieve 500kbps network bandwidth.

How to set bandwidth using the command line option (non-GUI mode)?

To set the speed in the non-GUI mode, use the below command:

jmeter -Jhttpclient.socket.http.cps=<calculated value> -n -t <path of .jmx> -l <path of .jtl>

Points to remember: 

  • Check the testing environment network bandwidth (where the test to be conducted) before simulating the speed. Because JMeter can only simulate the bandwidth equal to or less than the testing environment network bandwidth.
  • Use RB (Required Bandwidth) value in kbps for CPS calculation.  

You may be interested: