[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[ns] Two DSR patches for packet out-of-order problem



I am using DSR with my TCP simulation. I found in certain situations
DSR will send packets in exact reverse order of the original sequence that
they were sent by upper layer protocols such as TCP. 

If faithfully maintaining the original packet sending order at DSR level
to minimize the overall packet out-of-order problem is important to you,
then you might want to try the following two simple patches.

1. go to your ns-2 souce directory, say
   ~/ns/ns-allinone-2.1b7a/ns-2.1b7a/dsr and edit the file
   dsragent.cc
2. after line 1976, (before the line "for(r = head; r; r=nr){")
   add:

  /* XXXX patch to preserve the original order of the recycled
     packets. Here, we need to reverse the order of this linked
     list so that the recycled the packets are put into the send
     buffer in the original order -Zhenghua 2/27/2001 */
  
  Packet *ptr1, *ptr2;
  if(head)   {
      ptr1 = head->next_; head->next_ = 0;
      while(ptr1) {
           ptr2 = ptr1->next_;
           ptr1->next_ = head; 
           head = ptr1; 
           ptr1 = ptr2; 
      }
  }

3. after line 1447, delete line 1448 that look like 
    " delay += arp_timeout;" and substitute it with

    /* XXXX patch to preserve the original order of the recycled
       packets.  Here at most the first packet need to wait for the
       arp, the subsequent packets traversing the same path don't
       need to be delayed. -Zhenghua 2/27/2001*/

   if(delay == 0) delay += arp_timeout;

4. That's all. re-make the ns-2 and now the DSR will faithfully
   carrying out the packets in the order as they were sent.

The reason why DSR has this problem is because that when it receives
a mac-layer callback for a failed xmit, it will delete the next hop
route information from the route cache and delete all the packets in
the ifq that will be sent toward this broken hop.  If these killed 
packets happen to have been originated by this node, it will recyle them
and put them in a send buffer.  DSR will put these packet in the send
buffer in the EXACT reverse order that they were sent. The first patch
preserve the original order in the send buffer, the second patch makes 
these packets to be sent promptly once the source-route for them is
available.

Zhenghua