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

(-)i/src/internet/model/tcp-rx-buffer.cc (-1 / +1 lines)
 Lines 114-120   TcpRxBuffer::MaxRxSequence (void) const Link Here 
114
    { // No data allowed beyond FIN
114
    { // No data allowed beyond FIN
115
      return m_finSeq;
115
      return m_finSeq;
116
    }
116
    }
117
  else if (m_data.size ())
117
  else if (m_data.size () && m_nextRxSeq > m_data.begin ()->first)
118
    { // No data allowed beyond Rx window allowed
118
    { // No data allowed beyond Rx window allowed
119
      return m_data.begin ()->first + SequenceNumber32 (m_maxBuffer);
119
      return m_data.begin ()->first + SequenceNumber32 (m_maxBuffer);
120
    }
120
    }
(-)i/src/internet/model/tcp-socket-base.cc (-20 / +39 lines)
 Lines 159-164   TcpSocketBase::GetTypeId (void) Link Here 
159
                     "TCP Congestion machine state",
159
                     "TCP Congestion machine state",
160
                     MakeTraceSourceAccessor (&TcpSocketBase::m_congStateTrace),
160
                     MakeTraceSourceAccessor (&TcpSocketBase::m_congStateTrace),
161
                     "ns3::TcpSocketState::TcpCongStatesTracedValueCallback")
161
                     "ns3::TcpSocketState::TcpCongStatesTracedValueCallback")
162
    .AddTraceSource ("AdvWND",
163
                     "Advertised Window Size",
164
                     MakeTraceSourceAccessor (&TcpSocketBase::m_advWnd),
165
                     "ns3::TracedValueCallback::Uint32")
162
    .AddTraceSource ("RWND",
166
    .AddTraceSource ("RWND",
163
                     "Remote side's flow control window",
167
                     "Remote side's flow control window",
164
                     MakeTraceSourceAccessor (&TcpSocketBase::m_rWnd),
168
                     MakeTraceSourceAccessor (&TcpSocketBase::m_rWnd),
 Lines 2949-2956   uint16_t Link Here 
2949
TcpSocketBase::AdvertisedWindowSize (bool scale) const
2953
TcpSocketBase::AdvertisedWindowSize (bool scale) const
2950
{
2954
{
2951
  NS_LOG_FUNCTION (this << scale);
2955
  NS_LOG_FUNCTION (this << scale);
2952
  uint32_t w = m_rxBuffer->MaxBufferSize ();
2956
  uint32_t w = (m_rxBuffer->MaxRxSequence () > m_rxBuffer->NextRxSequence ()) ?
2957
    m_rxBuffer->MaxRxSequence () - m_rxBuffer->NextRxSequence () : 0;
2953
2958
2959
  // We don't want to advertise 0 after a FIN is received. So, we just use
2960
  // the previous value of the advWnd.
2961
  if (m_rxBuffer->Finished ())
2962
    {
2963
      w = m_advWnd;
2964
    }
2965
2966
  // Ugly, but we are not modifying the state, that variable
2967
  // is used only for tracing purpose.
2968
  if (w != m_advWnd)
2969
    {
2970
      const_cast<TcpSocketBase*> (this)->m_advWnd = w;
2971
    }
2954
  if (scale)
2972
  if (scale)
2955
    {
2973
    {
2956
      w >>= m_rcvWindShift;
2974
      w >>= m_rcvWindShift;
 Lines 2979-2984   TcpSocketBase::ReceivedData (Ptr<Packet> p, const TcpHeader& tcpHeader) Link Here 
2979
      SendEmptyPacket (TcpHeader::ACK);
2997
      SendEmptyPacket (TcpHeader::ACK);
2980
      return;
2998
      return;
2981
    }
2999
    }
3000
  // Notify app to receive if necessary
3001
  if (expectedSeq < m_rxBuffer->NextRxSequence ())
3002
    { // NextRxSeq advanced, we have something to send to the app
3003
      if (!m_shutdownRecv)
3004
        {
3005
          NotifyDataRecv ();
3006
        }
3007
      // Handle exceptions
3008
      if (m_closeNotified)
3009
        {
3010
          NS_LOG_WARN ("Why TCP " << this << " got data after close notification?");
3011
        }
3012
      // If we received FIN before and now completed all "holes" in rx buffer,
3013
      // invoke peer close procedure
3014
      if (m_rxBuffer->Finished () && (tcpHeader.GetFlags () & TcpHeader::FIN) == 0)
3015
        {
3016
          DoPeerClose ();
3017
          return;
3018
        }
3019
    }
2982
  // Now send a new ACK packet acknowledging all received and delivered data
3020
  // Now send a new ACK packet acknowledging all received and delivered data
2983
  if (m_rxBuffer->Size () > m_rxBuffer->Available () || m_rxBuffer->NextRxSequence () > expectedSeq + p->GetSize ())
3021
  if (m_rxBuffer->Size () > m_rxBuffer->Available () || m_rxBuffer->NextRxSequence () > expectedSeq + p->GetSize ())
2984
    { // A gap exists in the buffer, or we filled a gap: Always ACK
3022
    { // A gap exists in the buffer, or we filled a gap: Always ACK
 Lines 3000-3024   TcpSocketBase::ReceivedData (Ptr<Packet> p, const TcpHeader& tcpHeader) Link Here 
3000
                        (Simulator::Now () + Simulator::GetDelayLeft (m_delAckEvent)).GetSeconds ());
3038
                        (Simulator::Now () + Simulator::GetDelayLeft (m_delAckEvent)).GetSeconds ());
3001
        }
3039
        }
3002
    }
3040
    }
