Send JMeter Requests from Different IPs in Windows OS
Date Published: 10/16/2019
There are few articles/tips available online on how to add multiple IPs in the adapter but here I am primarily focusing on each step how you can add multiple IPs in Windows operating system and use it in JMeter's HTTP Request Source Address.

Get the JMeter load Test, IPs CSV and helping files from following Github Repository:

https://github.com/fullstackhub-io/JMeter-CLI-Load-Test-Dashboard-Multi-IPs

Introduction

I was looking for adding multiple IPs to simulate a real-world load testing environment in JMeter and this article really helped me to start: https://www.blazemeter.com/blog/how-to-send-jmeter-requests-from-different-ips/. Since this is for Mac OS and I am more a Windows OS user, I want to list down steps in Windows.

Let's Start

  • If you are Windows 10 user and using LAN, follow this GIF screenshot, I was reading that you can't add static IPs in WIFI adapter so I blindly believe it:

  • In the above screenshot, we just click on the bottom right corner of the taskbar on the Network Internet Access icon. In the opened window, we are clicked on the Ethernet side menu and then Change Adapter Options. Once the adapter option is opened, double click on the Ethernet connection icon to go to its properties. 
  • In the Ethernet Properties window, Double click on Internet Protocol Version 4 (TCP/IPv4) item to view its properties.   

  • If you already have static IP and Use the following IP address radio button is selected, you are good to go but if you have Obtain an IP address automatically option selected, we need to get the dynamically assigned IP and Gateway, follow these two subtasks.
    • Go to the command prompt: Win + R and Type cmd in Run window. Type the command ipconfig/all that will give you IPv4 Address, Subnet Mask and Default Gateway and other helpful information e.g. DNS Server, etc.
    • Enter the IPv4 Address, Subnet Mask, Default Gateway, DNS Servers from command result as following and hit the OK button, check your network is good and the internet is working fine:   
  • Now we have static IP, repeat the steps to go back to above-given Internet Protocol Version 4 (TCP/IPv4) Properties window. Click on the Advanced... button. You would see one IP Address in the IP addresses Listbox that we just configured in the above steps. 

  • We need to add more static IPs to simulate the multi-user load in JMeter, in order to find the unused IP address, try a few IPs in the same class by pinging them. e.g. ping 192.168.1.195 and ping 192.168.1.198 in command prompt. If the requests are returning the host is unreachable error, we can use these IPs. Click on Add... button under IP addresses Listbox and add the unused IPs, the subnet mask would automatically be populated once you will click on the textbox. Press the OK button. Also, click the OK button in Internet Protocol Version 4 (TCP/IPv4) Properties and Ethernet Properties windows.
  • Ping the newly added IPs, you should get the reply if it successfully configured. So now we have three IPs configured in our system. Open the command prompt and type the command: ipconfig, you should see all added IPs:

  • This is a very simple test, calling google.com for multiple users and showing the results in Result Tree, the number of users, ramp-up time and a number of loops are configurable through parameters. The only problem is that all users are using one default system IP so the real-world testing where there are multiple users with different IPs is not applicable here that we are going to do next. 
  • First create a CSV file of all IPs we configured earlier i.e. 192.168.1.194, 192.168.1.195 and 192.168.1.198 (You need to add your configured IPs) and name it as IPs.csv (or any preferred name).
  • In the article_jmeter test plan, right-click on Test Plan and select Add -> Config Element -> CSV Data Set Config. Select the newly created IPs.csv file as FileName and SourceIP as Variable Names. All IPs will be loaded in SourceIP variable in runtime.  

  • Next, select the HTTP Request and go to Advanced Tab in the right panel. In Source address, enter the SourceIP variable as IP/HostName. That's it. Now JMeter will send the request from multiple IPs. 

  • The last step before running the test is to add the HTTP Header Manager to view the IP in the request. Right-click on HTTP Request, select Add -> Config Element -> HTTP Header Manager. Add the x-Forwarded-For key with SourceIP variable value:

  • That's it, run the test plan by pressing the green button on the top ribbon and select the View Result Tree. Go to Request Tab and select the HTTP tab from the bottom, you would see x-Forwarded-For in the Request header. Click on different requests, you would see that these requests are sent by our newly added IPs. You can add as many IPs as you want:


Keywords: Send JMeter Requests from Different IPs in Windows,how to send imeter requests from different ip in windows