MCPcopy Create free account
hub / github.com/catboost/catboost / ProcessPingPacket

Method ProcessPingPacket

library/cpp/netliba/v12/udp_host.cpp:1391–1483  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1389 }
1390
1391 bool TUdpHost::ProcessPingPacket(const EUdpCmd cmd, const char* pktData, const char* pktEnd, const sockaddr_in6& fromAddress,
1392 TConnection* connection) {
1393 Y_ASSERT(IsPingCmd(cmd));
1394 Y_ASSERT(pktData <= pktEnd);
1395
1396 switch (cmd) {
1397 case XS_PING:
1398 case PING: {
1399 sockaddr_in6 trueFromAddress = fromAddress;
1400 Y_ASSERT(trueFromAddress.sin6_family == AF_INET6);
1401
1402 /*
1403 Cerr << GetAddressAsString(connection->GetAddress()) << " got ping " << int(cmd)
1404 << ", *conn=" << size_t(connection)
1405 << Endl;
1406 */
1407 // can not set MTU for fromAddress here since asymmetrical mtu is possible
1408 if (!ReadPing(pktData, pktEnd, &trueFromAddress.sin6_port)) {
1409 Y_ASSERT(false);
1410 return false;
1411 }
1412
1413 if (IB.Get()) {
1414 // For now just ignore XS pings over IB
1415 if (cmd == PING) {
1416 SendIBPong(S, connection, IB->GetConnectInfo(), trueFromAddress);
1417 }
1418 } else {
1419 if (cmd == XS_PING) {
1420 connection->SetSmallMtuUseXs(true);
1421 TPeerLink& peerInfo = connection->GetAlivePeerLink();
1422 auto congestion = peerInfo.GetUdpCongestion();
1423 if (congestion->GetMTU() == UDP_SMALL_PACKET_SIZE) {
1424 // Cerr << GetAddressAsString(connection->GetAddress()) << " dropping MTU to " << int(UDP_XSMALL_PACKET_SIZE) << Endl;
1425 congestion->SetMTU(UDP_XSMALL_PACKET_SIZE);
1426 }
1427 }
1428 SendPong(S, connection, trueFromAddress, cmd == XS_PING);
1429 }
1430 return true;
1431 }
1432 case XS_PONG: {
1433 /*
1434 Cerr << GetAddressAsString(connection->GetAddress()) << " got xs pong"
1435 << ", *conn=" << size_t(connection)
1436 << Endl;
1437 */
1438
1439 Connections.InsertToActive(connection);
1440 connection->SetSmallMtuUseXs(true);
1441 TPeerLink& peerInfo = connection->GetAlivePeerLink();
1442 auto congestion = peerInfo.GetUdpCongestion();
1443 if (congestion->GetMTU() == UDP_SMALL_PACKET_SIZE) {
1444 // Cerr << GetAddressAsString(connection->GetAddress()) << " dropping MTU to " << int(UDP_XSMALL_PACKET_SIZE) << Endl;
1445 congestion->SetMTU(UDP_XSMALL_PACKET_SIZE);
1446 }
1447
1448 return true;

Callers

nothing calls this directly

Calls 15

IsPingCmdFunction · 0.85
ReadPingFunction · 0.85
SendIBPongFunction · 0.85
SendPongFunction · 0.85
ReadIBPongFunction · 0.85
GetUdpCongestionMethod · 0.80
InsertToActiveMethod · 0.80
HasIBPeerMethod · 0.80
SetIBPeerMethod · 0.80
GetAddressMethod · 0.80
GetUdpAddressFunction · 0.70
GetMethod · 0.45

Tested by

no test coverage detected