| 688 | } |
| 689 | |
| 690 | void Stream::ProcessAck (Packet * packet) |
| 691 | { |
| 692 | bool acknowledged = false; |
| 693 | auto ts = i2p::util::GetMillisecondsSinceEpoch (); |
| 694 | uint32_t ackThrough = packet->GetAckThrough (); |
| 695 | m_NACKedPackets.clear (); |
| 696 | if (ackThrough > m_SequenceNumber) |
| 697 | { |
| 698 | LogPrint (eLogError, "Streaming: Unexpected ackThrough=", ackThrough, " > seqn=", m_SequenceNumber); |
| 699 | return; |
| 700 | } |
| 701 | int rttSample = INT_MAX; |
| 702 | int incCounter = 0; |
| 703 | int ackPacketsCounter = 0; |
| 704 | m_IsNAcked = false; |
| 705 | m_IsResendNeeded = false; |
| 706 | int nackCount = packet->GetNACKCount (); |
| 707 | for (auto it = m_SentPackets.begin (); it != m_SentPackets.end ();) |
| 708 | { |
| 709 | auto seqn = (*it)->GetSeqn (); |
| 710 | if (seqn <= ackThrough) |
| 711 | { |
| 712 | if (nackCount > 0) |
| 713 | { |
| 714 | bool nacked = false; |
| 715 | for (int i = 0; i < nackCount; i++) |
| 716 | if (seqn == packet->GetNACK (i)) |
| 717 | { |
| 718 | m_NACKedPackets.insert (*it); |
| 719 | m_IsNAcked = true; |
| 720 | nacked = true; |
| 721 | break; |
| 722 | } |
| 723 | if (nacked) |
| 724 | { |
| 725 | LogPrint (eLogDebug, "Streaming: Packet ", seqn, " NACK"); |
| 726 | ++it; |
| 727 | continue; |
| 728 | } |
| 729 | } |
| 730 | auto sentPacket = *it; |
| 731 | int64_t rtt = (int64_t)ts - (int64_t)sentPacket->sendTime; |
| 732 | if (rtt < 0) |
| 733 | LogPrint (eLogError, "Streaming: Packet ", seqn, "sent from the future, sendTime=", sentPacket->sendTime); |
| 734 | if (!seqn) |
| 735 | { |
| 736 | m_IsFirstRttSample = true; |
| 737 | rttSample = rtt < 0 ? 1 : rtt; |
| 738 | } |
| 739 | else if (!sentPacket->resent && seqn > m_TunnelsChangeSequenceNumber && rtt >= 0) |
| 740 | rttSample = std::min (rttSample, (int)rtt); |
| 741 | LogPrint (eLogDebug, "Streaming: Packet ", seqn, " acknowledged rtt=", rtt, " sentTime=", sentPacket->sendTime); |
| 742 | m_SentPackets.erase (it++); |
| 743 | m_LocalDestination.DeletePacket (sentPacket); |
| 744 | acknowledged = true; |
| 745 | ackPacketsCounter++; |
| 746 | if (m_WindowIncCounter < m_MaxWindowSize && !m_IsFirstACK && !m_IsWinDropped) |
| 747 | incCounter++; |
nothing calls this directly
no test coverage detected