3003
  // Notify app to receive if necessary
3004
  if (expectedSeq < m_rxBuffer->NextRxSequence ())
3005
    { // NextRxSeq advanced, we have something to send to the app
3006
      if (!m_shutdownRecv)
3007
        {
3008
          NotifyDataRecv ();
3009
        }
3010
      // Handle exceptions
3011
      if (m_closeNotified)
3012
        {
3013
          NS_LOG_WARN ("Why TCP " << this << " got data after close notification?");
3014
        }
3015
      // If we received FIN before and now completed all "holes" in rx buffer,
3016
      // invoke peer close procedure
3017
      if (m_rxBuffer->Finished () && (tcpHeader.GetFlags () & TcpHeader::FIN) == 0)
3018
        {
3019
          DoPeerClose ();
3020
        }
3021
    }
3022
}
3041
}
3023
3042
3024
/**
3043
/**
(-)i/src/internet/model/tcp-socket-base.h (+1 lines)
 Lines 1114-1119   protected: Link Here 
1114
  // Window management
1114
  // Window management
1115
  uint16_t              m_maxWinSize;  //!< Maximum window size to advertise
1115
  uint16_t              m_maxWinSize;  //!< Maximum window size to advertise
1116
  TracedValue<uint32_t> m_rWnd;        //!< Receiver window (RCV.WND in RFC793)
1116
  TracedValue<uint32_t> m_rWnd;        //!< Receiver window (RCV.WND in RFC793)
1117
  TracedValue<uint32_t> m_advWnd;      //!< Advertised Window size
1117
  TracedValue<SequenceNumber32> m_highRxMark;     //!< Highest seqno received
1118
  TracedValue<SequenceNumber32> m_highRxMark;     //!< Highest seqno received
1118
  SequenceNumber32 m_highTxAck;                   //!< Highest ack sent
1119
  SequenceNumber32 m_highTxAck;                   //!< Highest ack sent
1119
  TracedValue<SequenceNumber32> m_highRxAckMark;  //!< Highest ack received
1120
  TracedValue<SequenceNumber32> m_highRxAckMark;  //!< Highest ack received
(-)i/src/internet/wscript (+1 lines)
 Lines 268-273   def build(bld): Link Here 
268
        'test/tcp-pkts-acked-test.cc',
268
        'test/tcp-pkts-acked-test.cc',
269
        'test/tcp-rtt-estimation.cc',
269
        'test/tcp-rtt-estimation.cc',
270
        'test/tcp-bytes-in-flight-test.cc',
270
        'test/tcp-bytes-in-flight-test.cc',
271
        'test/tcp-advertised-window-test.cc',
271
        'test/udp-test.cc',
272
        'test/udp-test.cc',
272
        'test/ipv6-address-generator-test-suite.cc',
273
        'test/ipv6-address-generator-test-suite.cc',
273
        'test/ipv6-dual-stack-test-suite.cc',
274
        'test/ipv6-dual-stack-test-suite.cc',

Return to bug 2559