mirror of
https://github.com/PurpleI2P/i2pd.git
synced 2025-01-22 12:24:19 +00:00
resend intervals in milliseconds
This commit is contained in:
parent
fd41fba069
commit
e70d57dcb4
@ -729,7 +729,7 @@ namespace transport
|
||||
|
||||
void SSU2Server::ScheduleResend ()
|
||||
{
|
||||
m_ResendTimer.expires_from_now (boost::posix_time::seconds(SSU2_RESEND_INTERVAL));
|
||||
m_ResendTimer.expires_from_now (boost::posix_time::milliseconds(SSU2_RESEND_CHECK_TIMEOUT));
|
||||
m_ResendTimer.async_wait (std::bind (&SSU2Server::HandleResendTimer,
|
||||
this, std::placeholders::_1));
|
||||
}
|
||||
@ -738,7 +738,7 @@ namespace transport
|
||||
{
|
||||
if (ecode != boost::asio::error::operation_aborted)
|
||||
{
|
||||
auto ts = i2p::util::GetSecondsSinceEpoch ();
|
||||
auto ts = i2p::util::GetMillisecondsSinceEpoch ();
|
||||
for (auto it: m_Sessions)
|
||||
it.second->Resend (ts);
|
||||
for (auto it: m_PendingOutgoingSessions)
|
||||
|
@ -17,7 +17,8 @@ namespace i2p
|
||||
{
|
||||
namespace transport
|
||||
{
|
||||
const int SSU2_TERMINATION_CHECK_TIMEOUT = 30; // 30 seconds
|
||||
const int SSU2_TERMINATION_CHECK_TIMEOUT = 30; // in seconds
|
||||
const int SSU2_RESEND_CHECK_TIMEOUT = 500; // in milliseconds
|
||||
const size_t SSU2_SOCKET_RECEIVE_BUFFER_SIZE = 0x1FFFF; // 128K
|
||||
const size_t SSU2_SOCKET_SEND_BUFFER_SIZE = 0x1FFFF; // 128K
|
||||
const size_t SSU2_MAX_NUM_INTRODUCERS = 3;
|
||||
|
@ -265,7 +265,7 @@ namespace transport
|
||||
{
|
||||
if (!m_SendQueue.empty () && m_SentPackets.size () <= m_WindowSize)
|
||||
{
|
||||
auto nextResend = i2p::util::GetSecondsSinceEpoch () + SSU2_RESEND_INTERVAL;
|
||||
auto nextResend = i2p::util::GetMillisecondsSinceEpoch () + SSU2_RESEND_INTERVAL;
|
||||
auto packet = std::make_shared<SentPacket>();
|
||||
size_t ackBlockSize = CreateAckBlock (packet->payload, m_MaxPayloadSize);
|
||||
bool ackBlockSent = false;
|
||||
@ -344,7 +344,7 @@ namespace transport
|
||||
bool ackBlockSent = false;
|
||||
uint32_t msgID;
|
||||
memcpy (&msgID, msg->GetHeader () + I2NP_HEADER_MSGID_OFFSET, 4);
|
||||
auto nextResend = i2p::util::GetSecondsSinceEpoch () + SSU2_RESEND_INTERVAL;
|
||||
auto nextResend = i2p::util::GetMillisecondsSinceEpoch () + SSU2_RESEND_INTERVAL;
|
||||
auto packet = std::make_shared<SentPacket>();
|
||||
if (extraSize >= 8)
|
||||
{
|
||||
@ -414,7 +414,6 @@ namespace transport
|
||||
uint32_t packetNum = SendData (it->second->payload, it->second->payloadSize);
|
||||
it->second->numResends++;
|
||||
it->second->nextResendTime = ts + it->second->numResends*SSU2_RESEND_INTERVAL;
|
||||
m_LastActivityTimestamp = ts;
|
||||
resentPackets.emplace (packetNum, it->second);
|
||||
it = m_SentPackets.erase (it);
|
||||
}
|
||||
@ -486,7 +485,7 @@ namespace transport
|
||||
// we are Alice
|
||||
m_EphemeralKeys = i2p::transport::transports.GetNextX25519KeysPair ();
|
||||
m_SentHandshakePacket.reset (new HandshakePacket);
|
||||
auto ts = i2p::util::GetSecondsSinceEpoch ();
|
||||
auto ts = i2p::util::GetMillisecondsSinceEpoch ();
|
||||
m_SentHandshakePacket->nextResendTime = ts + SSU2_HANDSHAKE_RESEND_INTERVAL;
|
||||
|
||||
Header& header = m_SentHandshakePacket->header;
|
||||
@ -505,7 +504,7 @@ namespace transport
|
||||
// payload
|
||||
payload[0] = eSSU2BlkDateTime;
|
||||
htobe16buf (payload + 1, 4);
|
||||
htobe32buf (payload + 3, ts);
|
||||
htobe32buf (payload + 3, ts/1000);
|
||||
size_t payloadSize = 7;
|
||||
if (GetRouterStatus () == eRouterStatusFirewalled && m_Address->IsIntroducer ())
|
||||
{
|
||||
@ -587,7 +586,7 @@ namespace transport
|
||||
// we are Bob
|
||||
m_EphemeralKeys = i2p::transport::transports.GetNextX25519KeysPair ();
|
||||
m_SentHandshakePacket.reset (new HandshakePacket);
|
||||
auto ts = i2p::util::GetSecondsSinceEpoch ();
|
||||
auto ts = i2p::util::GetMillisecondsSinceEpoch ();
|
||||
m_SentHandshakePacket->nextResendTime = ts + SSU2_HANDSHAKE_RESEND_INTERVAL;
|
||||
|
||||
uint8_t kh2[32];
|
||||
@ -609,7 +608,7 @@ namespace transport
|
||||
size_t maxPayloadSize = m_MaxPayloadSize - 48;
|
||||
payload[0] = eSSU2BlkDateTime;
|
||||
htobe16buf (payload + 1, 4);
|
||||
htobe32buf (payload + 3, ts);
|
||||
htobe32buf (payload + 3, ts/1000);
|
||||
size_t payloadSize = 7;
|
||||
payloadSize += CreateAddressBlock (payload + payloadSize, maxPayloadSize - payloadSize, m_RemoteEndpoint);
|
||||
if (m_RelayTag)
|
||||
@ -700,8 +699,7 @@ namespace transport
|
||||
{
|
||||
// we are Alice
|
||||
m_SentHandshakePacket.reset (new HandshakePacket);
|
||||
auto ts = i2p::util::GetSecondsSinceEpoch ();
|
||||
m_SentHandshakePacket->nextResendTime = ts + SSU2_HANDSHAKE_RESEND_INTERVAL;
|
||||
m_SentHandshakePacket->nextResendTime = i2p::util::GetMillisecondsSinceEpoch () + SSU2_HANDSHAKE_RESEND_INTERVAL;
|
||||
|
||||
uint8_t kh2[32];
|
||||
i2p::crypto::HKDF (m_NoiseState->m_CK, nullptr, 0, "SessionConfirmed", kh2, 32); // k_header_2 = HKDF(chainKey, ZEROLEN, "SessionConfirmed", 32)
|
||||
|
@ -35,7 +35,7 @@ namespace transport
|
||||
const size_t SSU2_MAX_PACKET_SIZE = 1500;
|
||||
const size_t SSU2_MIN_PACKET_SIZE = 1280;
|
||||
const int SSU2_HANDSHAKE_RESEND_INTERVAL = 1; // in seconds
|
||||
const int SSU2_RESEND_INTERVAL = 3; // in seconds
|
||||
const int SSU2_RESEND_INTERVAL = 300; // in milliseconds
|
||||
const int SSU2_MAX_NUM_RESENDS = 5;
|
||||
const int SSU2_INCOMPLETE_MESSAGES_CLEANUP_TIMEOUT = 30; // in seconds
|
||||
const size_t SSU2_MIN_WINDOW_SIZE = 8; // in packets
|
||||
@ -189,7 +189,7 @@ namespace transport
|
||||
{
|
||||
uint8_t payload[SSU2_MAX_PACKET_SIZE];
|
||||
size_t payloadSize = 0;
|
||||
uint32_t nextResendTime; // in seconds
|
||||
uint64_t nextResendTime; // in milliseconds
|
||||
int numResends = 0;
|
||||
};
|
||||
|
||||
@ -199,7 +199,7 @@ namespace transport
|
||||
uint8_t headerX[48]; // part1 for SessionConfirmed
|
||||
uint8_t payload[SSU2_MAX_PACKET_SIZE*2];
|
||||
size_t payloadSize = 0;
|
||||
uint32_t nextResendTime = 0; // in seconds
|
||||
uint64_t nextResendTime = 0; // in milliseconds
|
||||
bool isSecondFragment = false; // for SessionConfirmed
|
||||
};
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user