mirror of
https://github.com/zerotier/ZeroTierOne.git
synced 2025-02-20 09:46:13 +00:00
Improve output of bond list command
This commit is contained in:
parent
718039561e
commit
0797adf223
@ -1159,16 +1159,17 @@ void Bond::estimatePathQuality(int64_t now)
|
||||
// Compute/Smooth average of real-world observations
|
||||
_paths[i].latencyMean = _paths[i].latencySamples.mean();
|
||||
_paths[i].latencyVariance = _paths[i].latencySamples.stddev();
|
||||
//_paths[i].packetErrorRatio = 1.0 - (_paths[i].packetValiditySamples.count() ? _paths[i].packetValiditySamples.mean() : 1.0);
|
||||
|
||||
if (userHasSpecifiedLinkSpeeds()) {
|
||||
// Use user-reported metrics
|
||||
SharedPtr<Link> link = RR->bc->getLinkBySocket(_policyAlias, _paths[i].p->localSocket());
|
||||
if (link) {
|
||||
_paths[i].throughputMean = link->speed();
|
||||
_paths[i].throughputVariance = 0;
|
||||
}
|
||||
}
|
||||
// Write values to external path object so that it can be propagated to the user
|
||||
_paths[i].p->_latencyMean = _paths[i].latencyMean;
|
||||
_paths[i].p->_latencyVariance = _paths[i].latencyVariance;
|
||||
_paths[i].p->_packetLossRatio = _paths[i].packetLossRatio;
|
||||
_paths[i].p->_packetErrorRatio = _paths[i].packetErrorRatio;
|
||||
_paths[i].p->_bonded = _paths[i].bonded;
|
||||
_paths[i].p->_givenLinkSpeed = 0;//_paths[i].givenLinkSpeed;
|
||||
_paths[i].p->_allocation = _paths[i].allocation;
|
||||
|
||||
//_paths[i].packetErrorRatio = 1.0 - (_paths[i].packetValiditySamples.count() ? _paths[i].packetValiditySamples.mean() : 1.0);
|
||||
|
||||
// Drain unacknowledged QoS records
|
||||
int qosRecordTimeout = (_qosSendInterval * 3);
|
||||
@ -1184,7 +1185,7 @@ void Bond::estimatePathQuality(int64_t now)
|
||||
}
|
||||
}
|
||||
if (numDroppedQosOutRecords) {
|
||||
log("Dropped %d QOS out-records", numDroppedQosOutRecords);
|
||||
debug("Dropped %d QOS out-records", numDroppedQosOutRecords);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -1159,8 +1159,9 @@ class Bond {
|
||||
std::vector<SharedPtr<Path> > pp;
|
||||
Mutex::Lock _l(_paths_m);
|
||||
for (unsigned int i = 0; i < ZT_MAX_PEER_NETWORK_PATHS; ++i) {
|
||||
if (! _paths[i].p)
|
||||
break;
|
||||
if (! _paths[i].p) {
|
||||
continue;
|
||||
}
|
||||
pp.push_back(_paths[i].p);
|
||||
}
|
||||
return pp;
|
||||
@ -1258,9 +1259,6 @@ class Bond {
|
||||
, latencyVariance(0)
|
||||
, packetLossRatio(0)
|
||||
, packetErrorRatio(0)
|
||||
, throughputMean(0)
|
||||
, throughputMax(0)
|
||||
, throughputVariance(0)
|
||||
, allocation(0)
|
||||
, byteLoad(0)
|
||||
, relativeByteLoad(0)
|
||||
@ -1394,9 +1392,6 @@ class Bond {
|
||||
float latencyVariance; // Packet delay variance (computed from a sliding window.)
|
||||
float packetLossRatio; // The ratio of lost packets to received packets.
|
||||
float packetErrorRatio; // The ratio of packets that failed their MAC/CRC checks to those that did not.
|
||||
uint64_t throughputMean; // The estimated mean throughput of this path.
|
||||
uint64_t throughputMax; // The maximum observed throughput of this path.
|
||||
float throughputVariance; // The variance in the estimated throughput of this path.
|
||||
uint8_t allocation; // The relative quality of this path to all others in the bond, [0-255].
|
||||
uint64_t byteLoad; // How much load this path is under.
|
||||
uint8_t relativeByteLoad; // How much load this path is under (relative to other paths in the bond.)
|
||||
|
@ -280,6 +280,41 @@ public:
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Mean latency as reported by the bonding layer
|
||||
*/
|
||||
inline unsigned int latencyMean() const { return _latencyMean; }
|
||||
|
||||
/**
|
||||
* @return Latency variance as reported by the bonding layer
|
||||
*/
|
||||
inline unsigned int latencyVariance() const { return _latencyVariance; }
|
||||
|
||||
/**
|
||||
* @return Packet Loss Ratio as reported by the bonding layer
|
||||
*/
|
||||
inline unsigned int packetLossRatio() const { return _packetLossRatio; }
|
||||
|
||||
/**
|
||||
* @return Packet Error Ratio as reported by the bonding layer
|
||||
*/
|
||||
inline unsigned int packetErrorRatio() const { return _packetErrorRatio; }
|
||||
|
||||
/**
|
||||
* @return Whether this path is bonded as reported by the bonding layer
|
||||
*/
|
||||
inline unsigned int bonded() const { return _bonded; }
|
||||
|
||||
/**
|
||||
* @return Given link speed as reported by the bonding layer
|
||||
*/
|
||||
inline unsigned int givenLinkSpeed() const { return _givenLinkSpeed; }
|
||||
|
||||
/**
|
||||
* @return Traffic allocation as reported by the bonding layer
|
||||
*/
|
||||
inline unsigned int allocation() const { return _allocation; }
|
||||
|
||||
void *_bondingMetricPtr;
|
||||
|
||||
private:
|
||||
@ -288,9 +323,18 @@ private:
|
||||
volatile int64_t _lastIn;
|
||||
volatile int64_t _lastTrustEstablishedPacketReceived;
|
||||
|
||||
volatile float _latencyMean;
|
||||
volatile float _latencyVariance;
|
||||
volatile float _packetLossRatio;
|
||||
volatile float _packetErrorRatio;
|
||||
volatile bool _bonded;
|
||||
volatile int64_t _givenLinkSpeed;
|
||||
volatile int8_t _allocation;
|
||||
|
||||
int64_t _lastEchoRequestReceived;
|
||||
|
||||
int64_t _localSocket;
|
||||
|
||||
volatile unsigned int _latency;
|
||||
InetAddress _addr;
|
||||
InetAddress::IpScope _ipScope; // memoize this since it's a computed value checked often
|
||||
|
18
one.cpp
18
one.cpp
@ -613,9 +613,7 @@ static int cli(int argc,char **argv)
|
||||
int numTotalLinks = OSUtils::jsonInt(j["numTotalLinks"],0);
|
||||
printf("Peer : %s\n", arg1.c_str());
|
||||
printf("Bond : %s\n", OSUtils::jsonString(j["bondingPolicy"],"-").c_str());
|
||||
//if (bondingPolicy == ZT_BOND_POLICY_ACTIVE_BACKUP) {
|
||||
printf("Link Select Method : %d\n", (int)OSUtils::jsonInt(j["linkSelectMethod"],0));
|
||||
//}
|
||||
printf("Links : %d/%d\n", numAliveLinks, numTotalLinks);
|
||||
printf("Failover Interval : %d (ms)\n", (int)OSUtils::jsonInt(j["failoverInterval"],0));
|
||||
printf("Up Delay : %d (ms)\n", (int)OSUtils::jsonInt(j["upDelay"],0));
|
||||
@ -623,30 +621,32 @@ static int cli(int argc,char **argv)
|
||||
printf("Packets Per Link : %d (ms)\n", (int)OSUtils::jsonInt(j["packetsPerLink"],0));
|
||||
nlohmann::json &p = j["links"];
|
||||
if (p.is_array()) {
|
||||
printf("\n Interface Name\t\t\t\t\t Path\t Alive\n");
|
||||
printf("\n interface\t\t\t\t\t path\n");
|
||||
for(int i=0; i<80; i++) { printf("-"); }
|
||||
printf("\n");
|
||||
for (int i=0; i<p.size(); i++)
|
||||
{
|
||||
printf("[%d] %15s %45s %12d\n",
|
||||
printf("[%3d] %21s %50s\n",
|
||||
i,
|
||||
OSUtils::jsonString(p[i]["ifname"],"-").c_str(),
|
||||
OSUtils::jsonString(p[i]["path"],"-").c_str(),
|
||||
(int)OSUtils::jsonInt(p[i]["alive"],0));
|
||||
OSUtils::jsonString(p[i]["path"],"-").c_str()
|
||||
);
|
||||
}
|
||||
printf("\n Latency Jitter Loss Error Speed Alloc\n");
|
||||
printf("\n lat pdv plr per speed alloc alive bonded\n");
|
||||
for(int i=0; i<80; i++) { printf("-"); }
|
||||
printf("\n");
|
||||
for (int i=0; i<p.size(); i++)
|
||||
{
|
||||
printf("[%d] %5.3f %5.3f %5.3f %5.3f %8d %5d\n",
|
||||
printf("[%3d] %7.2f %7.2f %6.2f %6.2f %8d %9d %8d %8d\n",
|
||||
i,
|
||||
OSUtils::jsonDouble(p[i]["latencyMean"], 0),
|
||||
OSUtils::jsonDouble(p[i]["latencyVariance"], 0),
|
||||
OSUtils::jsonDouble(p[i]["packetLossRatio"], 0),
|
||||
OSUtils::jsonDouble(p[i]["packetErrorRatio"], 0),
|
||||
(int)OSUtils::jsonInt(p[i]["givenLinkSpeed"], 0),
|
||||
(int)OSUtils::jsonInt(p[i]["allocation"], 0));
|
||||
(int)OSUtils::jsonInt(p[i]["allocation"], 0),
|
||||
(int)OSUtils::jsonInt(p[i]["alive"],0),
|
||||
(int)OSUtils::jsonInt(p[i]["bonded"],0));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -597,16 +597,14 @@ static void _bondToJson(nlohmann::json &pj, SharedPtr<Bond> &bond)
|
||||
nlohmann::json j;
|
||||
j["ifname"] = bond->getLink(paths[i])->ifname();
|
||||
j["path"] = pathStr;
|
||||
/*
|
||||
j["alive"] = paths[i]->alive(now,true);
|
||||
j["bonded"] = paths[i]->bonded();
|
||||
j["latencyMean"] = paths[i]->latencyMean();
|
||||
j["latencyVariance"] = paths[i]->latencyVariance();
|
||||
j["packetLossRatio"] = paths[i]->packetLossRatio();
|
||||
j["packetErrorRatio"] = paths[i]->packetErrorRatio();
|
||||
j["givenLinkSpeed"] = 1000;
|
||||
j["alive"] = paths[i]->alive(now);
|
||||
j["bonded"] = paths[i]->bonded();
|
||||
j["givenLinkSpeed"] = paths[i]->givenLinkSpeed();
|
||||
j["allocation"] = paths[i]->allocation();
|
||||
*/
|
||||
pa.push_back(j);
|
||||
}
|
||||
pj["links"] = pa;
|
||||
|
Loading…
x
Reference in New Issue
Block a user