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

(-)a/src/internet/model/tcp-socket-base.cc (-7 / +13 lines)
 Lines 2204-2214    Link Here 
2204
      header.SetDestinationPort (m_endPoint6->GetPeerPort ());
2204
      header.SetDestinationPort (m_endPoint6->GetPeerPort ());
2205
    }
2205
    }
2206
  AddOptions (header);
2206
  AddOptions (header);
2207
  header.SetWindowSize (AdvertisedWindowSize ());
2208
2207
2209
  // RFC 6298, clause 2.4
2208
  // RFC 6298, clause 2.4
2210
  m_rto = Max (m_rtt->GetEstimate () + Max (m_clockGranularity, m_rtt->GetVariation () * 4), m_minRto);
2209
  m_rto = Max (m_rtt->GetEstimate () + Max (m_clockGranularity, m_rtt->GetVariation () * 4), m_minRto);
2211
2210
2211
  uint16_t windowSize = AdvertisedWindowSize ();
2212
  bool hasSyn = flags & TcpHeader::SYN;
2212
  bool hasSyn = flags & TcpHeader::SYN;
2213
  bool hasFin = flags & TcpHeader::FIN;
2213
  bool hasFin = flags & TcpHeader::FIN;
2214
  bool isAck = flags == TcpHeader::ACK;
2214
  bool isAck = flags == TcpHeader::ACK;
 Lines 2241-2247    Link Here 
2241
        { // This is SYN retransmission
2241
        { // This is SYN retransmission
2242
          UpdateRttHistory (s, 0, true);
2242
          UpdateRttHistory (s, 0, true);
2243
        }
2243
        }
2244
2245
      windowSize = AdvertisedWindowSize (false);
2244
    }
2246
    }
2247
  header.SetWindowSize (windowSize);
2245
2248
2246
  m_txTrace (p, header, this);
2249
  m_txTrace (p, header, this);
2247
2250
 Lines 2702-2720    Link Here 
2702
}
2705
}
2703
2706
2704
uint16_t
2707
uint16_t
2705
TcpSocketBase::AdvertisedWindowSize () const
2708
TcpSocketBase::AdvertisedWindowSize (bool scale) const
2706
{
2709
{
2710
  NS_LOG_FUNCTION (this << scale);
2707
  uint32_t w = m_rxBuffer->MaxBufferSize ();
2711
  uint32_t w = m_rxBuffer->MaxBufferSize ();
2708
2712
2709
  w >>= m_rcvWindShift;
2713
  if (scale)
2710
2714
    {
2715
      w >>= m_rcvWindShift;
2716
    }
2711
  if (w > m_maxWinSize)
2717
  if (w > m_maxWinSize)
2712
    {
2718
    {
2713
      NS_LOG_WARN ("There is a loss in the adv win size, wrt buffer size");
2714
      w = m_maxWinSize;
2719
      w = m_maxWinSize;
2720
      NS_LOG_WARN ("Adv window size truncated to " << m_maxWinSize << "; possibly to avoid overflow of the 16-bit integer");
2715
    }
2721
    }
2716
2722
  NS_LOG_DEBUG ("Returning AdvertisedWindowSize of " << static_cast<uint16_t> (w));
2717
  return (uint16_t) w;
2723
  return static_cast<uint16_t> (w);
2718
}
2724
}
2719
2725
2720
// Receipt of new packet, put into Rx buffer
2726
// Receipt of new packet, put into Rx buffer
(-)a/src/internet/model/tcp-socket-base.h (-1 / +3 lines)
 Lines 783-791    Link Here 
783
783
784
  /**
784
  /**
785
   * \brief The amount of Rx window announced to the peer
785
   * \brief The amount of Rx window announced to the peer
786
   * \param scale indicate if the window should be scaled. True for
787
   * almost all cases, except when we are sending a SYN
786
   * \returns size of Rx window announced to the peer
788
   * \returns size of Rx window announced to the peer
787
   */
789
   */
788
  virtual uint16_t AdvertisedWindowSize (void) const;
790
  virtual uint16_t AdvertisedWindowSize (bool scale = true) const;
789
791
790
  /**
792
  /**
791
   * \brief Update the receiver window (RWND) based on the value of the
793
   * \brief Update the receiver window (RWND) based on the value of the

Return to bug 2392