Improve output of bond list command

This commit is contained in:
Joseph Henry 2022-09-16 13:43:34 -07:00
parent 718039561e
commit 0797adf223
No known key found for this signature in database
GPG key ID: C45B33FF5EBC9344
5 changed files with 70 additions and 32 deletions

View file

@ -1159,16 +1159,17 @@ void Bond::estimatePathQuality(int64_t now)
// Compute/Smooth average of real-world observations // Compute/Smooth average of real-world observations
_paths[i].latencyMean = _paths[i].latencySamples.mean(); _paths[i].latencyMean = _paths[i].latencySamples.mean();
_paths[i].latencyVariance = _paths[i].latencySamples.stddev(); _paths[i].latencyVariance = _paths[i].latencySamples.stddev();
//_paths[i].packetErrorRatio = 1.0 - (_paths[i].packetValiditySamples.count() ? _paths[i].packetValiditySamples.mean() : 1.0);
if (userHasSpecifiedLinkSpeeds()) { // Write values to external path object so that it can be propagated to the user
// Use user-reported metrics _paths[i].p->_latencyMean = _paths[i].latencyMean;
SharedPtr<Link> link = RR->bc->getLinkBySocket(_policyAlias, _paths[i].p->localSocket()); _paths[i].p->_latencyVariance = _paths[i].latencyVariance;
if (link) { _paths[i].p->_packetLossRatio = _paths[i].packetLossRatio;
_paths[i].throughputMean = link->speed(); _paths[i].p->_packetErrorRatio = _paths[i].packetErrorRatio;
_paths[i].throughputVariance = 0; _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 // Drain unacknowledged QoS records
int qosRecordTimeout = (_qosSendInterval * 3); int qosRecordTimeout = (_qosSendInterval * 3);
@ -1184,7 +1185,7 @@ void Bond::estimatePathQuality(int64_t now)
} }
} }
if (numDroppedQosOutRecords) { if (numDroppedQosOutRecords) {
log("Dropped %d QOS out-records", numDroppedQosOutRecords); debug("Dropped %d QOS out-records", numDroppedQosOutRecords);
} }
/* /*

View file

@ -1159,8 +1159,9 @@ class Bond {
std::vector<SharedPtr<Path> > pp; std::vector<SharedPtr<Path> > pp;
Mutex::Lock _l(_paths_m); Mutex::Lock _l(_paths_m);
for (unsigned int i = 0; i < ZT_MAX_PEER_NETWORK_PATHS; ++i) { for (unsigned int i = 0; i < ZT_MAX_PEER_NETWORK_PATHS; ++i) {
if (! _paths[i].p) if (! _paths[i].p) {
break; continue;
}
pp.push_back(_paths[i].p); pp.push_back(_paths[i].p);
} }
return pp; return pp;
@ -1258,9 +1259,6 @@ class Bond {
, latencyVariance(0) , latencyVariance(0)
, packetLossRatio(0) , packetLossRatio(0)
, packetErrorRatio(0) , packetErrorRatio(0)
, throughputMean(0)
, throughputMax(0)
, throughputVariance(0)
, allocation(0) , allocation(0)
, byteLoad(0) , byteLoad(0)
, relativeByteLoad(0) , relativeByteLoad(0)
@ -1394,9 +1392,6 @@ class Bond {
float latencyVariance; // Packet delay variance (computed from a sliding window.) float latencyVariance; // Packet delay variance (computed from a sliding window.)
float packetLossRatio; // The ratio of lost packets to received packets. 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. 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]. 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. 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.) uint8_t relativeByteLoad; // How much load this path is under (relative to other paths in the bond.)

View file

@ -280,6 +280,41 @@ public:
return false; 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; void *_bondingMetricPtr;
private: private:
@ -288,9 +323,18 @@ private:
volatile int64_t _lastIn; volatile int64_t _lastIn;
volatile int64_t _lastTrustEstablishedPacketReceived; 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 _lastEchoRequestReceived;
int64_t _localSocket; int64_t _localSocket;
volatile unsigned int _latency; volatile unsigned int _latency;
InetAddress _addr; InetAddress _addr;
InetAddress::IpScope _ipScope; // memoize this since it's a computed value checked often InetAddress::IpScope _ipScope; // memoize this since it's a computed value checked often

18
one.cpp
View file

@ -613,9 +613,7 @@ static int cli(int argc,char **argv)
int numTotalLinks = OSUtils::jsonInt(j["numTotalLinks"],0); int numTotalLinks = OSUtils::jsonInt(j["numTotalLinks"],0);
printf("Peer : %s\n", arg1.c_str()); printf("Peer : %s\n", arg1.c_str());
printf("Bond : %s\n", OSUtils::jsonString(j["bondingPolicy"],"-").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("Link Select Method : %d\n", (int)OSUtils::jsonInt(j["linkSelectMethod"],0));
//}
printf("Links : %d/%d\n", numAliveLinks, numTotalLinks); printf("Links : %d/%d\n", numAliveLinks, numTotalLinks);
printf("Failover Interval : %d (ms)\n", (int)OSUtils::jsonInt(j["failoverInterval"],0)); printf("Failover Interval : %d (ms)\n", (int)OSUtils::jsonInt(j["failoverInterval"],0));
printf("Up Delay : %d (ms)\n", (int)OSUtils::jsonInt(j["upDelay"],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)); printf("Packets Per Link : %d (ms)\n", (int)OSUtils::jsonInt(j["packetsPerLink"],0));
nlohmann::json &p = j["links"]; nlohmann::json &p = j["links"];
if (p.is_array()) { 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("-"); } for(int i=0; i<80; i++) { printf("-"); }
printf("\n"); printf("\n");
for (int i=0; i<p.size(); i++) for (int i=0; i<p.size(); i++)
{ {
printf("[%d] %15s %45s %12d\n", printf("[%3d] %21s %50s\n",
i, i,
OSUtils::jsonString(p[i]["ifname"],"-").c_str(), OSUtils::jsonString(p[i]["ifname"],"-").c_str(),
OSUtils::jsonString(p[i]["path"],"-").c_str(), OSUtils::jsonString(p[i]["path"],"-").c_str()
(int)OSUtils::jsonInt(p[i]["alive"],0)); );
} }
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("-"); } for(int i=0; i<80; i++) { printf("-"); }
printf("\n"); printf("\n");
for (int i=0; i<p.size(); i++) 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, i,
OSUtils::jsonDouble(p[i]["latencyMean"], 0), OSUtils::jsonDouble(p[i]["latencyMean"], 0),
OSUtils::jsonDouble(p[i]["latencyVariance"], 0), OSUtils::jsonDouble(p[i]["latencyVariance"], 0),
OSUtils::jsonDouble(p[i]["packetLossRatio"], 0), OSUtils::jsonDouble(p[i]["packetLossRatio"], 0),
OSUtils::jsonDouble(p[i]["packetErrorRatio"], 0), OSUtils::jsonDouble(p[i]["packetErrorRatio"], 0),
(int)OSUtils::jsonInt(p[i]["givenLinkSpeed"], 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));
} }
} }
} }

View file

@ -597,16 +597,14 @@ static void _bondToJson(nlohmann::json &pj, SharedPtr<Bond> &bond)
nlohmann::json j; nlohmann::json j;
j["ifname"] = bond->getLink(paths[i])->ifname(); j["ifname"] = bond->getLink(paths[i])->ifname();
j["path"] = pathStr; j["path"] = pathStr;
/*
j["alive"] = paths[i]->alive(now,true);
j["bonded"] = paths[i]->bonded();
j["latencyMean"] = paths[i]->latencyMean(); j["latencyMean"] = paths[i]->latencyMean();
j["latencyVariance"] = paths[i]->latencyVariance(); j["latencyVariance"] = paths[i]->latencyVariance();
j["packetLossRatio"] = paths[i]->packetLossRatio(); j["packetLossRatio"] = paths[i]->packetLossRatio();
j["packetErrorRatio"] = paths[i]->packetErrorRatio(); 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(); j["allocation"] = paths[i]->allocation();
*/
pa.push_back(j); pa.push_back(j);
} }
pj["links"] = pa; pj["links"] = pa;