Added call to computeAggregateAllocation() in multipath mode=1 to give realtime allocation output

This commit is contained in:
Joseph Henry 2019-08-12 17:04:27 -07:00
parent 77ae929eb3
commit 3c7e25ed58
2 changed files with 12 additions and 4 deletions

View File

@ -275,7 +275,7 @@ void Peer::recordIncomingPacket(void *tPtr, const SharedPtr<Path> &path, const u
} }
} }
void Peer::computeAggregateProportionalAllocation(int64_t now) void Peer::computeAggregateAllocation(int64_t now)
{ {
float maxStability = 0; float maxStability = 0;
float totalRelativeQuality = 0; float totalRelativeQuality = 0;
@ -318,10 +318,16 @@ void Peer::computeAggregateProportionalAllocation(int64_t now)
// Convert set of relative performances into an allocation set // Convert set of relative performances into an allocation set
for(uint16_t i=0;i<ZT_MAX_PEER_NETWORK_PATHS;++i) { for(uint16_t i=0;i<ZT_MAX_PEER_NETWORK_PATHS;++i) {
if (_paths[i].p) { if (_paths[i].p) {
if (RR->node->getMultipathMode() == ZT_MULTIPATH_RANDOM) {
_paths[i].p->updateComponentAllocationOfAggregateLink(((float)_pathChoiceHist.countValue(i) / (float)_pathChoiceHist.count()) * 255);
}
if (RR->node->getMultipathMode() == ZT_MULTIPATH_PROPORTIONALLY_BALANCED) {
_paths[i].p->updateComponentAllocationOfAggregateLink((unsigned char)((_paths[i].p->relativeQuality() / totalRelativeQuality) * 255)); _paths[i].p->updateComponentAllocationOfAggregateLink((unsigned char)((_paths[i].p->relativeQuality() / totalRelativeQuality) * 255));
} }
} }
} }
}
int Peer::computeAggregateLinkPacketDelayVariance() int Peer::computeAggregateLinkPacketDelayVariance()
{ {
@ -415,6 +421,7 @@ SharedPtr<Path> Peer::getAppropriatePath(int64_t now, bool includeExpired)
int numAlivePaths = 0; int numAlivePaths = 0;
int numStalePaths = 0; int numStalePaths = 0;
if (RR->node->getMultipathMode() == ZT_MULTIPATH_RANDOM) { if (RR->node->getMultipathMode() == ZT_MULTIPATH_RANDOM) {
computeAggregateAllocation(now); /* This call is algorithmically inert but gives us a value to show in the status output */
int alivePaths[ZT_MAX_PEER_NETWORK_PATHS]; int alivePaths[ZT_MAX_PEER_NETWORK_PATHS];
int stalePaths[ZT_MAX_PEER_NETWORK_PATHS]; int stalePaths[ZT_MAX_PEER_NETWORK_PATHS];
memset(&alivePaths, -1, sizeof(alivePaths)); memset(&alivePaths, -1, sizeof(alivePaths));
@ -434,6 +441,7 @@ SharedPtr<Path> Peer::getAppropriatePath(int64_t now, bool includeExpired)
unsigned int r = _freeRandomByte; unsigned int r = _freeRandomByte;
if (numAlivePaths > 0) { if (numAlivePaths > 0) {
int rf = r % numAlivePaths; int rf = r % numAlivePaths;
_pathChoiceHist.push(alivePaths[rf]); // Record which path we chose
return _paths[alivePaths[rf]].p; return _paths[alivePaths[rf]].p;
} }
else if(numStalePaths > 0) { else if(numStalePaths > 0) {
@ -449,7 +457,7 @@ SharedPtr<Path> Peer::getAppropriatePath(int64_t now, bool includeExpired)
if (RR->node->getMultipathMode() == ZT_MULTIPATH_PROPORTIONALLY_BALANCED) { if (RR->node->getMultipathMode() == ZT_MULTIPATH_PROPORTIONALLY_BALANCED) {
if ((now - _lastAggregateAllocation) >= ZT_PATH_QUALITY_COMPUTE_INTERVAL) { if ((now - _lastAggregateAllocation) >= ZT_PATH_QUALITY_COMPUTE_INTERVAL) {
_lastAggregateAllocation = now; _lastAggregateAllocation = now;
computeAggregateProportionalAllocation(now); computeAggregateAllocation(now);
} }
// Randomly choose path according to their allocations // Randomly choose path according to their allocations
float rf = _freeRandomByte; float rf = _freeRandomByte;

View File

@ -194,7 +194,7 @@ public:
* *
* @param now Current time * @param now Current time
*/ */
void computeAggregateProportionalAllocation(int64_t now); void computeAggregateAllocation(int64_t now);
/** /**
* @return The aggregate link Packet Delay Variance (PDV) * @return The aggregate link Packet Delay Variance (PDV)