Browse Source

don't send repliable datagram after less then 100 milliseconds

pull/1550/head
orignal 4 years ago
parent
commit
3ef8b3dcbb
  1. 16
      libi2pd_client/I2PTunnel.cpp
  2. 3
      libi2pd_client/I2PTunnel.h

16
libi2pd_client/I2PTunnel.cpp

@ -708,9 +708,12 @@ namespace client @@ -708,9 +708,12 @@ namespace client
if(!ecode)
{
LogPrint(eLogDebug, "UDPSession: forward ", len, "B from ", FromEndpoint);
LastActivity = i2p::util::GetMillisecondsSinceEpoch();
auto ts = i2p::util::GetMillisecondsSinceEpoch();
auto session = m_Destination->GetSession (Identity);
m_Destination->SendDatagram(session, m_Buffer, len, LocalPort, RemotePort);
if (ts > LastActivity + I2P_UDP_REPLIABLE_DATAGRAM_INTERVAL)
m_Destination->SendDatagram(session, m_Buffer, len, LocalPort, RemotePort);
else
m_Destination->SendRawDatagram(session, m_Buffer, len, LocalPort, RemotePort);
size_t numPackets = 0;
while (numPackets < i2p::datagram::DATAGRAM_SEND_QUEUE_MAX_SIZE)
{
@ -724,6 +727,7 @@ namespace client @@ -724,6 +727,7 @@ namespace client
if (numPackets > 0)
LogPrint(eLogDebug, "UDPSession: forward more ", numPackets, "packets B from ", FromEndpoint);
m_Destination->FlushSendQueue (session);
LastActivity = ts;
Receive();
}
else
@ -841,9 +845,13 @@ namespace client @@ -841,9 +845,13 @@ namespace client
m_LastPort = remotePort;
}
// send off to remote i2p destination
auto ts = i2p::util::GetMillisecondsSinceEpoch();
LogPrint(eLogDebug, "UDP Client: send ", transferred, " to ", m_RemoteIdent->ToBase32(), ":", RemotePort);
auto session = m_LocalDest->GetDatagramDestination()->GetSession (*m_RemoteIdent);
m_LocalDest->GetDatagramDestination()->SendDatagram (session, m_RecvBuff, transferred, remotePort, RemotePort);
if (ts > m_LastSession->second + I2P_UDP_REPLIABLE_DATAGRAM_INTERVAL)
m_LocalDest->GetDatagramDestination()->SendDatagram (session, m_RecvBuff, transferred, remotePort, RemotePort);
else
m_LocalDest->GetDatagramDestination()->SendRawDatagram (session, m_RecvBuff, transferred, remotePort, RemotePort);
size_t numPackets = 0;
while (numPackets < i2p::datagram::DATAGRAM_SEND_QUEUE_MAX_SIZE)
{
@ -862,7 +870,7 @@ namespace client @@ -862,7 +870,7 @@ namespace client
// mark convo as active
if (m_LastSession)
m_LastSession->second = i2p::util::GetMillisecondsSinceEpoch();
m_LastSession->second = ts;
RecvFromLocal();
}

3
libi2pd_client/I2PTunnel.h

@ -165,7 +165,8 @@ namespace client @@ -165,7 +165,8 @@ namespace client
/** 2 minute timeout for udp sessions */
const uint64_t I2P_UDP_SESSION_TIMEOUT = 1000 * 60 * 2;
const uint64_t I2P_UDP_REPLIABLE_DATAGRAM_INTERVAL = 100; // in milliseconds
/** max size for i2p udp */
const size_t I2P_UDP_MAX_MTU = 64*1024;

Loading…
Cancel
Save