Browse Source

set min pacing time to 250 microseconds

pull/2094/head
orignal 5 months ago
parent
commit
efd754eb93
  1. 14
      libi2pd/Streaming.cpp
  2. 3
      libi2pd/Streaming.h

14
libi2pd/Streaming.cpp

@ -76,14 +76,17 @@ namespace stream @@ -76,14 +76,17 @@ namespace stream
m_AckSendTimer (m_Service), m_NumSentBytes (0), m_NumReceivedBytes (0), m_Port (port),
m_RTT (INITIAL_RTT), m_WindowSize (INITIAL_WINDOW_SIZE), m_RTO (INITIAL_RTO),
m_AckDelay (local.GetOwner ()->GetStreamingAckDelay ()), m_PrevRTTSample (INITIAL_RTT),
m_PrevRTT (INITIAL_RTT), m_Jitter (0), m_MinPacingTime (0),
m_PrevRTT (INITIAL_RTT), m_Jitter (0), m_MinPacingTime (MIN_PACING_TIME),
m_PacingTime (INITIAL_PACING_TIME), m_NumResendAttempts (0), m_MTU (STREAMING_MTU)
{
RAND_bytes ((uint8_t *)&m_RecvStreamID, 4);
m_RemoteIdentity = remote->GetIdentity ();
auto outboundSpeed = local.GetOwner ()->GetStreamingOutboundSpeed ();
if (outboundSpeed)
m_MinPacingTime = (1000000LL*STREAMING_MTU)/outboundSpeed;
{
auto minPacingTime = (1000000LL*STREAMING_MTU)/outboundSpeed;
if (minPacingTime > m_MinPacingTime) m_MinPacingTime = minPacingTime;
}
}
Stream::Stream (boost::asio::io_service& service, StreamingDestination& local):
@ -94,13 +97,16 @@ namespace stream @@ -94,13 +97,16 @@ namespace stream
m_ReceiveTimer (m_Service), m_SendTimer (m_Service), m_ResendTimer (m_Service), m_AckSendTimer (m_Service),
m_NumSentBytes (0), m_NumReceivedBytes (0), m_Port (0), m_RTT (INITIAL_RTT),
m_WindowSize (INITIAL_WINDOW_SIZE), m_RTO (INITIAL_RTO), m_AckDelay (local.GetOwner ()->GetStreamingAckDelay ()),
m_PrevRTTSample (INITIAL_RTT), m_PrevRTT (INITIAL_RTT), m_Jitter (0), m_MinPacingTime (0),
m_PrevRTTSample (INITIAL_RTT), m_PrevRTT (INITIAL_RTT), m_Jitter (0), m_MinPacingTime (MIN_PACING_TIME),
m_PacingTime (INITIAL_PACING_TIME), m_NumResendAttempts (0), m_MTU (STREAMING_MTU)
{
RAND_bytes ((uint8_t *)&m_RecvStreamID, 4);
auto outboundSpeed = local.GetOwner ()->GetStreamingOutboundSpeed ();
if (outboundSpeed)
m_MinPacingTime = (1000000LL*STREAMING_MTU)/outboundSpeed;
{
auto minPacingTime = (1000000LL*STREAMING_MTU)/outboundSpeed;
if (minPacingTime > m_MinPacingTime) m_MinPacingTime = minPacingTime;
}
}
Stream::~Stream ()

3
libi2pd/Streaming.h

@ -67,6 +67,7 @@ namespace stream @@ -67,6 +67,7 @@ namespace stream
const int PENDING_INCOMING_TIMEOUT = 10; // in seconds
const int MAX_RECEIVE_TIMEOUT = 20; // in seconds
const uint16_t DELAY_CHOKING = 60000; // in milliseconds
const uint64_t MIN_PACING_TIME = 250; // in microseconds. TODO: depends on OS
struct Packet
{
@ -271,7 +272,7 @@ namespace stream @@ -271,7 +272,7 @@ namespace stream
SendBufferQueue m_SendBuffer;
double m_RTT;
int m_WindowSize, m_RTO, m_AckDelay, m_PrevRTTSample, m_PrevRTT, m_Jitter;
uint64_t m_MinPacingTime, m_PacingTime;
uint64_t m_MinPacingTime, m_PacingTime; // miscroseconds
int m_NumResendAttempts;
size_t m_MTU;
};

Loading…
Cancel
Save