#include "../client.h" void command_netstats(Client *c, const Seperator *sep) { bool is_full = !strcasecmp(sep->arg[1], "full"); bool is_reset = !strcasecmp(sep->arg[1], "reset"); if (is_reset) { auto connection = c->Connection(); c->Message(Chat::White, "Resetting client stats (packet loss will not read correctly after reset)."); connection->ResetStats(); return; } auto connection = c->Connection(); auto opts = connection->GetManager()->GetOptions(); auto eqs_stats = connection->GetStats(); auto &stats = eqs_stats.DaybreakStats; auto now = EQ::Net::Clock::now(); auto sec_since_stats_reset = std::chrono::duration_cast>( now - stats.created ).count(); std::string popup_text = ""; popup_text += fmt::format( "", stats.sent_bytes, stats.sent_bytes / sec_since_stats_reset ); popup_text += fmt::format( "", stats.recv_bytes, stats.recv_bytes / sec_since_stats_reset ); popup_text += "

"; popup_text += fmt::format( "", stats.bytes_before_encode, static_cast(stats.bytes_before_encode - stats.sent_bytes) / static_cast(stats.bytes_before_encode) * 100.0 ); popup_text += fmt::format( "", stats.bytes_after_decode, static_cast(stats.bytes_after_decode - stats.recv_bytes) / static_cast(stats.bytes_after_decode) * 100.0 ); popup_text += "

"; popup_text += fmt::format("
", stats.min_ping); popup_text += fmt::format("", stats.max_ping); popup_text += fmt::format("", stats.last_ping); popup_text += fmt::format("", stats.avg_ping); popup_text += "

"; popup_text += fmt::format( "", stats.recv_packets, stats.recv_packets / sec_since_stats_reset ); popup_text += fmt::format( "", stats.sent_packets, stats.sent_packets / sec_since_stats_reset ); popup_text += "

"; popup_text += fmt::format("", stats.sync_recv_packets); popup_text += fmt::format("", stats.sync_sent_packets); popup_text += fmt::format("", stats.sync_remote_recv_packets); popup_text += fmt::format("", stats.sync_remote_sent_packets); popup_text += "

"; popup_text += fmt::format( "", (100.0 * (1.0 - static_cast(stats.sync_recv_packets) / static_cast(stats.sync_remote_sent_packets))) ); popup_text += fmt::format( "", (100.0 * (1.0 - static_cast(stats.sync_remote_recv_packets) / static_cast(stats.sync_sent_packets))) ); popup_text += "

"; popup_text += fmt::format( "
", stats.resent_packets, stats.resent_packets / sec_since_stats_reset ); popup_text += fmt::format( "", stats.resent_fragments, stats.resent_fragments / sec_since_stats_reset ); popup_text += fmt::format( "", stats.resent_full, stats.resent_full / sec_since_stats_reset ); popup_text += "

"; popup_text += fmt::format( "", stats.dropped_datarate_packets, stats.dropped_datarate_packets / sec_since_stats_reset ); if (opts.daybreak_options.outgoing_data_rate > 0.0) { popup_text += fmt::format( "", (100.0 * (1.0 - ((opts.daybreak_options.outgoing_data_rate - stats.datarate_remaining) / opts.daybreak_options.outgoing_data_rate))), opts.daybreak_options.outgoing_data_rate ); } if (is_full) { popup_text += "

"; popup_text += ""; for (auto i = 0; i < _maxEmuOpcode; ++i) { auto cnt = eqs_stats.SentCount[i]; if (cnt > 0) { popup_text += fmt::format( "", OpcodeNames[i], cnt, cnt / sec_since_stats_reset ); } } popup_text += "

"; popup_text += ""; for (auto i = 0; i < _maxEmuOpcode; ++i) { auto cnt = eqs_stats.RecvCount[i]; if (cnt > 0) { popup_text += fmt::format( "", OpcodeNames[i], cnt, cnt / sec_since_stats_reset ); } } } popup_text += "
Sent Bytes{} ({:.2f} Per Second)
Received Bytes{} ({:.2f} Per Second)
Bytes Before Encode (Sent){}Compression Rate{:.2f}%%
Bytes After Decode (Received){}Compression Rate{:.2f}%%
Min Ping{}
Max Ping{}
Last Ping{}
Average Ping{}
(Realtime) Received Packets{} ({:.2f} Per Second)
(Realtime) Sent Packets{} ({:.2f} Per Second)
(Sync) Received Packets{}
(Sync) Sent Packets{}
(Sync) Remote Received Packets{}
(Sync) Remote Sent Packets{}
Packet Loss In{:.2f}%%
Packet Loss Out{:.2f}%%
Resent Packets{} ({:.2f} Per Second)
Resent Fragments{} ({:.2f} Per Second)
Resent Non-Fragments{} ({:.2f} Per Second)
Dropped Datarate Packets{} ({:.2f} Per Second)
Outgoing Link Saturation{:.2f}%% ({:.2f}kb Per Second)
Sent Packet Types
{}{} ({:.2f} Per Second)
Received Packet Types
{}{} ({:.2f} Per Second)
"; c->SendPopupToClient( "Network Statistics", popup_text.c_str() ); }