title: UDP Packet reordering
body: <p>I am making  VOIP  calling  Android app . where I have partially completed it using simple UDP without using SIP , RTP etc... 
  When I am trying it in my Home LAN , quality is very good.
  But when  I am using it over internet , sound quality is very poor for jitter .</p>
  
  <p>Now the thing is in receiver side  I need to  RE-ORDER  received packet. I don’t want to use RTP  as it involved extra coding at this moment.</p>
  
  <p>In receive loop I am receiving UDP  packet constantly and sending it to speaker.
  I need to buffer those received packet and send it in order to speaker.</p>
  
  <pre><code>    While(true){
      byte[] data = new byte[..];
      Udpsocket.receive(data);
      // Store data in a big buffer. after receiving enough packets say 500 packets 
      // properly send to Speaker in proper order
      }
  </code></pre>
  
  <p>I was looking  Linux TCP code for packet reordering but it is very complex for me.</p>
  
  <p>Can you please tell me how to reorder efficiently? I mean how much data I need to buffer etc. etc. how long I need to wait for data ..
  any suggestion ,  sample code  or simple algorithm  for reordering UDP packet  will be appreciated .</p>
  
  <p>Thanks</p>