IP spoofing using localAddress

How do we use localAddress ? I would like to submit a request with different IP address so load balancer will route the request to all servers instead of one server. Server configuration is sticky IP and so if I use 200 user load test it goes to single server. Need to distribute the load on each server.
I have 10 Ip address in my data file(csv/txt file)

val httpProtocol = http
// .inferHtmlResources(BlackList(""".*\.js""", """.*\.css""", """.*\.gif""", """.*\.jpeg""", """.*\.jpg""", """.*\.ico""", """.*\.woff""", """.*\.(t|o)tf""", """.*\.png"""), WhiteList())
 .acceptEncodingHeader("gzip, deflate")
 .contentTypeHeader("application/x-www-form-urlencoded; charset=UTF-8")
 .userAgentHeader("Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/42.0.2311.135 Safari/537.36")

Thank you.

localAddress currently takes a static java.net.InetAddress value, so you can’t have a per virtual user value.
Please open a feature request.

Until then, you can have as many populations as you have cluster nodes, and have each of them use a different value:

val commonProtocol = http…
val http1 = http.localAddress(address1)
val http2 = http.localAddress(address2)

val scn = scenario…


This is a must needed feature. So far, I have been “Scaling out” to simulate multiple IPs.

Ticket created https://github.com/gatling/gatling/issues/2725

I found the changes that implements InetAddress as an expression. Will you be kind enough to show how to use it.

Is it something like the following:

val address = ""
val address2 = ""

setUp(scn.inject(rampUsers(1) over (0 seconds)).protocols(httpProtocol.localAddress(address)),
  scn.inject(rampUsers(1) over (0 seconds)).protocols(httpProtocol.localAddress(address2))


In Java, you build a InetAddress with a static factory method.

Instead of duplicating the scenarios, I would load balance manually:

val address1 = java.net.InetAddress.getByName(“”)
val address2 = java.net.InetAddress.getByName(“”)

def randomLocalAddress = if (ThreadLocalRandom.current.nextBoolean) address1 else address2

val localAddressFeeder = Iterator.continually(Map(“localAddress” → randomLocalAddress))


Note that, of course, you won’t be able to do IP spoofing, but only use valid IP aliases.

We tried this way :

val address1 = java.net.InetAddress.getByName("")
val address2 = java.net.InetAddress.getByName("")

def randomLocalAddress = if (ThreadLocalRandom.current.nextBoolean) address1 else address2

val localAddressFeeder = Iterator.continually(Map("localAddress" -> randomLocalAddress))

  val httpProtocol1 = http

Stephane, Pierre? Anyone?


The change to take an Expression there is in master, not in 2.1.