title: Typical UDP latency on iPhone over 3G - are my numbers right?
body: <p>In order to evaluate TCP versus UDP on the iPhone, I wrote a small echo server on my computer and used the AsyncUdpSocket library on the iPhone, but latencies are coming out surprisingly large and I wonder if there is something wrong with my implementation somehow.</p>
  
  <p>My setup has a wifi-router (Apple Airport) which has an external static IP. The port used by the echo server is forwarded to my development computer.</p>
  
  <p>I used two different setups:</p>
  
  <ol>
  <li>iPhone -> Wifi -> Wifi Router -> Wifi -> Computer</li>
  <li>iPhone -> 3G -> Wifi Router -> Wifi -> Computer</li>
  </ol>
  
  <p>Packet size was around 10 bytes.</p>
  
  <p>In the first case, roundtrip varied from 9 ms to 600 ms. Mostly I would see a median of around 300 ms, but some runs would have only 30 ms.</p>
  
  <p>Second case... Best case 2000 ms, moving up to 5000 ms.</p>
  
  <p>Implementation would send an UDP packet, wait until it gets back, then send the next.</p>
  
  <p>I initially believed something was wrong with the implementation, but running it from the simulator give a consistent latency of only 7 ms.</p>
  
  <p>Are my numbers right or is something weird going on?</p>