Browse Source

congesion control during retransmission

pull/151/head
orignal 10 years ago
parent
commit
aae837f642
  1. 27
      Streaming.cpp

27
Streaming.cpp

@ -114,10 +114,8 @@ namespace stream
{ {
if (receivedSeqn <= m_LastReceivedSequenceNumber) if (receivedSeqn <= m_LastReceivedSequenceNumber)
{ {
// we have received duplicate. Most likely our outbound tunnel is dead // we have received duplicate
LogPrint (eLogWarning, "Duplicate message ", receivedSeqn, " received"); LogPrint (eLogWarning, "Duplicate message ", receivedSeqn, " received");
m_CurrentOutboundTunnel = nullptr; // pick another outbound tunnel
UpdateCurrentRemoteLease (); // pick another lease
SendQuickAck (); // resend ack for previous message again SendQuickAck (); // resend ack for previous message again
delete packet; // packet dropped delete packet; // packet dropped
} }
@ -258,12 +256,6 @@ namespace stream
else else
break; break;
} }
if (nackCount > 0)
{
// congesion avoidance
m_WindowSize -= nackCount;
if (m_WindowSize < MIN_WINDOW_SIZE) m_WindowSize = MIN_WINDOW_SIZE;
}
if (m_SentPackets.empty ()) if (m_SentPackets.empty ())
m_ResendTimer.cancel (); m_ResendTimer.cancel ();
if (acknowledged) if (acknowledged)
@ -568,10 +560,13 @@ namespace stream
{ {
if (ecode != boost::asio::error::operation_aborted) if (ecode != boost::asio::error::operation_aborted)
{ {
bool congesion = false;
std::vector<Packet *> packets; std::vector<Packet *> packets;
for (auto it : m_SentPackets) for (auto it : m_SentPackets)
{ {
it->numResendAttempts++; it->numResendAttempts++;
if (it->numResendAttempts == 1) // detect congesion at first attempt only
congesion = true;
if (it->numResendAttempts <= MAX_NUM_RESEND_ATTEMPTS) if (it->numResendAttempts <= MAX_NUM_RESEND_ATTEMPTS)
packets.push_back (it); packets.push_back (it);
else else
@ -585,8 +580,18 @@ namespace stream
} }
if (packets.size () > 0) if (packets.size () > 0)
{ {
m_CurrentOutboundTunnel = nullptr; // pick another outbound tunnel if (congesion)
UpdateCurrentRemoteLease (); // pick another lease {
// congesion avoidance
m_WindowSize /= 2;
if (m_WindowSize < MIN_WINDOW_SIZE) m_WindowSize = MIN_WINDOW_SIZE;
}
else
{
// congesion avoidance didn't help
m_CurrentOutboundTunnel = nullptr; // pick another outbound tunnel
UpdateCurrentRemoteLease (); // pick another lease
}
SendPackets (packets); SendPackets (packets);
} }
ScheduleResend (); ScheduleResend ();

Loading…
Cancel
Save