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

(-)a/src/internet/model/rtt-estimator.cc (-15 / +19 lines)
 Lines 279-303    Link Here 
279
Time RttMeanDeviation::RetransmitTimeout ()
279
Time RttMeanDeviation::RetransmitTimeout ()
280
{
280
{
281
  NS_LOG_FUNCTION (this);
281
  NS_LOG_FUNCTION (this);
282
  // If not enough samples, just return 2 times estimate
282
283
  //if (nSamples < 2) return est * 2;
283
  // the default is 1 second, if there is not enough samples or the rtt is smaller than 1.
284
  Time retval (Seconds (0));
284
  Time retval = Time::FromInteger (1, Time::S);
285
  double var = m_variance.ToDouble (Time::S);
285
286
  NS_LOG_DEBUG ("RetransmitTimeout:  var " << var << " est " << m_currentEstimatedRtt.ToDouble (Time::S) << " multiplier " << m_multiplier);
286
  // if not enough samples returns 1, as especified at (2.1)  -> RFC 6298
287
  if (var < (m_currentEstimatedRtt.ToDouble (Time::S) / 4.0) )
287
  if (m_nSamples != 0)
288
    {
288
    {
289
      for (uint16_t i = 0; i < 2* m_multiplier; i++)
289
      if (m_nSamples == 1) // (2.2) -> RFC 6298
290
        {
290
        {
291
          retval += m_currentEstimatedRtt;
291
    	  m_srtt = m_currentEstimatedRtt.ToDouble (Time::S);
292
    	  m_rttVar = m_srtt/2;
293
    	  retval = (retval.ToDouble (Time::S) > 4*m_rttVar) ? retval : Time::FromDouble (4*m_rttVar,  Time::S);
294
    	  retval = Time::FromDouble (m_rttVar,  Time::S) + retval;
292
        }
295
        }
296
      else
297
        { // (2.3) -> RFC 6298
298
    	  m_rttVar = 0.75 * m_rttVar + 0.25 * abs(m_srtt - m_currentEstimatedRtt.ToDouble (Time::S));
299
    	  m_srtt = 0.875 * m_srtt + (0.125 * m_currentEstimatedRtt.ToDouble (Time::S));
300
       	  retval = (retval.ToDouble (Time::S) > 4*m_rttVar) ? retval : Time::FromDouble (4*m_rttVar,  Time::S);
301
       	  retval = Time::FromDouble (m_srtt,  Time::S) + retval;
302
         }
293
    }
303
    }
294
  else
304
  return (retval > m_minRto ? retval : m_minRto);  //  (2.4)  -> RFC 6298
295
    {
296
      int64_t temp = m_currentEstimatedRtt.ToInteger (Time::S) + 4 * m_variance.ToInteger (Time::S);
297
      retval = Time::FromInteger (temp, Time::S);
298
    }
299
  NS_LOG_DEBUG ("RetransmitTimeout:  return " << (retval > m_minRto ? retval.GetSeconds () : m_minRto.GetSeconds ()));
300
  return (retval > m_minRto ? retval : m_minRto);  // return maximum
301
}
305
}
302
306
303
Ptr<RttEstimator> RttMeanDeviation::Copy () const
307
Ptr<RttEstimator> RttMeanDeviation::Copy () const
(-)a/src/internet/model/rtt-estimator.h (+2 lines)
 Lines 145-150    Link Here 
145
protected:
145
protected:
146
  Time         m_currentEstimatedRtt;     // Current estimate
146
  Time         m_currentEstimatedRtt;     // Current estimate
147
  Time         m_minRto;                  // minimum value of the timeout
147
  Time         m_minRto;                  // minimum value of the timeout
148
  double       m_srtt;                    // smoothed round-trip time (RFC 6298)
149
  double       m_rttVar;				  // round-trip time variation (RFC 6298)
148
  uint32_t     m_nSamples;                // Number of samples
150
  uint32_t     m_nSamples;                // Number of samples
149
  uint16_t     m_multiplier;              // RTO Multiplier
151
  uint16_t     m_multiplier;              // RTO Multiplier
150
};
152
};
(-)a/src/internet/model/tcp-socket-base.cc (-3 / +26 lines)
 Lines 1759-1769    Link Here 
1759
  header.SetWindowSize (AdvertisedWindowSize ());
1759
  header.SetWindowSize (AdvertisedWindowSize ());
1760
  AddOptions (header);
1760
  AddOptions (header);
1761
  if (m_retxEvent.IsExpired () )
1761
  if (m_retxEvent.IsExpired () )
1762
    { // Schedule retransmit
1762
    {
1763
      m_rto = m_rtt->RetransmitTimeout ();
1763
	  // Schedules retransmit
1764
      if (m_cnCount == 0)
1765
        { // No more connection retries, give up
1766
          NS_LOG_LOGIC ("Transmission failed.");
1767
          CloseAndNotify ();
1768
          m_rtt->Reset (); //According to recommendation -> RFC 6298
1769
          return 0;
1770
        }
1771
      else
1772
        { // Exponential backoff of connection time out
1773
    	  int backoffCount = 0x1 << (m_cnRetries - m_cnCount);
1774
          m_rto = m_rto * backoffCount;
1775
          m_cnCount--;
1776
        }
1777
1778
      if (m_rto.Get ().GetSeconds () > 60)
1779
        { // (2.5)-> RFC 6298
1780
    	  m_rto = Time::FromDouble (60,  Time::S);
1781
        } else if (m_state == SYN_SENT && m_rto.Get ().GetSeconds () < 3)
1782
        	{ // (5.7)-> RFC 6298
1783
        		m_rto = Time::FromDouble (3,  Time::S);
1784
        	}
1785
1764
      NS_LOG_LOGIC (this << " SendDataPacket Schedule ReTxTimeout at time " <<
1786
      NS_LOG_LOGIC (this << " SendDataPacket Schedule ReTxTimeout at time " <<
1765
                    Simulator::Now ().GetSeconds () << " to expire at time " <<
1787
                    Simulator::Now ().GetSeconds () << " to expire at time " <<
1766
                    (Simulator::Now () + m_rto.Get ()).GetSeconds () );
1788
                    (Simulator::Now () + m_rto.Get ()).GetSeconds ());
1789
1767
      m_retxEvent = Simulator::Schedule (m_rto, &TcpSocketBase::ReTxTimeout, this);
1790
      m_retxEvent = Simulator::Schedule (m_rto, &TcpSocketBase::ReTxTimeout, this);
1768
    }
1791
    }
1769
  NS_LOG_LOGIC ("Send packet via TcpL4Protocol with flags 0x" << std::hex << static_cast<uint32_t> (flags) << std::dec);
1792
  NS_LOG_LOGIC ("Send packet via TcpL4Protocol with flags 0x" << std::hex << static_cast<uint32_t> (flags) << std::dec);

Return to bug 1405