mirror of
https://github.com/PurpleI2P/i2pd.git
synced 2025-10-17 09:10:21 +01:00
save unacked seqn. handle acked option. calculate RTT
Some checks are pending
Build Debian packages / bookworm (push) Waiting to run
Build Debian packages / bullseye (push) Waiting to run
Build Debian packages / trixie (push) Waiting to run
Build on FreeBSD / with UPnP (push) Waiting to run
Build on OSX / With USE_UPNP=no (push) Waiting to run
Build on OSX / With USE_UPNP=yes (push) Waiting to run
Build on Windows / clang-x86_64 (push) Waiting to run
Build on Windows / i686 (push) Waiting to run
Build on Windows / ucrt-x86_64 (push) Waiting to run
Build on Windows / x86_64 (push) Waiting to run
Build on Windows / CMake clang-x86_64 (push) Waiting to run
Build on Windows / CMake i686 (push) Waiting to run
Build on Windows / CMake ucrt-x86_64 (push) Waiting to run
Build on Windows / CMake x86_64 (push) Waiting to run
Build on Windows / XP (push) Waiting to run
Build on Ubuntu / Make with USE_UPNP=no (push) Waiting to run
Build on Ubuntu / Make with USE_UPNP=yes (push) Waiting to run
Build on Ubuntu / CMake with -DWITH_UPNP=OFF (push) Waiting to run
Build on Ubuntu / CMake with -DWITH_UPNP=ON (push) Waiting to run
Build containers / Building container for linux/amd64 (push) Waiting to run
Build containers / Building container for linux/arm64 (push) Waiting to run
Build containers / Building container for linux/arm/v7 (push) Waiting to run
Build containers / Building container for linux/386 (push) Waiting to run
Build containers / Pushing merged manifest (push) Blocked by required conditions
Some checks are pending
Build Debian packages / bookworm (push) Waiting to run
Build Debian packages / bullseye (push) Waiting to run
Build Debian packages / trixie (push) Waiting to run
Build on FreeBSD / with UPnP (push) Waiting to run
Build on OSX / With USE_UPNP=no (push) Waiting to run
Build on OSX / With USE_UPNP=yes (push) Waiting to run
Build on Windows / clang-x86_64 (push) Waiting to run
Build on Windows / i686 (push) Waiting to run
Build on Windows / ucrt-x86_64 (push) Waiting to run
Build on Windows / x86_64 (push) Waiting to run
Build on Windows / CMake clang-x86_64 (push) Waiting to run
Build on Windows / CMake i686 (push) Waiting to run
Build on Windows / CMake ucrt-x86_64 (push) Waiting to run
Build on Windows / CMake x86_64 (push) Waiting to run
Build on Windows / XP (push) Waiting to run
Build on Ubuntu / Make with USE_UPNP=no (push) Waiting to run
Build on Ubuntu / Make with USE_UPNP=yes (push) Waiting to run
Build on Ubuntu / CMake with -DWITH_UPNP=OFF (push) Waiting to run
Build on Ubuntu / CMake with -DWITH_UPNP=ON (push) Waiting to run
Build containers / Building container for linux/amd64 (push) Waiting to run
Build containers / Building container for linux/arm64 (push) Waiting to run
Build containers / Building container for linux/arm/v7 (push) Waiting to run
Build containers / Building container for linux/386 (push) Waiting to run
Build containers / Pushing merged manifest (push) Blocked by required conditions
This commit is contained in:
parent
edf488cbc3
commit
cf48c205e1
2 changed files with 36 additions and 13 deletions
|
@ -38,10 +38,10 @@ namespace client
|
||||||
if (options->Get (UDP_SESSION_SEQN, seqn) && seqn > m_LastSession->m_LastReceivedPacketNum)
|
if (options->Get (UDP_SESSION_SEQN, seqn) && seqn > m_LastSession->m_LastReceivedPacketNum)
|
||||||
{
|
{
|
||||||
m_LastSession->m_LastReceivedPacketNum = seqn;
|
m_LastSession->m_LastReceivedPacketNum = seqn;
|
||||||
i2p::util::Mapping options;
|
i2p::util::Mapping replyOptions;
|
||||||
options.Put (UDP_SESSION_ACKED, m_LastSession->m_LastReceivedPacketNum);
|
replyOptions.Put (UDP_SESSION_ACKED, m_LastSession->m_LastReceivedPacketNum);
|
||||||
m_LastSession->m_Destination->SendDatagram(m_LastSession->GetDatagramSession (),
|
m_LastSession->m_Destination->SendDatagram(m_LastSession->GetDatagramSession (),
|
||||||
nullptr, 0, m_LastSession->LocalPort, m_LastSession->RemotePort, &options); // Ack only, no payload
|
nullptr, 0, m_LastSession->LocalPort, m_LastSession->RemotePort, &replyOptions); // Ack only, no payload
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -277,7 +277,7 @@ namespace client
|
||||||
m_Name (name), m_RemoteDest (remoteDest), m_LocalDest (localDestination), m_LocalEndpoint (localEndpoint),
|
m_Name (name), m_RemoteDest (remoteDest), m_LocalDest (localDestination), m_LocalEndpoint (localEndpoint),
|
||||||
m_ResolveThread (nullptr), m_LocalSocket (nullptr), RemotePort (remotePort),
|
m_ResolveThread (nullptr), m_LocalSocket (nullptr), RemotePort (remotePort),
|
||||||
m_LastPort (0), m_cancel_resolve (false), m_Gzip (gzip), m_DatagramVersion (datagramVersion),
|
m_LastPort (0), m_cancel_resolve (false), m_Gzip (gzip), m_DatagramVersion (datagramVersion),
|
||||||
m_NextSendPacketNum (1), m_LastReceivedPacketNum (0)
|
m_NextSendPacketNum (1), m_LastReceivedPacketNum (0), m_RTT (0)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -377,10 +377,13 @@ namespace client
|
||||||
auto ts = i2p::util::GetMillisecondsSinceEpoch ();
|
auto ts = i2p::util::GetMillisecondsSinceEpoch ();
|
||||||
LogPrint (eLogDebug, "UDP Client: Send ", transferred, " to ", m_RemoteAddr->identHash.ToBase32 (), ":", RemotePort);
|
LogPrint (eLogDebug, "UDP Client: Send ", transferred, " to ", m_RemoteAddr->identHash.ToBase32 (), ":", RemotePort);
|
||||||
auto session = GetDatagramSession ();
|
auto session = GetDatagramSession ();
|
||||||
if (ts > m_LastSession->second + I2P_UDP_REPLIABLE_DATAGRAM_INTERVAL)
|
uint64_t repliableDatagramInterval = I2P_UDP_REPLIABLE_DATAGRAM_INTERVAL;
|
||||||
|
if (m_RTT && m_RTT < I2P_UDP_REPLIABLE_DATAGRAM_INTERVAL*10) repliableDatagramInterval = m_RTT/10;
|
||||||
|
if (ts > m_LastSession->second + repliableDatagramInterval )
|
||||||
{
|
{
|
||||||
if (m_DatagramVersion == i2p::datagram::eDatagramV3)
|
if (m_DatagramVersion == i2p::datagram::eDatagramV3)
|
||||||
{
|
{
|
||||||
|
m_UnackedDatagrams.push_back ({ m_NextSendPacketNum, ts });
|
||||||
i2p::util::Mapping options;
|
i2p::util::Mapping options;
|
||||||
options.Put (UDP_SESSION_SEQN, m_NextSendPacketNum);
|
options.Put (UDP_SESSION_SEQN, m_NextSendPacketNum);
|
||||||
if (m_LastReceivedPacketNum > 0)
|
if (m_LastReceivedPacketNum > 0)
|
||||||
|
@ -467,11 +470,13 @@ namespace client
|
||||||
if (options->Get (UDP_SESSION_SEQN, seqn) && seqn > m_LastReceivedPacketNum)
|
if (options->Get (UDP_SESSION_SEQN, seqn) && seqn > m_LastReceivedPacketNum)
|
||||||
{
|
{
|
||||||
m_LastReceivedPacketNum = seqn;
|
m_LastReceivedPacketNum = seqn;
|
||||||
i2p::util::Mapping options;
|
i2p::util::Mapping replyOptions;
|
||||||
options.Put (UDP_SESSION_ACKED, m_LastReceivedPacketNum);
|
replyOptions.Put (UDP_SESSION_ACKED, m_LastReceivedPacketNum);
|
||||||
m_LocalDest->GetDatagramDestination ()->SendDatagram (GetDatagramSession (),
|
m_LocalDest->GetDatagramDestination ()->SendDatagram (GetDatagramSession (),
|
||||||
nullptr, 0, m_LastPort, RemotePort, &options); // Ack only, no payload
|
nullptr, 0, m_LastPort, RemotePort, &replyOptions); // Ack only, no payload
|
||||||
}
|
}
|
||||||
|
if (options->Get (UDP_SESSION_ACKED, seqn))
|
||||||
|
Acked (seqn);
|
||||||
}
|
}
|
||||||
if (len > 0)
|
if (len > 0)
|
||||||
HandleRecvFromI2PRaw (fromPort, toPort, buf, len);
|
HandleRecvFromI2PRaw (fromPort, toPort, buf, len);
|
||||||
|
@ -503,5 +508,19 @@ namespace client
|
||||||
LogPrint (eLogWarning, "UDP Client: Not tracking udp session using port ", (int) toPort);
|
LogPrint (eLogWarning, "UDP Client: Not tracking udp session using port ", (int) toPort);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void I2PUDPClientTunnel::Acked (uint32_t seqn)
|
||||||
|
{
|
||||||
|
if (m_UnackedDatagrams.empty () && seqn < m_UnackedDatagrams.front ().first) return;
|
||||||
|
auto it = m_UnackedDatagrams.begin ();
|
||||||
|
while (it != m_UnackedDatagrams.end ())
|
||||||
|
{
|
||||||
|
if (it->first > seqn) break;
|
||||||
|
if (it->first == seqn)
|
||||||
|
m_RTT = i2p::util::GetMillisecondsSinceEpoch () - it->second;
|
||||||
|
it++;
|
||||||
|
}
|
||||||
|
m_UnackedDatagrams.erase (m_UnackedDatagrams.begin (), it);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,6 +14,7 @@
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <thread>
|
#include <thread>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
#include <list>
|
||||||
#include <unordered_map>
|
#include <unordered_map>
|
||||||
#include <boost/asio.hpp>
|
#include <boost/asio.hpp>
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
|
@ -32,7 +33,7 @@ namespace client
|
||||||
|
|
||||||
/** max size for i2p udp */
|
/** max size for i2p udp */
|
||||||
const size_t I2P_UDP_MAX_MTU = 64*1024;
|
const size_t I2P_UDP_MAX_MTU = 64*1024;
|
||||||
|
|
||||||
struct UDPSession
|
struct UDPSession
|
||||||
{
|
{
|
||||||
i2p::datagram::DatagramDestination * m_Destination;
|
i2p::datagram::DatagramDestination * m_Destination;
|
||||||
|
@ -110,7 +111,7 @@ namespace client
|
||||||
void HandleRecvFromI2PRaw (uint16_t fromPort, uint16_t toPort, const uint8_t * buf, size_t len);
|
void HandleRecvFromI2PRaw (uint16_t fromPort, uint16_t toPort, const uint8_t * buf, size_t len);
|
||||||
UDPSessionPtr ObtainUDPSession (const i2p::data::IdentityEx& from, uint16_t localPort, uint16_t remotePort);
|
UDPSessionPtr ObtainUDPSession (const i2p::data::IdentityEx& from, uint16_t localPort, uint16_t remotePort);
|
||||||
uint32_t GetSessionIndex (uint16_t fromPort, uint16_t toPort) const { return ((uint32_t)fromPort << 16) + toPort; }
|
uint32_t GetSessionIndex (uint16_t fromPort, uint16_t toPort) const { return ((uint32_t)fromPort << 16) + toPort; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
bool m_IsUniqueLocal;
|
bool m_IsUniqueLocal;
|
||||||
|
@ -165,7 +166,8 @@ namespace client
|
||||||
void HandleRecvFromI2PRaw (uint16_t fromPort, uint16_t toPort, const uint8_t * buf, size_t len);
|
void HandleRecvFromI2PRaw (uint16_t fromPort, uint16_t toPort, const uint8_t * buf, size_t len);
|
||||||
void TryResolving ();
|
void TryResolving ();
|
||||||
std::shared_ptr<i2p::datagram::DatagramSession> GetDatagramSession ();
|
std::shared_ptr<i2p::datagram::DatagramSession> GetDatagramSession ();
|
||||||
|
void Acked (uint32_t seqn);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
const std::string m_Name;
|
const std::string m_Name;
|
||||||
|
@ -186,7 +188,9 @@ namespace client
|
||||||
std::shared_ptr<UDPConvo> m_LastSession;
|
std::shared_ptr<UDPConvo> m_LastSession;
|
||||||
std::weak_ptr<i2p::datagram::DatagramSession> m_LastDatagramSession;
|
std::weak_ptr<i2p::datagram::DatagramSession> m_LastDatagramSession;
|
||||||
uint32_t m_NextSendPacketNum, m_LastReceivedPacketNum;
|
uint32_t m_NextSendPacketNum, m_LastReceivedPacketNum;
|
||||||
|
std::list<std::pair<uint32_t, uint64_t> > m_UnackedDatagrams; // list of sent but not acked repliable datagrams(seqn, timestamp) in ascending order
|
||||||
|
uint64_t m_RTT; // milliseconds
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
bool isUpdated; // transient, used during reload only
|
bool isUpdated; // transient, used during reload only
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue