What is IP Spoofing
IP spoofing is used to simulate real-time requests for a web application during performance/ load testing. IP spoofing hits the web application with multiple virtual users from different IP addresses using a single Load Generator. This technique relays to the web server that your HTTP requests are not a threat.
Why? IP Spoofing is required
As simulated by JMeter the request goes via the Load Balancer, hits Server A and gets a Cookie. If the following request will go to the Server B it will not be authenticated (due the Load Balancer Stickiness mechanism) as for the moment only Server A knows about this user and accepts its Cookie unless local caches are replicated into a Shared Cache.
Assume the above situation when all requests sent from JMeter are hitting Server A only, and Server B is not receiving any load. As a result, how can be ensure whether your application is scaling correctly or not and the results of the load testing are valid. See, how to simulate requests originating from different IP addresses in your JMeter test using single LG machine.
How to configure IP Spoofing in Jmeter
To simulate real time user behavior while conducting performance testing, we need to hit the application (target server) with multiple virtual users using multiple IP addresses from a single Load Generator (LG) to keep the web server from blocking those virtual users. So, we will go for IP spoofing concept, to achieve this we will configure few settings in network connection of LG.
Go to your control panel -> Network Connections window, right click on the interface and choose “Properties”
Another option to reach this window is by pressing Win+R combination, typing ncpa.cpl and hitting Enter.
On the next window choose “Internet Protocol Version 4” and click “Properties” again.
It will open following window
And uncheck Obtain an IP address automatically and set the IP address, netmask, gateway, and DNS servers manually (check the IPs are available under the same subnet).
Note: IP address of your machine may be changed, so first you need to open CMD > type ipconfig command to check your machine info as
Once you configured the manual IP address, click the “Advanced” button. It will take you to Advanced TCP/IP Settings configuration window where you can click the “Add” button and add as many IP addresses as necessary in addition to your main IP address.
See, we added the 10.20.30.40 IP address. For the “255.255.255.0” netmask, it is possible to have 253 extra IP addresses (256 minus broadcast address minus network address minus primary IP) but in fact you are only limited with your gateway configuration.
How to add multiple IP addresses from Command-Line Mode
- A quick and better option is using the Windows Command Prompt and netsh add command so adding a single IP address is as simple as:
netsh interface ipv4 add address “Wi-Fi” 10.20.30.40 255.255.255.0
- To verify those IP addresses whether are working or not, use the following command
curl –interface 10.20.30.40 -I example.com
- To verify all IP addresses are added successfully, use command “ipconfig” and it should show all newly added addresses
Jmeter Configure for IP Spoofing
Now we need configure these IPs to JMeter that send the request using these IPs. Add the HTTP Request Sampler to the Thread Group, in advanced tab u can find IP/Hostname dropdown box and give the IP which we added through network settings.
Given the following JMeter configuration:
- Thread Group with 1 thread and 1 loop
- HTTP Request
- Server name: localhost
- Port Number: 8080
- View Results Tree Listener
This is the default View Results Tree listener output containing sample start time, load time, body size, response headers, etc.
To pass multiple IP addresses add a csv data set config and pass the csv file, where the IP addresses have been added and pass the variable name.
Now hit the target host by setting No of threads (users) and duration and check the server logs u can find the load was generating from multiple IPs. In this way we achieve IP spoofing through JMeter in performance testing.
LoadRunner – IP Spoofing Configuration
LoadRunner itself includes the IP Wizard program that you run on each load generator to create multiple IP addresses. You add new IP addresses to a machine once and use the addresses for all performance scenarios.
Invoke the IP Wizard on the load generator by going to Start menu then Software then IP Wizard.
Note: You need to turn off DHCP on your network card before you can use the IP Wizard. If DHCP is on, you will receive the following message when you try to start the IP Wizard.
Enabling multiple IP addresses from the LoadRunner Controller
Once you defined multiple IP addresses, you need to set an option to tell the controller to use these IPs. To do that, follow these steps:
- In the Controller Design view, select Scenario then Enable IP Spoofer. Note: You must select this option before connecting to a load generator.
- Enable Expert Mode (in the controller, click Design Tab, Tools menu then click Expert Mode).
- Under the General Options of the Controller Expert Mode, specify how the controller should allocate the multiple IP address mode. To allocate an IP per thread, select IP address allocation per thread.
Note: If you run LoadRunner with all configured settings that have been listed above and then you run the netstat -nt command on the server machine/command prompt, you should see that all IPs are being used by LoadRunner (shown below).
Enabling IP Spoofing from Performance Center
Once you setup multiple IP addresses, you can enable IP spoofing for a load test. Note: You must enable IP spoofing before running a load test.
To enable IP spoofing from the user site:
- On the Performance Center left menu, select Load Tests then Manage. The Load Tests page opens, displaying all the load tests in the current project.
- Click the load test for which you want to enable IP spoofing.
- On the Load Test configuration page that opens, click the General tab.
- Under Advanced, select Enable IP Spoofer.
- Click Save to save your settings.
Good article…
Knowledgeable content.