1
1
Fork 0
mirror of https://github.com/oxen-io/lokinet synced 2023-12-14 06:53:00 +01:00

Merge pull request #1535 from majestrate/no-iwp-multiack-2021-02-13

only do single ack packets
This commit is contained in:
Jeff 2021-03-04 15:49:12 -05:00 committed by GitHub
commit 72c9b0f1b4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 21 additions and 15 deletions

View file

@ -775,12 +775,7 @@ namespace llarp
return; return;
} }
} }
auto msg = std::move(itr->second); HandleRecvMsgCompleted(itr->second);
const llarp_buffer_t buf(msg.m_Data);
m_Parent->HandleMessage(this, buf);
if (m_ReplayFilter.emplace(rxid, m_Parent->Now()).second)
m_SendMACKs.emplace(rxid);
m_RXMsgs.erase(rxid);
} }
} }
else else
@ -827,20 +822,27 @@ namespace llarp
{ {
if (itr->second.Verify()) if (itr->second.Verify())
{ {
auto msg = std::move(itr->second); HandleRecvMsgCompleted(itr->second);
const llarp_buffer_t buf(msg.m_Data);
m_Parent->HandleMessage(this, buf);
if (m_ReplayFilter.emplace(itr->first, m_Parent->Now()).second)
m_SendMACKs.emplace(itr->first);
} }
else else
{ {
LogError("hash mismatch for message ", itr->first); LogError("hash mismatch for message ", itr->first);
} }
m_RXMsgs.erase(itr);
} }
} }
void
Session::HandleRecvMsgCompleted(const InboundMessage& msg)
{
const auto rxid = msg.m_MsgID;
if (m_ReplayFilter.emplace(rxid, m_Parent->Now()).second)
{
m_Parent->HandleMessage(this, msg.m_Data);
EncryptAndSend(msg.ACKS());
}
m_RXMsgs.erase(rxid);
}
void void
Session::HandleACKS(Packet_t data) Session::HandleACKS(Packet_t data)
{ {

View file

@ -6,6 +6,7 @@
#include <iwp/message_buffer.hpp> #include <iwp/message_buffer.hpp>
#include <net/ip_address.hpp> #include <net/ip_address.hpp>
#include <map>
#include <unordered_set> #include <unordered_set>
#include <deque> #include <deque>
#include <queue> #include <queue>
@ -185,8 +186,8 @@ namespace llarp
void void
ResetRates(); ResetRates();
std::unordered_map<uint64_t, InboundMessage> m_RXMsgs; std::map<uint64_t, InboundMessage> m_RXMsgs;
std::unordered_map<uint64_t, OutboundMessage> m_TXMsgs; std::map<uint64_t, OutboundMessage> m_TXMsgs;
/// maps rxid to time recieved /// maps rxid to time recieved
std::unordered_map<uint64_t, llarp_time_t> m_ReplayFilter; std::unordered_map<uint64_t, llarp_time_t> m_ReplayFilter;
@ -227,6 +228,9 @@ namespace llarp
void void
SendMACK(); SendMACK();
void
HandleRecvMsgCompleted(const InboundMessage& msg);
void void
GenerateAndSendIntro(); GenerateAndSendIntro();

View file

@ -252,7 +252,7 @@ TEST_CASE("IWP send messages", "[iwp]")
std::function<void(void)> endTestNow, std::function<void(void)> endTestNow,
Context_ptr alice, Context_ptr alice,
Context_ptr bob) { Context_ptr bob) {
constexpr int numSend = 128; constexpr int numSend = 64;
// when alice makes a session to bob send `aliceNumSend` messages to him // when alice makes a session to bob send `aliceNumSend` messages to him
alice->InitLink<false>([endIfDone, alice, &aliceNumSent](auto session) { alice->InitLink<false>([endIfDone, alice, &aliceNumSent](auto session) {
for (auto index = 0; index < numSend; index++) for (auto index = 0; index < numSend; index++)