From 9d629254ff89c70162db926d32abca4fd57b46cb Mon Sep 17 00:00:00 2001 From: csoler Date: Fri, 8 Mar 2019 17:12:46 +0100 Subject: [PATCH] set default FT rate to some non zero value. Should start transfers faster. Needs testing. --- libretroshare/src/ft/fttransfermodule.cc | 38 ++++++++++-------- libretroshare/src/ft/fttransfermodule.h | 51 ++++++++++-------------- 2 files changed, 44 insertions(+), 45 deletions(-) diff --git a/libretroshare/src/ft/fttransfermodule.cc b/libretroshare/src/ft/fttransfermodule.cc index c7d3f45c9..524c503b0 100644 --- a/libretroshare/src/ft/fttransfermodule.cc +++ b/libretroshare/src/ft/fttransfermodule.cc @@ -44,34 +44,40 @@ * */ -const double FT_TM_MAX_PEER_RATE = 100 * 1024 * 1024; /* 100MB/s */ +const double FT_TM_MAX_PEER_RATE = 100 * 1024 * 1024; /* 100MB/s */ const uint32_t FT_TM_MAX_RESETS = 5; -const uint32_t FT_TM_MINIMUM_CHUNK = 1024; /* ie 1Kb / sec */ -const uint32_t FT_TM_RESTART_DOWNLOAD = 20; /* 20 seconds */ -const uint32_t FT_TM_DOWNLOAD_TIMEOUT = 10; /* 10 seconds */ -//const uint32_t FT_TM_CRC_MAP_MAX_WAIT_PER_GIG = 20; /* 20 seconds per gigabyte */ - -// const double FT_TM_MAX_INCREASE = 1.00; -// const double FT_TM_MIN_INCREASE = -0.10; +const uint32_t FT_TM_MINIMUM_CHUNK = 1024; /* ie 1Kb / sec */ +const uint32_t FT_TM_DEFAULT_TRANSFER_RATE = 20*1024; /* ie 20 Kb/sec */ +const uint32_t FT_TM_RESTART_DOWNLOAD = 20; /* 20 seconds */ +const uint32_t FT_TM_DOWNLOAD_TIMEOUT = 10; /* 10 seconds */ const double FT_TM_RATE_INCREASE_SLOWER = 0.05 ; const double FT_TM_RATE_INCREASE_AVERAGE = 0.3 ; const double FT_TM_RATE_INCREASE_FASTER = 1.0 ; -//const int32_t FT_TM_FAST_RTT = 1.0; -//const int32_t FT_TM_STD_RTT = 5.0; -//const int32_t FT_TM_SLOW_RTT = 20.0; - -//const uint32_t FT_TM_CRC_MAP_STATE_NOCHECK = 0 ; -//const uint32_t FT_TM_CRC_MAP_STATE_DONT_HAVE = 1 ; -//const uint32_t FT_TM_CRC_MAP_STATE_HAVE = 2 ; - #define FT_TM_FLAG_DOWNLOADING 0 #define FT_TM_FLAG_CANCELED 1 #define FT_TM_FLAG_COMPLETE 2 #define FT_TM_FLAG_CHECKING 3 #define FT_TM_FLAG_CHUNK_CRC 4 +peerInfo::peerInfo(const RsPeerId& peerId_in) + :peerId(peerId_in),state(PQIPEER_NOT_ONLINE),desiredRate(FT_TM_DEFAULT_TRANSFER_RATE),actualRate(FT_TM_DEFAULT_TRANSFER_RATE), + lastTS(0), + recvTS(0), lastTransfers(0), nResets(0), + rtt(0), rttActive(false), rttStart(0), rttOffset(0), + mRateIncrease(1) + { + } +// peerInfo(const RsPeerId& peerId_in,uint32_t state_in,uint32_t maxRate_in): +// peerId(peerId_in),state(state_in),desiredRate(maxRate_in),actualRate(0), +// lastTS(0), +// recvTS(0), lastTransfers(0), nResets(0), +// rtt(0), rttActive(false), rttStart(0), rttOffset(0), +// mRateIncrease(1) +// { +// return; +// } ftTransferModule::ftTransferModule(ftFileCreator *fc, ftDataMultiplex *dm, ftController *c) :mFileCreator(fc), mMultiplexor(dm), mFtController(c), tfMtx("ftTransferModule"), mFlag(FT_TM_FLAG_DOWNLOADING),mPriority(SPEED_NORMAL) { diff --git a/libretroshare/src/ft/fttransfermodule.h b/libretroshare/src/ft/fttransfermodule.h index eeb40c6e2..0dfaba013 100644 --- a/libretroshare/src/ft/fttransfermodule.h +++ b/libretroshare/src/ft/fttransfermodule.h @@ -54,39 +54,32 @@ class HashThread ; class peerInfo { public: - explicit peerInfo(const RsPeerId& peerId_in):peerId(peerId_in),state(PQIPEER_NOT_ONLINE),desiredRate(0),actualRate(0), - lastTS(0), - recvTS(0), lastTransfers(0), nResets(0), - rtt(0), rttActive(false), rttStart(0), rttOffset(0), - mRateIncrease(1) - { - return; - } - peerInfo(const RsPeerId& peerId_in,uint32_t state_in,uint32_t maxRate_in): - peerId(peerId_in),state(state_in),desiredRate(maxRate_in),actualRate(0), - lastTS(0), - recvTS(0), lastTransfers(0), nResets(0), - rtt(0), rttActive(false), rttStart(0), rttOffset(0), - mRateIncrease(1) - { - return; - } + explicit peerInfo(const RsPeerId& peerId_in); + +// peerInfo(const RsPeerId& peerId_in,uint32_t state_in,uint32_t maxRate_in): +// peerId(peerId_in),state(state_in),desiredRate(maxRate_in),actualRate(0), +// lastTS(0), +// recvTS(0), lastTransfers(0), nResets(0), +// rtt(0), rttActive(false), rttStart(0), rttOffset(0), +// mRateIncrease(1) +// { +// return; +// } RsPeerId peerId; uint32_t state; - double desiredRate; - double actualRate; + double desiredRate; /* speed at which the data should be requested */ + double actualRate; /* actual speed at which the data is received */ - rstime_t lastTS; /* last Request */ - rstime_t recvTS; /* last Recv */ - uint32_t lastTransfers; /* data recvd in last second */ - uint32_t nResets; /* count to disable non-existant files */ + rstime_t lastTS; /* last Request */ + rstime_t recvTS; /* last Recv */ + uint32_t lastTransfers; /* data recvd in last second */ + uint32_t nResets; /* count to disable non-existant files */ - /* rrt rate control */ - uint32_t rtt; /* last rtt */ - bool rttActive; /* have we initialised an rtt measurement */ - rstime_t rttStart; /* ts of request */ - uint64_t rttOffset; /* end of request */ - float mRateIncrease; /* current rate */ + uint32_t rtt; /* last rtt */ + bool rttActive; /* have we initialised an rtt measurement */ + rstime_t rttStart; /* ts of request */ + uint64_t rttOffset; /* end of request */ + float mRateIncrease; /* current rate increase factor */ }; class ftFileStatus