Simulating Latency

Hello,

We are looking to simulate latency on the network to test an application in a WAN environment.

Would it be plausible looking to iRules to investigate if this is possible?

Any pointers/tipes would be appreciated.

I was thinking for loops. I tested this in the lab, on my BigIP this equates to about 58 milliseconds of delay:

when CLIENT_ACCEPTED {
  set y1 [clock clicks -milliseconds]
  for { set x 0 } { $x < 100000 } { incr x } {do nothing}
  set y2 [clock clicks -milliseconds]
  set time1 [expr $y2 - $y1] 
  log "For loop time is $time1 milliseconds"
}

Note that, while this is possible via iRules, it is not recommended and is not the intended use of the language.

This kind of rule can, as you might imagine, introduce serious latency in connections to your BIG-IP, and should only be used in a testing environment.

-Colin

Yes, you could…but like I said, I don’t recommend putting it in place at all on a production system.

-Colin

You may wish to consider using DummyNet http://info.iet.unipi.it/~luigi/ip\_dummynet/ to simulate a WAN link outside of the BIG-IP.

forgive me if I am wrong, but triggering this on CLIENT_ACCEPTED just means that the initial connection is waylaid. latency is evident on every packet not just the 4th…

if you do it on HTTP protocol you may use the same code in when HTTP_REQUEST and/or HTTP_RESPONSE

This would simulate latency per session, not per packet, you’re correct.

Colin

According to this https://devcentral.f5.com/s/articles/irules-and-wait-states-after-makes-life-better you’d rather use this irule

when HTTP_REQUEST {
    after 50
}