void NodeList::pingPunchForInactiveNode(const SharedNodePointer& node) { if (node->getType() == NodeType::AudioMixer) { flagTimeForConnectionStep(LimitedNodeList::ConnectionStep::SendAudioPing); } // every second we're trying to ping this node and we're not getting anywhere - debug that out const int NUM_DEBUG_CONNECTION_ATTEMPTS = 1000 / (UDP_PUNCH_PING_INTERVAL_MS); if (node->getConnectionAttempts() > 0 && node->getConnectionAttempts() % NUM_DEBUG_CONNECTION_ATTEMPTS == 0) { qCDebug(networking) << "No response to UDP hole punch pings for node" << node->getUUID() << "in last second."; } // send the ping packet to the local and public sockets for this node auto localPingPacket = constructPingPacket(PingType::Local); sendPacket(std::move(localPingPacket), *node, node->getLocalSocket()); auto publicPingPacket = constructPingPacket(PingType::Public); sendPacket(std::move(publicPingPacket), *node, node->getPublicSocket()); if (!node->getSymmetricSocket().isNull()) { auto symmetricPingPacket = constructPingPacket(PingType::Symmetric); sendPacket(std::move(symmetricPingPacket), *node, node->getSymmetricSocket()); } node->incrementConnectionAttempts(); }
void NodeList::pingPunchForInactiveNode(const SharedNodePointer& node) { // send the ping packet to the local and public sockets for this node QByteArray localPingPacket = constructPingPacket(PingType::Local); writeDatagram(localPingPacket, node, node->getLocalSocket()); QByteArray publicPingPacket = constructPingPacket(PingType::Public); writeDatagram(publicPingPacket, node, node->getPublicSocket()); if (!node->getSymmetricSocket().isNull()) { QByteArray symmetricPingPacket = constructPingPacket(PingType::Symmetric); writeDatagram(symmetricPingPacket, node, node->getSymmetricSocket()); } }
void NodeList::sendKeepAlivePings() { eachMatchingNode([this](const SharedNodePointer& node)->bool { return _nodeTypesOfInterest.contains(node->getType()); }, [&](const SharedNodePointer& node) { sendPacket(constructPingPacket(), *node); }); }
void NodeList::handleICEConnectionToDomainServer() { if (_domainHandler.getICEPeer().isNull() || _domainHandler.getICEPeer().getConnectionAttempts() >= MAX_ICE_CONNECTION_ATTEMPTS) { _domainHandler.getICEPeer().resetConnectionAttemps(); LimitedNodeList::sendHeartbeatToIceServer(_domainHandler.getICEServerSockAddr(), _domainHandler.getICEClientID(), _domainHandler.getICEDomainID()); } else { qDebug() << "Sending ping packets to establish connectivity with domain-server with ID" << uuidStringWithoutCurlyBraces(_domainHandler.getICEDomainID()); // send the ping packet to the local and public sockets for this nodfe QByteArray localPingPacket = constructPingPacket(PingType::Local, false, _domainHandler.getICEClientID()); writeUnverifiedDatagram(localPingPacket, _domainHandler.getICEPeer().getLocalSocket()); QByteArray publicPingPacket = constructPingPacket(PingType::Public, false, _domainHandler.getICEClientID()); writeUnverifiedDatagram(publicPingPacket, _domainHandler.getICEPeer().getPublicSocket()); _domainHandler.getICEPeer().incrementConnectionAttempts(); } }
void Agent::sendPingRequests() { auto nodeList = DependencyManager::get<NodeList>(); nodeList->eachMatchingNode([](const SharedNodePointer& node)->bool { switch (node->getType()) { case NodeType::AvatarMixer: case NodeType::AudioMixer: case NodeType::EntityServer: return true; default: return false; } }, [nodeList](const SharedNodePointer& node) { nodeList->sendPacket(nodeList->constructPingPacket(), *node); }); }