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

(-)a/src/internet/model/tcp-socket-base.cc (-29 / +10 lines)
 Lines 582-594   TcpSocketBase::Bind (const Address &address) Link Here 
582
}
582
}
583
583
584
void
584
void
585
TcpSocketBase::InitializeCwnd (void)
586
{
587
  m_tcb->m_cWnd = GetInitialCwnd () * GetSegSize ();
588
  m_tcb->m_ssThresh = GetInitialSSThresh ();
589
}
590
591
void
592
TcpSocketBase::SetInitialSSThresh (uint32_t threshold)
585
TcpSocketBase::SetInitialSSThresh (uint32_t threshold)
593
{
586
{
594
  NS_ABORT_MSG_UNLESS ( (m_state == CLOSED) || threshold == m_tcb->m_initialSsThresh,
587
  NS_ABORT_MSG_UNLESS ( (m_state == CLOSED) || threshold == m_tcb->m_initialSsThresh,
 Lines 618-637   TcpSocketBase::GetInitialCwnd (void) const Link Here 
618
  return m_tcb->m_initialCWnd;
611
  return m_tcb->m_initialCWnd;
619
}
612
}
620
613
621
void
622
TcpSocketBase::ScaleSsThresh (uint8_t scaleFactor)
623
{
624
  m_tcb->m_ssThresh <<= scaleFactor;
625
}
626
627
/* Inherit from Socket class: Initiate connection to a remote address:port */
614
/* Inherit from Socket class: Initiate connection to a remote address:port */
628
int
615
int
629
TcpSocketBase::Connect (const Address & address)
616
TcpSocketBase::Connect (const Address & address)
630
{
617
{
631
  NS_LOG_FUNCTION (this << address);
618
  NS_LOG_FUNCTION (this << address);
632
619
633
  InitializeCwnd ();
634
635
  // If haven't do so, Bind() this socket first
620
  // If haven't do so, Bind() this socket first
636
  if (InetSocketAddress::IsMatchingType (address) && m_endPoint6 == 0)
621
  if (InetSocketAddress::IsMatchingType (address) && m_endPoint6 == 0)
637
    {
622
    {
 Lines 706-713   TcpSocketBase::Listen (void) Link Here 
706
{
691
{
707
  NS_LOG_FUNCTION (this);
692
  NS_LOG_FUNCTION (this);
708
693
709
  InitializeCwnd ();
710
711
  // Linux quits EINVAL if we're not in CLOSED state, so match what they do
694
  // Linux quits EINVAL if we're not in CLOSED state, so match what they do
712
  if (m_state != CLOSED)
695
  if (m_state != CLOSED)
713
    {
696
    {
 Lines 1184-1207   TcpSocketBase::DoForwardUp (Ptr<Packet> packet, const Address &fromAddress, Link Here 
1184
1167
1185
  ReadOptions (tcpHeader);
1168
  ReadOptions (tcpHeader);
1186
1169
1187
  if (tcpHeader.GetFlags () & TcpHeader::ACK)
1170
  if (tcpHeader.GetFlags () & TcpHeader::SYN)
1188
    {
1189
      EstimateRtt (tcpHeader);
1190
    }
1191
1192
  // Update Rx window size, i.e. the flow control window
1193
  if (tcpHeader.GetFlags () & TcpHeader::ACK)
1194
    {
1195
      UpdateWindowSize (tcpHeader);
1196
    }
1197
  else if (tcpHeader.GetFlags () & TcpHeader::SYN)
1198
    {
1171
    {
1199
      /* The window field in a segment where the SYN bit is set (i.e., a <SYN>
1172
      /* The window field in a segment where the SYN bit is set (i.e., a <SYN>
1200
       * or <SYN,ACK>) MUST NOT be scaled (from RFC 7323 page 9). But should be
1173
       * or <SYN,ACK>) MUST NOT be scaled (from RFC 7323 page 9). But should be
1201
       * saved anyway..
1174
       * saved anyway..
1202
       */
1175
       */
1203
      m_rWnd = tcpHeader.GetWindowSize ();
1176
      m_rWnd = tcpHeader.GetWindowSize ();
1177
1178
      m_tcb->m_cWnd = GetInitialCwnd () * GetSegSize ();
1179
      m_tcb->m_ssThresh = GetInitialSSThresh ();
1204
    }
1180
    }
1181
  else if (tcpHeader.GetFlags () & TcpHeader::ACK)
1182
    {
1183
      EstimateRtt (tcpHeader);
1184
      UpdateWindowSize (tcpHeader);
1185
    }
1186
1205
1187
1206
  if (m_rWnd.Get () == 0 && m_persistEvent.IsExpired ())
1188
  if (m_rWnd.Get () == 0 && m_persistEvent.IsExpired ())
1207
    { // Zero window: Enter persist state to send 1 byte to probe
1189
    { // Zero window: Enter persist state to send 1 byte to probe
 Lines 3101-3107   TcpSocketBase::ReadOptions (const TcpHeader& header) Link Here 
3101
            {
3083
            {
3102
              m_winScalingEnabled = true;
3084
              m_winScalingEnabled = true;
3103
              ProcessOptionWScale (header.GetOption (TcpOption::WINSCALE));
3085
              ProcessOptionWScale (header.GetOption (TcpOption::WINSCALE));
3104
              ScaleSsThresh (m_rcvWindShift);
3105
            }
3086
            }
3106
        }
3087
        }
3107
    }
3088
    }
(-)a/src/internet/model/tcp-socket-base.h (-19 lines)
 Lines 895-919   protected: Link Here 
895
   */
895
   */
896
  void AddOptionTimestamp (TcpHeader& header);
896
  void AddOptionTimestamp (TcpHeader& header);
897
897
898
  /**
899
   * \brief Scale the initial SsThresh value to the correct one
900
   *
901
   * Set the initial SsThresh to the largest possible advertised window
902
   * according to the sender scale factor.
903
   *
904
   * \param scaleFactor the sender scale factor
905
   */
906
  virtual void ScaleSsThresh (uint8_t scaleFactor);
907
908
  /**
909
   * \brief Initialize congestion window
910
   *
911
   * Default cWnd to 1 MSS (RFC2001, sec.1) and must
912
   * not be larger than 2 MSS (RFC2581, sec.3.1). Both m_initiaCWnd and
913
   * m_segmentSize are set by the attribute system in ns3::TcpSocket.
914
   */
915
  virtual void InitializeCwnd ();
916
917
protected:
898
protected:
918
  // Counters and events
899
  // Counters and events
919
  EventId           m_retxEvent;       //!< Retransmission event
900
  EventId           m_retxEvent;       //!< Retransmission event
(-)a/src/internet/model/tcp-socket.cc (-1 / +1 lines)
 Lines 65-71   TcpSocket::GetTypeId (void) Link Here 
65
                   MakeUintegerChecker<uint32_t> ())
65
                   MakeUintegerChecker<uint32_t> ())
66
    .AddAttribute ("InitialSlowStartThreshold",
66
    .AddAttribute ("InitialSlowStartThreshold",
67
                   "TCP initial slow start threshold (bytes)",
67
                   "TCP initial slow start threshold (bytes)",
68
                   UintegerValue (0xffff),
68
                   UintegerValue (UINT32_MAX),
69
                   MakeUintegerAccessor (&TcpSocket::GetInitialSSThresh,
69
                   MakeUintegerAccessor (&TcpSocket::GetInitialSSThresh,
70
                                         &TcpSocket::SetInitialSSThresh),
70
                                         &TcpSocket::SetInitialSSThresh),
71
                   MakeUintegerChecker<uint32_t> ())
71
                   MakeUintegerChecker<uint32_t> ())

Return to bug 2262