network-programmingwindows-7fiddler

Fiddler: Where to add IF statement for m_SimulateModem?


I want to add the following code to fiddler:

if (m_SimulateModem) {
    // Delay sends by 300ms per KB uploaded.
    oSession["request-trickle-delay"] = "300"; 
    // Delay receives by 150ms per KB downloaded.
    oSession["response-trickle-delay"] = "150"; 
}

I've already set m_simulatemodem to true (var m_SimulateModem: boolean = true;), but I don't know which event I should add the snippet above.

I tried adding it inside static function OnBeforeRequest(oSession: Session) but it doesn't seem to do anything.

Basically, I want to simulate a very low speed so that any browser being used returns The connection has timed out or ERR_CONNECTION_TIMED_OUT.


Solution

  • The Fiddler Performance Testing guide clearly states that the request-trickle-delay have to be used in OnBeforerequest:

    Simulate modem uploads (add to OnBeforeRequest function)

    oSession["request-trickle-delay"] = "300";

    And the response-trickle-delay have to be used in OnBeforeResponse:

    To test application performance, add rules using FiddlerScript to the OnBeforeResponse function (except where noted). For example:

    oSession["response-trickle-delay"] = "150";

    However I assume that with both settings you won't force your browser to run into a ERR_CONNECTION_TIMED_OUT.

    A setting of 300 means one KB per 300ms so we end up in about 3KB per second or ~2400 KBit. That is the connections speed of a good old modem from the last decade of the 20th century. It may take some time but as long as the data flow is continuously delivered all requests will work.

    A connection time out occurs when the client tries to contact the server but the server does not answer on the TCP request (e.g. because the port is not listening or the server is blocked by too much traffic).

    The easiest way to simulate that would to use an existing server and rewrite the server port so that the request will time-out because there is no server listening on the specified port:

    // make requests to www.example.org end up in a connection time-out
    if (oSession.HostnameIs("www.example.org")) {
      oSession.hostname="www.example.org:12345";
    }