Adjusted locking order of _paths_m for path pruning. Other minor multipath changes

This commit is contained in:
Joseph Henry 2018-05-02 15:24:14 -07:00
commit 91c8e82c42
4 changed files with 42 additions and 16 deletions

View file

@ -293,7 +293,7 @@
/**
* Number of samples to consider when computing path statistics
*/
#define ZT_PATH_QUALITY_METRIC_WIN_SZ 128
#define ZT_PATH_QUALITY_METRIC_WIN_SZ 64
/**
* How often important path metrics are sampled (in ms). These metrics are later used
@ -311,7 +311,7 @@
* since we will record a 0 bit/s measurement if no valid latency measurement was made within this
* window of time.
*/
#define ZT_PATH_LATENCY_SAMPLE_INTERVAL ZT_PING_CHECK_INVERVAL * 2
#define ZT_PATH_LATENCY_SAMPLE_INTERVAL ZT_MULTIPATH_PEER_PING_PERIOD * 2
/**
* Interval used for rate-limiting the computation of path quality estimates. Set at 0
@ -374,6 +374,13 @@
*/
#define ZT_PEER_PING_PERIOD 60000
/**
* Delay between full-fledge pings of directly connected peers.
* With multipath bonding enabled ping peers more often to measure
* packet loss and latency.
*/
#define ZT_MULTIPATH_PEER_PING_PERIOD 5000
/**
* Paths are considered expired if they have not sent us a real packet in this long
*/

View file

@ -432,6 +432,22 @@ public:
}
}
/**
* @param buf Buffer to store resultant string
* @return Description of path, in ASCII string format
*/
inline char *toString(char *buf) {
sprintf(buf,"%6s, q=%8.3f, %5.3f Mb/s, j=%8.2f, ml=%8.2f, meanAge=%8.2f, addr=%45s",
getName(),
lastComputedQuality(),
(float)meanThroughput() / (float)1000000,
jitter(),
meanLatency(),
meanAge(),
getAddressString());
return buf;
}
/**
* Record whether a packet is considered invalid by MAC/compression/cipher checks. This
* could be an indication of a bit error. This function will keep a running counter of

View file

@ -100,14 +100,17 @@ void Peer::received(
path->trustedPacketReceived(now);
}
if (RR->node->getMultipathMode() != ZT_MULTIPATH_NONE) {
if ((now - _lastPathPrune) > ZT_CLOSED_PATH_PRUNING_INTERVAL) {
_lastPathPrune = now;
prunePaths();
}
for(unsigned int i=0;i<ZT_MAX_PEER_NETWORK_PATHS;++i) {
if (_paths[i].p) {
_paths[i].p->measureLink(now);
{
Mutex::Lock _l(_paths_m);
if (RR->node->getMultipathMode() != ZT_MULTIPATH_NONE) {
if ((now - _lastPathPrune) > ZT_CLOSED_PATH_PRUNING_INTERVAL) {
_lastPathPrune = now;
prunePaths();
}
for(unsigned int i=0;i<ZT_MAX_PEER_NETWORK_PATHS;++i) {
if (_paths[i].p) {
_paths[i].p->measureLink(now);
}
}
}
}
@ -386,9 +389,9 @@ SharedPtr<Path> Peer::getAppropriatePath(int64_t now, bool includeExpired)
if (bestPath == ZT_MAX_PEER_NETWORK_PATHS || (numAlivePaths == 0 && numStalePaths == 0)) {
return SharedPtr<Path>();
} if (numAlivePaths == 1) {
return _paths[bestPath].p;
//return _paths[bestPath].p;
} if (numStalePaths == 1) {
return _paths[bestPath].p;
//return _paths[bestPath].p;
}
// Relative quality
@ -725,7 +728,6 @@ unsigned int Peer::doPingAndKeepalive(void *tPtr,int64_t now)
unsigned int Peer::prunePaths()
{
Mutex::Lock _l(_paths_m);
unsigned int pruned = 0;
for(unsigned int i=0;i<ZT_MAX_PEER_NETWORK_PATHS;++i) {
if (_paths[i].p) {