IP spoofing using localAddress

1,213 views
Skip to first unread message

Chirag Kapadia

unread,
May 18, 2015, 1:47:14 PM5/18/15
to gat...@googlegroups.com
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
.baseURL("https://applicationurl.com")
// .inferHtmlResources(BlackList(""".*\.js""", """.*\.css""", """.*\.gif""", """.*\.jpeg""", """.*\.jpg""", """.*\.ico""", """.*\.woff""", """.*\.(t|o)tf""", """.*\.png"""), WhiteList())
.acceptHeader("*/*")
.acceptEncodingHeader("gzip, deflate")
.acceptLanguageHeader("en-US,en;q=0.8")
.connection("keep-alive")
.contentTypeHeader("application/x-www-form-urlencoded; charset=UTF-8")
.doNotTrackHeader("1")
.userAgentHeader("Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/42.0.2311.135 Safari/537.36")
.disableCaching
.localAddress(
????)


Thank you.

Stéphane LANDELLE

unread,
May 18, 2015, 2:22:42 PM5/18/15
to gat...@googlegroups.com
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...

setUp(scn.inject(...).protocols(http1),
          scn.inject(...).protocols(http2))


Stéphane Landelle
Lead developer


--
You received this message because you are subscribed to the Google Groups "Gatling User Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to gatling+u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Abhinav Gogna

unread,
May 18, 2015, 2:54:00 PM5/18/15
to gat...@googlegroups.com
This is a must needed feature. So far, I have been "Scaling out" to simulate multiple IPs.

Abhinav Gogna

unread,
Jun 19, 2015, 3:54:12 AM6/19/15
to gat...@googlegroups.com
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 = "192.3.4.5"
val address2 = "192.3.4.9"

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

Thanks,
Abhinav

Stéphane LANDELLE

unread,
Jun 23, 2015, 7:26:08 AM6/23/15
to gat...@googlegroups.com
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("192.3.4.5")
val address2 = java.net.InetAddress.getByName("192.3.4.9")
httpProtocol.localAddress("${localAddress}")

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

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

feed(localAddressFeeder)

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



Stéphane Landelle
Lead developer


Chirag Kapadia

unread,
Aug 27, 2015, 5:09:20 PM8/27/15
to Gatling User Group
We tried this way :



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


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

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


  val httpProtocol1 = http
.baseURL("https://abc.com")
 .localAddress("${localAddress}")

we are getting this error message 


Error:(81, 30) type mismatch;
 found   : String("${localAddress}")
 required: java.net.InetAddress
  httpProtocol1.localAddress("${localAddress}")

Any suggession ?

How do we feed localAddressFeeder

                             

Abhinav Gogna

unread,
Sep 1, 2015, 3:09:31 PM9/1/15
to Gatling User Group
Stephane, Pierre? Anyone?

Abhinav Gogna

unread,
Sep 24, 2015, 9:45:34 AM9/24/15
to Gatling User Group
Bump.

Stéphane LANDELLE

unread,
Sep 29, 2015, 2:32:31 AM9/29/15
to gat...@googlegroups.com
The change to take an Expression there is in master, not in 2.1.

Stéphane Landelle
Lead developer


Reply all
Reply to author
Forward
0 new messages