mirror of
https://github.com/ZeroTier/ZeroTierOne
synced 2025-08-22 06:14:02 -07:00
Found more places for packet metrics
This commit is contained in:
parent
70d4710c99
commit
f8e4116582
9 changed files with 34 additions and 3 deletions
|
@ -857,6 +857,7 @@ void Bond::sendQOS_MEASUREMENT(void* tPtr, int pathIdx, int64_t localSocket, con
|
|||
else {
|
||||
RR->sw->send(tPtr, outp, false);
|
||||
}
|
||||
Metrics::pkt_qos_out++;
|
||||
_paths[pathIdx].packetsReceivedSinceLastQoS = 0;
|
||||
_paths[pathIdx].lastQoSMeasurement = now;
|
||||
_overheadBytes += outp.size();
|
||||
|
|
|
@ -366,6 +366,8 @@ bool IncomingPacket::_doHELLO(const RuntimeEnvironment *RR,void *tPtr,const bool
|
|||
outp.append((uint64_t)pid);
|
||||
outp.append((uint8_t)Packet::ERROR_IDENTITY_COLLISION);
|
||||
outp.armor(key,true,peer->aesKeysIfSupported());
|
||||
Metrics::pkt_error_out++;
|
||||
Metrics::pkt_error_identity_collision_out++;
|
||||
_path->send(RR,tPtr,outp.data(),outp.size(),RR->node->now());
|
||||
} else {
|
||||
RR->t->incomingPacketMessageAuthenticationFailure(tPtr,_path,pid,fromAddress,hops(),"invalid MAC");
|
||||
|
@ -517,6 +519,7 @@ bool IncomingPacket::_doHELLO(const RuntimeEnvironment *RR,void *tPtr,const bool
|
|||
|
||||
outp.armor(peer->key(),true,peer->aesKeysIfSupported());
|
||||
peer->recordOutgoingPacket(_path,outp.packetId(),outp.payloadLength(),outp.verb(),ZT_QOS_NO_FLOW,now);
|
||||
Metrics::pkt_ok_out++;
|
||||
_path->send(RR,tPtr,outp.data(),outp.size(),now);
|
||||
|
||||
peer->setRemoteVersion(protoVersion,vMajor,vMinor,vRevision); // important for this to go first so received() knows the version
|
||||
|
@ -668,7 +671,9 @@ bool IncomingPacket::_doWHOIS(const RuntimeEnvironment *RR,void *tPtr,const Shar
|
|||
}
|
||||
|
||||
if (count > 0) {
|
||||
Metrics::pkt_ok_out++;
|
||||
outp.armor(peer->key(),true,peer->aesKeysIfSupported());
|
||||
Metrics::pkt_ok_out++;
|
||||
_path->send(RR,tPtr,outp.data(),outp.size(),RR->node->now());
|
||||
}
|
||||
|
||||
|
@ -896,6 +901,7 @@ bool IncomingPacket::_doEXT_FRAME(const RuntimeEnvironment *RR,void *tPtr,const
|
|||
const int64_t now = RR->node->now();
|
||||
outp.armor(peer->key(),true,peer->aesKeysIfSupported());
|
||||
peer->recordOutgoingPacket(_path,outp.packetId(),outp.payloadLength(),outp.verb(),ZT_QOS_NO_FLOW,now);
|
||||
Metrics::pkt_ok_out++;
|
||||
_path->send(RR,tPtr,outp.data(),outp.size(),RR->node->now());
|
||||
}
|
||||
|
||||
|
@ -923,6 +929,7 @@ bool IncomingPacket::_doECHO(const RuntimeEnvironment *RR,void *tPtr,const Share
|
|||
outp.append(reinterpret_cast<const unsigned char *>(data()) + ZT_PACKET_IDX_PAYLOAD,size() - ZT_PACKET_IDX_PAYLOAD);
|
||||
outp.armor(peer->key(),true,peer->aesKeysIfSupported());
|
||||
peer->recordOutgoingPacket(_path,outp.packetId(),outp.payloadLength(),outp.verb(),ZT_QOS_NO_FLOW,now);
|
||||
Metrics::pkt_ok_out++;
|
||||
_path->send(RR,tPtr,outp.data(),outp.size(),RR->node->now());
|
||||
|
||||
peer->received(tPtr,_path,hops(),pid,payloadLength(),Packet::VERB_ECHO,0,Packet::VERB_NOP,false,0,ZT_QOS_NO_FLOW);
|
||||
|
@ -1100,6 +1107,8 @@ bool IncomingPacket::_doNETWORK_CONFIG_REQUEST(const RuntimeEnvironment *RR,void
|
|||
outp.append((unsigned char)Packet::ERROR_UNSUPPORTED_OPERATION);
|
||||
outp.append(nwid);
|
||||
outp.armor(peer->key(),true,peer->aesKeysIfSupported());
|
||||
Metrics::pkt_error_out++;
|
||||
Metrics::pkt_error_unsupported_op_out++;
|
||||
_path->send(RR,tPtr,outp.data(),outp.size(),RR->node->now());
|
||||
}
|
||||
|
||||
|
@ -1123,6 +1132,7 @@ bool IncomingPacket::_doNETWORK_CONFIG(const RuntimeEnvironment *RR,void *tPtr,c
|
|||
const int64_t now = RR->node->now();
|
||||
outp.armor(peer->key(),true,peer->aesKeysIfSupported());
|
||||
peer->recordOutgoingPacket(_path,outp.packetId(),outp.payloadLength(),outp.verb(),ZT_QOS_NO_FLOW,now);
|
||||
Metrics::pkt_ok_out++;
|
||||
_path->send(RR,tPtr,outp.data(),outp.size(),RR->node->now());
|
||||
}
|
||||
}
|
||||
|
@ -1164,6 +1174,7 @@ bool IncomingPacket::_doMULTICAST_GATHER(const RuntimeEnvironment *RR,void *tPtr
|
|||
if (gatheredLocally > 0) {
|
||||
outp.armor(peer->key(),true,peer->aesKeysIfSupported());
|
||||
peer->recordOutgoingPacket(_path,outp.packetId(),outp.payloadLength(),outp.verb(),ZT_QOS_NO_FLOW,now);
|
||||
Metrics::pkt_ok_out++;
|
||||
_path->send(RR,tPtr,outp.data(),outp.size(),now);
|
||||
}
|
||||
}
|
||||
|
@ -1264,6 +1275,7 @@ bool IncomingPacket::_doMULTICAST_FRAME(const RuntimeEnvironment *RR,void *tPtr,
|
|||
const int64_t now = RR->node->now();
|
||||
outp.armor(peer->key(),true,peer->aesKeysIfSupported());
|
||||
peer->recordOutgoingPacket(_path,outp.packetId(),outp.payloadLength(),outp.verb(),ZT_QOS_NO_FLOW,now);
|
||||
Metrics::pkt_ok_out++;
|
||||
_path->send(RR,tPtr,outp.data(),outp.size(),RR->node->now());
|
||||
}
|
||||
}
|
||||
|
@ -1406,6 +1418,8 @@ void IncomingPacket::_sendErrorNeedCredentials(const RuntimeEnvironment *RR,void
|
|||
outp.append((uint8_t)Packet::ERROR_NEED_MEMBERSHIP_CERTIFICATE);
|
||||
outp.append(nwid);
|
||||
outp.armor(peer->key(),true,peer->aesKeysIfSupported());
|
||||
Metrics::pkt_error_out++;
|
||||
Metrics::pkt_error_need_membership_cert_out++;
|
||||
_path->send(RR,tPtr,outp.data(),outp.size(),RR->node->now());
|
||||
}
|
||||
|
||||
|
|
|
@ -97,6 +97,7 @@ void Membership::pushCredentials(const RuntimeEnvironment *RR,void *tPtr,const i
|
|||
|
||||
outp.compress();
|
||||
RR->sw->send(tPtr,outp,true);
|
||||
Metrics::pkt_network_credentials_out++;
|
||||
}
|
||||
|
||||
_lastPushedCredentials = now;
|
||||
|
|
|
@ -11,6 +11,7 @@
|
|||
*/
|
||||
|
||||
#include <prometheus/simpleapi.h>
|
||||
#include <prometheus/histogram.h>
|
||||
|
||||
namespace prometheus {
|
||||
namespace simpleapi {
|
||||
|
|
|
@ -13,6 +13,7 @@
|
|||
#define METRICS_H_
|
||||
|
||||
#include <prometheus/simpleapi.h>
|
||||
#include <prometheus/histogram.h>
|
||||
|
||||
namespace prometheus {
|
||||
namespace simpleapi {
|
||||
|
@ -94,7 +95,6 @@ namespace ZeroTier {
|
|||
extern prometheus::simpleapi::counter_metric_t pkt_error_authentication_required_out;
|
||||
extern prometheus::simpleapi::counter_metric_t pkt_error_internal_server_error_out;
|
||||
|
||||
|
||||
// Data Sent/Received Metrics
|
||||
extern prometheus::simpleapi::counter_metric_t udp_send;
|
||||
extern prometheus::simpleapi::counter_metric_t udp_recv;
|
||||
|
|
|
@ -195,6 +195,7 @@ void Multicaster::send(
|
|||
outp.append(data,len);
|
||||
if (!network->config().disableCompression()) outp.compress();
|
||||
outp.armor(bestMulticastReplicator->key(),true,bestMulticastReplicator->aesKeysIfSupported());
|
||||
Metrics::pkt_multicast_frame_out++;
|
||||
bestMulticastReplicatorPath->send(RR,tPtr,outp.data(),outp.size(),now);
|
||||
return;
|
||||
}
|
||||
|
@ -321,6 +322,7 @@ void Multicaster::send(
|
|||
com->serialize(outp);
|
||||
RR->node->expectReplyTo(outp.packetId());
|
||||
RR->sw->send(tPtr,outp,true);
|
||||
Metrics::pkt_multicast_gather_out++;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -28,6 +28,11 @@ namespace ZeroTier {
|
|||
|
||||
static unsigned char s_freeRandomByteCounter = 0;
|
||||
|
||||
char * peerIDString(const Identity &id) {
|
||||
char out[16];
|
||||
return id.address().toString(out);
|
||||
}
|
||||
|
||||
Peer::Peer(const RuntimeEnvironment *renv,const Identity &myIdentity,const Identity &peerIdentity) :
|
||||
RR(renv),
|
||||
_lastReceive(0),
|
||||
|
@ -238,6 +243,7 @@ void Peer::received(
|
|||
outp->setAt(ZT_PACKET_IDX_PAYLOAD,(uint16_t)count);
|
||||
outp->compress();
|
||||
outp->armor(_key,true,aesKeysIfSupported());
|
||||
Metrics::pkt_push_direct_paths_out++;
|
||||
path->send(RR,tPtr,outp->data(),outp->size(),now);
|
||||
}
|
||||
delete outp;
|
||||
|
@ -377,6 +383,7 @@ void Peer::introduce(void *const tPtr,const int64_t now,const SharedPtr<Peer> &o
|
|||
outp.append(other->_paths[theirs].p->address().rawIpData(),4);
|
||||
}
|
||||
outp.armor(_key,true,aesKeysIfSupported());
|
||||
Metrics::pkt_rendezvous_out++;
|
||||
_paths[mine].p->send(RR,tPtr,outp.data(),outp.size(),now);
|
||||
} else {
|
||||
Packet outp(other->_id.address(),RR->identity.address(),Packet::VERB_RENDEZVOUS);
|
||||
|
@ -391,6 +398,7 @@ void Peer::introduce(void *const tPtr,const int64_t now,const SharedPtr<Peer> &o
|
|||
outp.append(_paths[mine].p->address().rawIpData(),4);
|
||||
}
|
||||
outp.armor(other->_key,true,other->aesKeysIfSupported());
|
||||
Metrics::pkt_rendezvous_out++;
|
||||
other->_paths[theirs].p->send(RR,tPtr,outp.data(),outp.size(),now);
|
||||
}
|
||||
++alt;
|
||||
|
@ -433,6 +441,7 @@ void Peer::sendHELLO(void *tPtr,const int64_t localSocket,const InetAddress &atA
|
|||
|
||||
if (atAddress) {
|
||||
outp.armor(_key,false,nullptr); // false == don't encrypt full payload, but add MAC
|
||||
Metrics::pkt_hello_out++;
|
||||
RR->node->expectReplyTo(outp.packetId());
|
||||
RR->node->putPacket(tPtr,RR->node->lowBandwidthModeEnabled() ? localSocket : -1,atAddress,outp.data(),outp.size());
|
||||
} else {
|
||||
|
@ -446,6 +455,7 @@ void Peer::attemptToContactAt(void *tPtr,const int64_t localSocket,const InetAdd
|
|||
if ( (!sendFullHello) && (_vProto >= 5) && (!((_vMajor == 1)&&(_vMinor == 1)&&(_vRevision == 0))) ) {
|
||||
Packet outp(_id.address(),RR->identity.address(),Packet::VERB_ECHO);
|
||||
outp.armor(_key,true,aesKeysIfSupported());
|
||||
Metrics::pkt_echo_out++;
|
||||
RR->node->expectReplyTo(outp.packetId());
|
||||
RR->node->putPacket(tPtr,localSocket,atAddress,outp.data(),outp.size());
|
||||
} else {
|
||||
|
|
|
@ -34,6 +34,7 @@
|
|||
#include "Mutex.hpp"
|
||||
#include "Bond.hpp"
|
||||
#include "AES.hpp"
|
||||
#include "Metrics.hpp"
|
||||
|
||||
#define ZT_PEER_MAX_SERIALIZED_STATE_SIZE (sizeof(Peer) + 32 + (sizeof(Path) * 2))
|
||||
|
||||
|
@ -50,7 +51,7 @@ class Peer
|
|||
friend class Bond;
|
||||
|
||||
private:
|
||||
Peer() {} // disabled to prevent bugs -- should not be constructed uninitialized
|
||||
Peer() = delete; // disabled to prevent bugs -- should not be constructed uninitialized
|
||||
|
||||
public:
|
||||
~Peer() {
|
||||
|
@ -314,7 +315,7 @@ public:
|
|||
} else {
|
||||
SharedPtr<Path> bp(getAppropriatePath(now,false));
|
||||
if (bp) {
|
||||
return bp->latency();
|
||||
return (unsigned int)bp->latency();
|
||||
}
|
||||
return 0xffff;
|
||||
}
|
||||
|
|
|
@ -98,6 +98,7 @@ void Switch::onRemotePacket(void *tPtr,const int64_t localSocket,const InetAddre
|
|||
_lastBeaconResponse = now;
|
||||
Packet outp(peer->address(),RR->identity.address(),Packet::VERB_NOP);
|
||||
outp.armor(peer->key(),true,peer->aesKeysIfSupported());
|
||||
Metrics::pkt_nop_out++;
|
||||
path->send(RR,tPtr,outp.data(),outp.size(),now);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue