|
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), |
|
|
| 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 |
/** |