1
0
mirror of https://github.com/luanti-org/luanti.git synced 2025-10-31 23:45:22 +01:00

Improve some protocol code log messages

also get rid of the very noisy socket debug message that are
useless in a world where Wireshark exists.
This commit is contained in:
sfan5
2024-08-31 17:16:48 +02:00
parent f54f2c1601
commit 72c306d920
5 changed files with 26 additions and 86 deletions

View File

@@ -1009,7 +1009,13 @@ void UDPPeer::reportRTT(float rtt)
if (timeout > RESEND_TIMEOUT_MAX)
timeout = RESEND_TIMEOUT_MAX;
float timeout_old = getResendTimeout();
setResendTimeout(timeout);
if (std::abs(timeout - timeout_old) >= 0.001f) {
dout_con << m_connection->getDesc() << " set resend timeout " << timeout
<< " (rtt=" << rtt_stat << ") for peer id: " << id << std::endl;
}
}
bool UDPPeer::Ping(float dtime,SharedBuffer<u8>& data)
@@ -1129,7 +1135,7 @@ bool UDPPeer::processReliableSendCommand(
u16 packets_available = toadd.size();
/* we didn't get a single sequence number no need to fill queue */
if (!have_initial_sequence_number) {
LOG(derr_con << m_connection->getDesc() << "Ran out of sequence numbers!" << std::endl);
dout_con << m_connection->getDesc() << " No sequence numbers available!" << std::endl;
return false;
}

View File

@@ -35,7 +35,6 @@ namespace con
#define PROFILE(a)
#undef DEBUG_CONNECTION_KBPS
#else
/* this mutex is used to achieve log message consistency */
#define PROFILE(a) a
//#define DEBUG_CONNECTION_KBPS
#undef DEBUG_CONNECTION_KBPS
@@ -221,7 +220,8 @@ void ConnectionSendThread::runTimeouts(float dtime, u32 peer_packet_quota)
}
float resend_timeout = udpPeer->getResendTimeout();
for (Channel &channel : udpPeer->channels) {
for (int ch = 0; ch < CHANNEL_COUNT; ch++) {
auto &channel = udpPeer->channels[ch];
// Remove timed out incomplete unreliable split packets
channel.incoming_splits.removeUnreliableTimedOuts(dtime, peer_timeout);
@@ -242,8 +242,8 @@ void ConnectionSendThread::runTimeouts(float dtime, u32 peer_packet_quota)
if (!timed_outs.empty()) {
dout_con << m_connection->getDesc() <<
"Skipping re-send of " << timed_outs.size() <<
" timed-out reliables to peer_id " << udpPeer->id
<< " (half-open)." << std::endl;
" timed-out reliables to peer_id=" << udpPeer->id
<< " channel=" << ch << " (half-open)." << std::endl;
}
continue;
}
@@ -256,7 +256,14 @@ void ConnectionSendThread::runTimeouts(float dtime, u32 peer_packet_quota)
for (const auto &k : timed_outs)
resendReliable(channel, k.get(), resend_timeout);
auto ws_old = channel.getWindowSize();
channel.UpdateTimers(dtime);
auto ws_new = channel.getWindowSize();
if (ws_old != ws_new) {
dout_con << m_connection->getDesc() <<
"Window size adjusted to " << ws_new << " for peer_id="
<< udpPeer->id << " channel=" << ch << std::endl;
}
}
/* send ping if necessary */
@@ -309,12 +316,12 @@ void ConnectionSendThread::rawSend(const BufferedPacket *p)
assert(p);
try {
m_connection->m_udpSocket.Send(p->address, p->data, p->size());
LOG(dout_con << m_connection->getDesc()
<< " rawSend: " << p->size()
<< " bytes sent" << std::endl);
//LOG(dout_con << m_connection->getDesc()
// << " rawSend: " << p->size()
// << " bytes sent" << std::endl);
} catch (SendFailedException &e) {
LOG(derr_con << m_connection->getDesc()
<< "Connection::rawSend(): SendFailedException: "
<< "SendFailedException: " << e.what() << " to "
<< p->address.serializeString() << std::endl);
}
}
@@ -686,9 +693,9 @@ void ConnectionSendThread::sendPackets(float dtime, u32 peer_packet_quota)
PROFILE(ScopeProfiler
peerprofiler(g_profiler, peerIdentifier.str(), SPT_AVG));
LOG(dout_con << m_connection->getDesc()
<< " Handle per peer queues: peer_id=" << peerId
<< " packet quota: " << peer->m_increment_packets_remaining << std::endl);
//LOG(dout_con << m_connection->getDesc()
// << " Handle per peer queues: peer_id=" << peerId
// << " packet quota: " << peer->m_increment_packets_remaining << std::endl);
// first send queued reliable packets for all peers (if possible)
for (unsigned int i = 0; i < CHANNEL_COUNT; i++) {
@@ -1191,7 +1198,7 @@ SharedBuffer<u8> ConnectionReceiveThread::handlePacketType_Control(Channel *chan
// an overflow is quite unlikely but as it'd result in major
// rtt miscalculation we handle it here
if (current_time > p->absolute_send_time) {
float rtt = (current_time - p->absolute_send_time) / 1000.0;
float rtt = (current_time - p->absolute_send_time) / 1000.0f;
// Let peer calculate stuff according to it
// (avg_rtt and resend_timeout)
@@ -1336,12 +1343,6 @@ SharedBuffer<u8> ConnectionReceiveThread::handlePacketType_Reliable(Channel *cha
<< ", seqnum: " << seqnum << std::endl;)
m_connection->sendAck(peer->id, channelnum, seqnum);
// we already have this packet so this one was on wire at least
// the current timeout
// we don't know how long this packet was on wire don't do silly guessing
// dynamic_cast<UDPPeer*>(&peer)->
// reportRTT(dynamic_cast<UDPPeer*>(&peer)->getResendTimeout());
throw ProcessedSilentlyException("Retransmitting ack for old packet");
}
}