netcode-revival: verbose game-traffic telemetry on the relay

With --verbose, the relay logs a windowed summary of forwarded game
datagrams ('game traffic: N datagram(s) relayed to M member(s) in room
'XXX'') so the game's own RakNet netcode is observable in the relay log -
distinct from ghost pose joins. Counted per 2s window to avoid per-packet
spam.
This commit is contained in:
MiTHRAL 2026-08-28 13:30:31 -04:00
parent dea4c3c5f4
commit 1d237a3a2c
2 changed files with 20 additions and 0 deletions

View file

@ -355,6 +355,7 @@ void GhostRelay::HandlePacket(const GhostAddr& from, const PacketBuf& p,
GamePayload* fwd = reinterpret_cast<GamePayload*>(out.payload);
fwd->src_virtual_ip = me->virtual_ip;
const uint16_t size = PacketSize(out);
uint32_t recipients = 0;
for (Client& c : clients_) {
if (&c == me || c.refused) {
continue;
@ -367,6 +368,20 @@ void GhostRelay::HandlePacket(const GhostAddr& from, const PacketBuf& p,
continue;
}
GhostSockSendTo(sock_, c.addr, &out, size);
++recipients;
}
// Verbose: a windowed summary of game datagrams relayed, so the game's
// own netcode traffic is visible in the log.
if (verbose_.load(std::memory_order_relaxed) && recipients != 0) {
++game_forwards_;
if (now - last_game_log_ >= 2.0 || game_forwards_ == 1) {
GHOST_RELAY_INFO("game traffic: {} datagram(s) relayed to {} "
"member(s) in room '{}'",
game_forwards_, recipients,
std::string(me->room, me->room_len));
last_game_log_ = now;
game_forwards_ = 0;
}
}
break;
}

View file

@ -84,6 +84,11 @@ class GhostRelay {
bool locked_ = false;
char locked_room_[kGhostMaxRoomLen] = {};
uint8_t locked_room_len_ = 0;
// Verbose game-traffic telemetry (netcode-revival): count forwarded game
// datagrams and log a windowed summary so the game's own RakNet traffic is
// observable without spamming the log per packet.
uint32_t game_forwards_ = 0;
double last_game_log_ = 0.0;
};
} // namespace skate3::native_ghost