|
|
@ -68,11 +68,12 @@ namespace stream |
|
|
|
|
|
|
|
|
|
|
|
Stream::Stream (boost::asio::io_service& service, StreamingDestination& local, |
|
|
|
Stream::Stream (boost::asio::io_service& service, StreamingDestination& local, |
|
|
|
std::shared_ptr<const i2p::data::LeaseSet> remote, int port): m_Service (service), |
|
|
|
std::shared_ptr<const i2p::data::LeaseSet> remote, int port): m_Service (service), |
|
|
|
m_SendStreamID (0), m_SequenceNumber (0), m_LastReceivedSequenceNumber (-1), |
|
|
|
m_SendStreamID (0), m_SequenceNumber (0), |
|
|
|
|
|
|
|
m_TunnelsChangeSequenceNumber (0), m_LastReceivedSequenceNumber (-1), |
|
|
|
m_Status (eStreamStatusNew), m_IsAckSendScheduled (false), m_LocalDestination (local), |
|
|
|
m_Status (eStreamStatusNew), m_IsAckSendScheduled (false), m_LocalDestination (local), |
|
|
|
m_RemoteLeaseSet (remote), m_ReceiveTimer (m_Service), m_ResendTimer (m_Service), |
|
|
|
m_RemoteLeaseSet (remote), m_ReceiveTimer (m_Service), m_ResendTimer (m_Service), |
|
|
|
m_AckSendTimer (m_Service), m_NumSentBytes (0), m_NumReceivedBytes (0), m_Port (port), |
|
|
|
m_AckSendTimer (m_Service), m_NumSentBytes (0), m_NumReceivedBytes (0), m_Port (port), |
|
|
|
m_WindowSize (MIN_WINDOW_SIZE), m_RTT (INITIAL_RTT), m_RTO (INITIAL_RTO), |
|
|
|
m_RTT (INITIAL_RTT), m_WindowSize (MIN_WINDOW_SIZE), m_RTO (INITIAL_RTO), |
|
|
|
m_AckDelay (local.GetOwner ()->GetStreamingAckDelay ()), |
|
|
|
m_AckDelay (local.GetOwner ()->GetStreamingAckDelay ()), |
|
|
|
m_LastWindowSizeIncreaseTime (0), m_NumResendAttempts (0), m_MTU (STREAMING_MTU) |
|
|
|
m_LastWindowSizeIncreaseTime (0), m_NumResendAttempts (0), m_MTU (STREAMING_MTU) |
|
|
|
{ |
|
|
|
{ |
|
|
@ -81,11 +82,12 @@ namespace stream |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
Stream::Stream (boost::asio::io_service& service, StreamingDestination& local): |
|
|
|
Stream::Stream (boost::asio::io_service& service, StreamingDestination& local): |
|
|
|
m_Service (service), m_SendStreamID (0), m_SequenceNumber (0), m_LastReceivedSequenceNumber (-1), |
|
|
|
m_Service (service), m_SendStreamID (0), m_SequenceNumber (0), |
|
|
|
|
|
|
|
m_TunnelsChangeSequenceNumber (0), m_LastReceivedSequenceNumber (-1), |
|
|
|
m_Status (eStreamStatusNew), m_IsAckSendScheduled (false), m_LocalDestination (local), |
|
|
|
m_Status (eStreamStatusNew), m_IsAckSendScheduled (false), m_LocalDestination (local), |
|
|
|
m_ReceiveTimer (m_Service), m_ResendTimer (m_Service), m_AckSendTimer (m_Service), |
|
|
|
m_ReceiveTimer (m_Service), m_ResendTimer (m_Service), m_AckSendTimer (m_Service), |
|
|
|
m_NumSentBytes (0), m_NumReceivedBytes (0), m_Port (0), m_WindowSize (MIN_WINDOW_SIZE), |
|
|
|
m_NumSentBytes (0), m_NumReceivedBytes (0), m_Port (0), m_RTT (INITIAL_RTT), |
|
|
|
m_RTT (INITIAL_RTT), m_RTO (INITIAL_RTO), m_AckDelay (local.GetOwner ()->GetStreamingAckDelay ()), |
|
|
|
m_WindowSize (MIN_WINDOW_SIZE), m_RTO (INITIAL_RTO), m_AckDelay (local.GetOwner ()->GetStreamingAckDelay ()), |
|
|
|
m_LastWindowSizeIncreaseTime (0), m_NumResendAttempts (0), m_MTU (STREAMING_MTU) |
|
|
|
m_LastWindowSizeIncreaseTime (0), m_NumResendAttempts (0), m_MTU (STREAMING_MTU) |
|
|
|
{ |
|
|
|
{ |
|
|
|
RAND_bytes ((uint8_t *)&m_RecvStreamID, 4); |
|
|
|
RAND_bytes ((uint8_t *)&m_RecvStreamID, 4); |
|
|
@ -287,6 +289,8 @@ namespace stream |
|
|
|
m_AckSendTimer.async_wait (std::bind (&Stream::HandleAckSendTimer, |
|
|
|
m_AckSendTimer.async_wait (std::bind (&Stream::HandleAckSendTimer, |
|
|
|
shared_from_this (), std::placeholders::_1)); |
|
|
|
shared_from_this (), std::placeholders::_1)); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
if (delayRequested >= DELAY_CHOKING) |
|
|
|
|
|
|
|
m_WindowSize = 1; |
|
|
|
} |
|
|
|
} |
|
|
|
optionData += 2; |
|
|
|
optionData += 2; |
|
|
|
} |
|
|
|
} |
|
|
@ -404,6 +408,8 @@ namespace stream |
|
|
|
LogPrint (eLogError, "Streaming: Unexpected ackThrough=", ackThrough, " > seqn=", m_SequenceNumber); |
|
|
|
LogPrint (eLogError, "Streaming: Unexpected ackThrough=", ackThrough, " > seqn=", m_SequenceNumber); |
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
int rttSample = INT_MAX; |
|
|
|
|
|
|
|
bool firstRttSample = false; |
|
|
|
int nackCount = packet->GetNACKCount (); |
|
|
|
int nackCount = packet->GetNACKCount (); |
|
|
|
for (auto it = m_SentPackets.begin (); it != m_SentPackets.end ();) |
|
|
|
for (auto it = m_SentPackets.begin (); it != m_SentPackets.end ();) |
|
|
|
{ |
|
|
|
{ |
|
|
@ -427,24 +433,38 @@ namespace stream |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
auto sentPacket = *it; |
|
|
|
auto sentPacket = *it; |
|
|
|
uint64_t rtt = ts - sentPacket->sendTime; |
|
|
|
int64_t rtt = (int64_t)ts - (int64_t)sentPacket->sendTime; |
|
|
|
if(ts < sentPacket->sendTime) |
|
|
|
if (rtt < 0) |
|
|
|
{ |
|
|
|
|
|
|
|
LogPrint (eLogError, "Streaming: Packet ", seqn, "sent from the future, sendTime=", sentPacket->sendTime); |
|
|
|
LogPrint (eLogError, "Streaming: Packet ", seqn, "sent from the future, sendTime=", sentPacket->sendTime); |
|
|
|
rtt = 1; |
|
|
|
if (!seqn) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
firstRttSample = true; |
|
|
|
|
|
|
|
rttSample = rtt < 0 ? 1 : rtt; |
|
|
|
} |
|
|
|
} |
|
|
|
if (seqn) |
|
|
|
else if (!sentPacket->resent && seqn > m_TunnelsChangeSequenceNumber && rtt >= 0) |
|
|
|
m_RTT = std::round (RTT_EWMA_ALPHA * m_RTT + (1.0 - RTT_EWMA_ALPHA) * rtt); |
|
|
|
rttSample = std::min (rttSample, (int)rtt); |
|
|
|
else |
|
|
|
|
|
|
|
m_RTT = rtt; |
|
|
|
|
|
|
|
m_RTO = m_RTT*1.5; // TODO: implement it better
|
|
|
|
|
|
|
|
LogPrint (eLogDebug, "Streaming: Packet ", seqn, " acknowledged rtt=", rtt, " sentTime=", sentPacket->sendTime); |
|
|
|
LogPrint (eLogDebug, "Streaming: Packet ", seqn, " acknowledged rtt=", rtt, " sentTime=", sentPacket->sendTime); |
|
|
|
m_SentPackets.erase (it++); |
|
|
|
m_SentPackets.erase (it++); |
|
|
|
m_LocalDestination.DeletePacket (sentPacket); |
|
|
|
m_LocalDestination.DeletePacket (sentPacket); |
|
|
|
acknowledged = true; |
|
|
|
acknowledged = true; |
|
|
|
if (m_WindowSize < WINDOW_SIZE) |
|
|
|
if (m_WindowSize < WINDOW_SIZE) |
|
|
|
m_WindowSize++; // slow start
|
|
|
|
m_WindowSize++; // slow start
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
else |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if (rttSample != INT_MAX) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
if (firstRttSample) |
|
|
|
|
|
|
|
m_RTT = rttSample; |
|
|
|
else |
|
|
|
else |
|
|
|
|
|
|
|
m_RTT = RTT_EWMA_ALPHA * rttSample + (1.0 - RTT_EWMA_ALPHA) * m_RTT; |
|
|
|
|
|
|
|
bool wasInitial = m_RTO == INITIAL_RTO; |
|
|
|
|
|
|
|
m_RTO = std::max (MIN_RTO, (int)(m_RTT * 1.5)); // TODO: implement it better
|
|
|
|
|
|
|
|
if (wasInitial) |
|
|
|
|
|
|
|
ScheduleResend (); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if (acknowledged && m_WindowSize >= WINDOW_SIZE) |
|
|
|
{ |
|
|
|
{ |
|
|
|
// linear growth
|
|
|
|
// linear growth
|
|
|
|
if (ts > m_LastWindowSizeIncreaseTime + m_RTT) |
|
|
|
if (ts > m_LastWindowSizeIncreaseTime + m_RTT) |
|
|
@ -454,14 +474,10 @@ namespace stream |
|
|
|
m_LastWindowSizeIncreaseTime = ts; |
|
|
|
m_LastWindowSizeIncreaseTime = ts; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
if (!seqn && m_RoutingSession) // first message confirmed
|
|
|
|
if (firstRttSample && m_RoutingSession) |
|
|
|
m_RoutingSession->SetSharedRoutingPath ( |
|
|
|
m_RoutingSession->SetSharedRoutingPath ( |
|
|
|
std::make_shared<i2p::garlic::GarlicRoutingPath> ( |
|
|
|
std::make_shared<i2p::garlic::GarlicRoutingPath> ( |
|
|
|
i2p::garlic::GarlicRoutingPath{m_CurrentOutboundTunnel, m_CurrentRemoteLease, m_RTT, 0, 0})); |
|
|
|
i2p::garlic::GarlicRoutingPath{m_CurrentOutboundTunnel, m_CurrentRemoteLease, (int)m_RTT, 0, 0})); |
|
|
|
} |
|
|
|
|
|
|
|
else |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if (m_SentPackets.empty ()) |
|
|
|
if (m_SentPackets.empty ()) |
|
|
|
m_ResendTimer.cancel (); |
|
|
|
m_ResendTimer.cancel (); |
|
|
|
if (acknowledged) |
|
|
|
if (acknowledged) |
|
|
@ -677,6 +693,7 @@ namespace stream |
|
|
|
htobe32buf (packet + size, lastReceivedSeqn); |
|
|
|
htobe32buf (packet + size, lastReceivedSeqn); |
|
|
|
size += 4; // ack Through
|
|
|
|
size += 4; // ack Through
|
|
|
|
uint8_t numNacks = 0; |
|
|
|
uint8_t numNacks = 0; |
|
|
|
|
|
|
|
bool choking = false; |
|
|
|
if (lastReceivedSeqn > m_LastReceivedSequenceNumber) |
|
|
|
if (lastReceivedSeqn > m_LastReceivedSequenceNumber) |
|
|
|
{ |
|
|
|
{ |
|
|
|
// fill NACKs
|
|
|
|
// fill NACKs
|
|
|
@ -688,7 +705,8 @@ namespace stream |
|
|
|
if (numNacks + (seqn - nextSeqn) >= 256) |
|
|
|
if (numNacks + (seqn - nextSeqn) >= 256) |
|
|
|
{ |
|
|
|
{ |
|
|
|
LogPrint (eLogError, "Streaming: Number of NACKs exceeds 256. seqn=", seqn, " nextSeqn=", nextSeqn); |
|
|
|
LogPrint (eLogError, "Streaming: Number of NACKs exceeds 256. seqn=", seqn, " nextSeqn=", nextSeqn); |
|
|
|
htobe32buf (packet + 12, nextSeqn); // change ack Through
|
|
|
|
htobe32buf (packet + 12, nextSeqn - 1); // change ack Through back
|
|
|
|
|
|
|
|
choking = true; |
|
|
|
break; |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
for (uint32_t i = nextSeqn; i < seqn; i++) |
|
|
|
for (uint32_t i = nextSeqn; i < seqn; i++) |
|
|
@ -711,8 +729,15 @@ namespace stream |
|
|
|
} |
|
|
|
} |
|
|
|
packet[size] = 0; |
|
|
|
packet[size] = 0; |
|
|
|
size++; // resend delay
|
|
|
|
size++; // resend delay
|
|
|
|
htobuf16 (packet + size, 0); // no flags set
|
|
|
|
htobuf16 (packet + size, choking ? PACKET_FLAG_DELAY_REQUESTED : 0); // no flags set or delay
|
|
|
|
size += 2; // flags
|
|
|
|
size += 2; // flags
|
|
|
|
|
|
|
|
if (choking) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
htobuf16 (packet + size, 2); // 2 bytes delay interval
|
|
|
|
|
|
|
|
htobuf16 (packet + size + 2, DELAY_CHOKING); // set choking interval
|
|
|
|
|
|
|
|
size += 2; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
else |
|
|
|
htobuf16 (packet + size, 0); // no options
|
|
|
|
htobuf16 (packet + size, 0); // no options
|
|
|
|
size += 2; // options size
|
|
|
|
size += 2; // options size
|
|
|
|
p.len = size; |
|
|
|
p.len = size; |
|
|
@ -881,7 +906,7 @@ namespace stream |
|
|
|
m_CurrentOutboundTunnel = routingPath->outboundTunnel; |
|
|
|
m_CurrentOutboundTunnel = routingPath->outboundTunnel; |
|
|
|
m_CurrentRemoteLease = routingPath->remoteLease; |
|
|
|
m_CurrentRemoteLease = routingPath->remoteLease; |
|
|
|
m_RTT = routingPath->rtt; |
|
|
|
m_RTT = routingPath->rtt; |
|
|
|
m_RTO = m_RTT*1.5; // TODO: implement it better
|
|
|
|
m_RTO = std::max (MIN_RTO, (int)(m_RTT * 1.5)); // TODO: implement it better
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -891,20 +916,32 @@ namespace stream |
|
|
|
UpdateCurrentRemoteLease (true); |
|
|
|
UpdateCurrentRemoteLease (true); |
|
|
|
if (m_CurrentRemoteLease && ts < m_CurrentRemoteLease->endDate + i2p::data::LEASE_ENDDATE_THRESHOLD) |
|
|
|
if (m_CurrentRemoteLease && ts < m_CurrentRemoteLease->endDate + i2p::data::LEASE_ENDDATE_THRESHOLD) |
|
|
|
{ |
|
|
|
{ |
|
|
|
|
|
|
|
bool freshTunnel = false; |
|
|
|
if (!m_CurrentOutboundTunnel) |
|
|
|
if (!m_CurrentOutboundTunnel) |
|
|
|
{ |
|
|
|
{ |
|
|
|
auto leaseRouter = i2p::data::netdb.FindRouter (m_CurrentRemoteLease->tunnelGateway); |
|
|
|
auto leaseRouter = i2p::data::netdb.FindRouter (m_CurrentRemoteLease->tunnelGateway); |
|
|
|
m_CurrentOutboundTunnel = m_LocalDestination.GetOwner ()->GetTunnelPool ()->GetNextOutboundTunnel (nullptr, |
|
|
|
m_CurrentOutboundTunnel = m_LocalDestination.GetOwner ()->GetTunnelPool ()->GetNextOutboundTunnel (nullptr, |
|
|
|
leaseRouter ? leaseRouter->GetCompatibleTransports (false) : (i2p::data::RouterInfo::CompatibleTransports)i2p::data::RouterInfo::eAllTransports); |
|
|
|
leaseRouter ? leaseRouter->GetCompatibleTransports (false) : (i2p::data::RouterInfo::CompatibleTransports)i2p::data::RouterInfo::eAllTransports); |
|
|
|
|
|
|
|
freshTunnel = true; |
|
|
|
} |
|
|
|
} |
|
|
|
else if (!m_CurrentOutboundTunnel->IsEstablished ()) |
|
|
|
else if (!m_CurrentOutboundTunnel->IsEstablished ()) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
auto oldOutboundTunnel = m_CurrentOutboundTunnel; |
|
|
|
m_CurrentOutboundTunnel = m_LocalDestination.GetOwner ()->GetTunnelPool ()->GetNewOutboundTunnel (m_CurrentOutboundTunnel); |
|
|
|
m_CurrentOutboundTunnel = m_LocalDestination.GetOwner ()->GetTunnelPool ()->GetNewOutboundTunnel (m_CurrentOutboundTunnel); |
|
|
|
|
|
|
|
if (m_CurrentOutboundTunnel && oldOutboundTunnel->GetEndpointIdentHash() != m_CurrentOutboundTunnel->GetEndpointIdentHash()) |
|
|
|
|
|
|
|
freshTunnel = true; |
|
|
|
|
|
|
|
} |
|
|
|
if (!m_CurrentOutboundTunnel) |
|
|
|
if (!m_CurrentOutboundTunnel) |
|
|
|
{ |
|
|
|
{ |
|
|
|
LogPrint (eLogError, "Streaming: No outbound tunnels in the pool, sSID=", m_SendStreamID); |
|
|
|
LogPrint (eLogError, "Streaming: No outbound tunnels in the pool, sSID=", m_SendStreamID); |
|
|
|
m_CurrentRemoteLease = nullptr; |
|
|
|
m_CurrentRemoteLease = nullptr; |
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
if (freshTunnel) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
m_RTO = INITIAL_RTO; |
|
|
|
|
|
|
|
m_TunnelsChangeSequenceNumber = m_SequenceNumber; // should be determined more precisely
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
std::vector<i2p::tunnel::TunnelMessageBlock> msgs; |
|
|
|
std::vector<i2p::tunnel::TunnelMessageBlock> msgs; |
|
|
|
for (const auto& it: packets) |
|
|
|
for (const auto& it: packets) |
|
|
@ -936,10 +973,10 @@ namespace stream |
|
|
|
if (m_RoutingSession->IsLeaseSetNonConfirmed ()) |
|
|
|
if (m_RoutingSession->IsLeaseSetNonConfirmed ()) |
|
|
|
{ |
|
|
|
{ |
|
|
|
auto ts = i2p::util::GetMillisecondsSinceEpoch (); |
|
|
|
auto ts = i2p::util::GetMillisecondsSinceEpoch (); |
|
|
|
if (ts > m_RoutingSession->GetLeaseSetSubmissionTime () + i2p::garlic::LEASET_CONFIRMATION_TIMEOUT) |
|
|
|
if (ts > m_RoutingSession->GetLeaseSetSubmissionTime () + i2p::garlic::LEASESET_CONFIRMATION_TIMEOUT) |
|
|
|
{ |
|
|
|
{ |
|
|
|
// LeaseSet was not confirmed, should try other tunnels
|
|
|
|
// LeaseSet was not confirmed, should try other tunnels
|
|
|
|
LogPrint (eLogWarning, "Streaming: LeaseSet was not confirmed in ", i2p::garlic::LEASET_CONFIRMATION_TIMEOUT, " milliseconds. Trying to resubmit"); |
|
|
|
LogPrint (eLogWarning, "Streaming: LeaseSet was not confirmed in ", i2p::garlic::LEASESET_CONFIRMATION_TIMEOUT, " milliseconds. Trying to resubmit"); |
|
|
|
m_RoutingSession->SetSharedRoutingPath (nullptr); |
|
|
|
m_RoutingSession->SetSharedRoutingPath (nullptr); |
|
|
|
m_CurrentOutboundTunnel = nullptr; |
|
|
|
m_CurrentOutboundTunnel = nullptr; |
|
|
|
m_CurrentRemoteLease = nullptr; |
|
|
|
m_CurrentRemoteLease = nullptr; |
|
|
@ -989,6 +1026,7 @@ namespace stream |
|
|
|
{ |
|
|
|
{ |
|
|
|
if (ts >= it->sendTime + m_RTO) |
|
|
|
if (ts >= it->sendTime + m_RTO) |
|
|
|
{ |
|
|
|
{ |
|
|
|
|
|
|
|
it->resent = true; |
|
|
|
it->sendTime = ts; |
|
|
|
it->sendTime = ts; |
|
|
|
packets.push_back (it); |
|
|
|
packets.push_back (it); |
|
|
|
} |
|
|
|
} |
|
|
@ -998,31 +1036,31 @@ namespace stream |
|
|
|
if (packets.size () > 0) |
|
|
|
if (packets.size () > 0) |
|
|
|
{ |
|
|
|
{ |
|
|
|
m_NumResendAttempts++; |
|
|
|
m_NumResendAttempts++; |
|
|
|
m_RTO *= 2; |
|
|
|
if (m_NumResendAttempts == 1 && m_RTO != INITIAL_RTO) |
|
|
|
switch (m_NumResendAttempts) |
|
|
|
|
|
|
|
{ |
|
|
|
{ |
|
|
|
case 1: // congestion avoidance
|
|
|
|
// congestion avoidance
|
|
|
|
|
|
|
|
m_RTO *= 2; |
|
|
|
m_WindowSize -= (m_WindowSize + WINDOW_SIZE_DROP_FRACTION) / WINDOW_SIZE_DROP_FRACTION; // adjustment >= 1
|
|
|
|
m_WindowSize -= (m_WindowSize + WINDOW_SIZE_DROP_FRACTION) / WINDOW_SIZE_DROP_FRACTION; // adjustment >= 1
|
|
|
|
if (m_WindowSize < MIN_WINDOW_SIZE) m_WindowSize = MIN_WINDOW_SIZE; |
|
|
|
if (m_WindowSize < MIN_WINDOW_SIZE) m_WindowSize = MIN_WINDOW_SIZE; |
|
|
|
break; |
|
|
|
} |
|
|
|
case 2: |
|
|
|
else |
|
|
|
m_RTO = INITIAL_RTO; // drop RTO to initial upon tunnels pair change first time
|
|
|
|
{ |
|
|
|
#if (__cplusplus >= 201703L) // C++ 17 or higher
|
|
|
|
m_TunnelsChangeSequenceNumber = m_SequenceNumber; |
|
|
|
[[fallthrough]]; |
|
|
|
m_RTO = INITIAL_RTO; // drop RTO to initial upon tunnels pair change
|
|
|
|
#endif |
|
|
|
|
|
|
|
// no break here
|
|
|
|
|
|
|
|
case 4: |
|
|
|
|
|
|
|
if (m_RoutingSession) m_RoutingSession->SetSharedRoutingPath (nullptr); |
|
|
|
if (m_RoutingSession) m_RoutingSession->SetSharedRoutingPath (nullptr); |
|
|
|
UpdateCurrentRemoteLease (); // pick another lease
|
|
|
|
if (m_NumResendAttempts & 1) |
|
|
|
LogPrint (eLogWarning, "Streaming: Another remote lease has been selected for stream with rSID=", m_RecvStreamID, ", sSID=", m_SendStreamID); |
|
|
|
{ |
|
|
|
break; |
|
|
|
|
|
|
|
case 3: |
|
|
|
|
|
|
|
// pick another outbound tunnel
|
|
|
|
// pick another outbound tunnel
|
|
|
|
if (m_RoutingSession) m_RoutingSession->SetSharedRoutingPath (nullptr); |
|
|
|
|
|
|
|
m_CurrentOutboundTunnel = m_LocalDestination.GetOwner ()->GetTunnelPool ()->GetNextOutboundTunnel (m_CurrentOutboundTunnel); |
|
|
|
m_CurrentOutboundTunnel = m_LocalDestination.GetOwner ()->GetTunnelPool ()->GetNextOutboundTunnel (m_CurrentOutboundTunnel); |
|
|
|
LogPrint (eLogWarning, "Streaming: Another outbound tunnel has been selected for stream with sSID=", m_SendStreamID); |
|
|
|
LogPrint (eLogWarning, "Streaming: Resend #", m_NumResendAttempts, |
|
|
|
break; |
|
|
|
", another outbound tunnel has been selected for stream with sSID=", m_SendStreamID); |
|
|
|
default: ; |
|
|
|
} |
|
|
|
|
|
|
|
else |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
UpdateCurrentRemoteLease (); // pick another lease
|
|
|
|
|
|
|
|
LogPrint (eLogWarning, "Streaming: Resend #", m_NumResendAttempts, |
|
|
|
|
|
|
|
", another remote lease has been selected for stream with rSID=", m_RecvStreamID, ", sSID=", m_SendStreamID); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
SendPackets (packets); |
|
|
|
SendPackets (packets); |
|
|
|
} |
|
|
|
} |
|
|
@ -1055,11 +1093,15 @@ namespace stream |
|
|
|
if (m_Status == eStreamStatusOpen) |
|
|
|
if (m_Status == eStreamStatusOpen) |
|
|
|
{ |
|
|
|
{ |
|
|
|
if (m_RoutingSession && m_RoutingSession->IsLeaseSetNonConfirmed ()) |
|
|
|
if (m_RoutingSession && m_RoutingSession->IsLeaseSetNonConfirmed ()) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
auto ts = i2p::util::GetMillisecondsSinceEpoch (); |
|
|
|
|
|
|
|
if (ts > m_RoutingSession->GetLeaseSetSubmissionTime () + i2p::garlic::LEASESET_CONFIRMATION_TIMEOUT) |
|
|
|
{ |
|
|
|
{ |
|
|
|
// seems something went wrong and we should re-select tunnels
|
|
|
|
// seems something went wrong and we should re-select tunnels
|
|
|
|
m_CurrentOutboundTunnel = nullptr; |
|
|
|
m_CurrentOutboundTunnel = nullptr; |
|
|
|
m_CurrentRemoteLease = nullptr; |
|
|
|
m_CurrentRemoteLease = nullptr; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
SendQuickAck (); |
|
|
|
SendQuickAck (); |
|
|
|
} |
|
|
|
} |
|
|
|
m_IsAckSendScheduled = false; |
|
|
|
m_IsAckSendScheduled = false; |
|
|
|