title: How to simulate bandwidth and delay in localhost with dummynet (ipfw)
body: <p>I am using a web server in <code>localhost:8080</code> and I'm trying to use dummynet (ipfw) to simulate latency and low bandwidth to that server but somehow I cannot get it to work.</p>
  
  <p>When I use the command</p>
  
  <pre><code>sudo ipfw add pipe 1 all from any to any
  sudo ipfw pipe 1 config bw 400Kbit/s delay 100ms
  </code></pre>
  
  <p>and then ping the localhost</p>
  
  <pre><code>ping localhost
  </code></pre>
  
  <p>I get these results:</p>
  
  <pre><code>PING localhost (127.0.0.1): 56 data bytes
  64 bytes from 127.0.0.1: icmp_seq=0 ttl=64 time=686.512 ms
  64 bytes from 127.0.0.1: icmp_seq=1 ttl=64 time=848.309 ms
  64 bytes from 127.0.0.1: icmp_seq=2 ttl=64 time=409.890 ms
  64 bytes from 127.0.0.1: icmp_seq=3 ttl=64 time=410.988 ms
  64 bytes from 127.0.0.1: icmp_seq=4 ttl=64 time=424.014 ms
  64 bytes from 127.0.0.1: icmp_seq=5 ttl=64 time=411.002 ms
  64 bytes from 127.0.0.1: icmp_seq=6 ttl=64 time=409.175 ms
  64 bytes from 127.0.0.1: icmp_seq=7 ttl=64 time=417.517 ms
  </code></pre>
  
  <p>My problems are:</p>
  
  <ol>
  <li><p>Why is the ping round trip time (~400ms) is about 4 times larger than my specified delay (100ms) </p></li>
  <li><p>The bandwidth limiting does not seem to work also. When I try to download a 6Mb test file from the address <code>http://localhost:8080/Testfile</code> in Chrome, I get the file instantly, not in my desired rate</p></li>
  </ol>