View | Details | Raw Unified | Return to bug 829
Collapse All | Expand All

(-)a/src/internet-stack/pending-data.cc (+32 lines)
 Lines 220-223    Link Here 
220
  NS_LOG_FUNCTION (this << s << f << o);
220
  NS_LOG_FUNCTION (this << s << f << o);
221
  return CopyFromOffset (s, OffsetFromSeq(f,o));
221
  return CopyFromOffset (s, OffsetFromSeq(f,o));
222
}
222
}
223
224
uint32_t
225
PendingData::RemoveToSeq (const SequenceNumber& seqFront, const SequenceNumber& seqOffset)
226
{
227
  NS_LOG_FUNCTION (this << seqFront << seqOffset);
228
  uint32_t count = OffsetFromSeq (seqFront, seqOffset);
229
  NS_ASSERT_MSG (count <= size, "Trying to remove more data than in the buffer"); 
230
  if (count == size)
231
    {
232
      Clear ();
233
      return size;
234
    }
235
  // Remove whole packets, if possible, from the front of the data
236
  // Do not perform buffer manipulations within packet; if a whole packet
237
  // cannot be removed, leave it alone
238
  std::vector<Ptr<Packet> >::iterator endI = data.begin ();
239
  uint32_t current = 0;
240
  // Any packet whose data has been completely acked can be removed
241
  for (std::vector<Ptr<Packet> >::iterator dataI = data.begin (); dataI < data.end (); dataI++)
242
    {
243
      if (current + (*dataI)->GetSize () > count)
244
        {
245
          break;
246
        }
247
      current += (*dataI)->GetSize ();
248
      ++endI;
249
    }
250
  data.erase (data.begin (), endI);
251
  size -= current;
252
  return current;
253
}
254
223
}//namepsace ns3
255
}//namepsace ns3
(-)a/src/internet-stack/pending-data.h (+10 lines)
 Lines 92-97    Link Here 
92
  virtual Ptr<Packet> CopyFromOffset (uint32_t, uint32_t);  // Size, offset, ret packet
92
  virtual Ptr<Packet> CopyFromOffset (uint32_t, uint32_t);  // Size, offset, ret packet
93
  // Copy data, size, offset specified by sequence difference
93
  // Copy data, size, offset specified by sequence difference
94
  virtual Ptr<Packet> CopyFromSeq (uint32_t, const SequenceNumber&, const SequenceNumber&);
94
  virtual Ptr<Packet> CopyFromSeq (uint32_t, const SequenceNumber&, const SequenceNumber&);
95
  /**
96
   * Permits object to clear any pending data between seqFront and 
97
   * seqOffset - 1).  Callers should check the return value to determine
98
   * whether any data was removed from the front.
99
   *
100
   * \param seqFront sequence number to start to try to remove from 
101
   * \param seqOffset first sequence number in buffer that should be retained
102
   * \return number of bytes from the front that were removed from the buffer
103
   */
104
  virtual uint32_t RemoveToSeq (const SequenceNumber& seqFront, const SequenceNumber& seqOffset);
95
  PendingData*   Copy () const;          // Create a copy of this header
105
  PendingData*   Copy () const;          // Create a copy of this header
96
  PendingData*   CopyS (uint32_t);         // Copy with new size
106
  PendingData*   CopyS (uint32_t);         // Copy with new size
97
  PendingData*   CopySD (uint32_t, uint8_t*); // Copy with new size, new data
107
  PendingData*   CopySD (uint32_t, uint8_t*); // Copy with new size, new data
(-)a/src/internet-stack/tcp-socket-impl.cc (+5 lines)
 Lines 1511-1516    Link Here 
1511
                        Simulator::GetDelayLeft (m_retxEvent)).GetSeconds());
1511
                        Simulator::GetDelayLeft (m_retxEvent)).GetSeconds());
1512
          m_retxEvent.Cancel ();
1512
          m_retxEvent.Cancel ();
1513
        }
1513
        }
1514
      else if (m_pendingData->SizeFromSeq (m_firstPendingSequence, m_highestRxAck) > 0)
1515
        {
1516
          // Remove from front, if possible
1517
          m_firstPendingSequence += m_pendingData->RemoveToSeq (m_firstPendingSequence, m_highestRxAck);
1518
        }
1514
    }
1519
    }
1515
  // Try to send more data
1520
  // Try to send more data
1516
  SendPendingData (m_connected);
1521
  SendPendingData (m_connected);

Return to bug 829