From c60a83f7f487b682aeaf35da4d301289ae8a94be Mon Sep 17 00:00:00 2001 From: Jeff Becker Date: Fri, 7 Feb 2020 12:25:42 -0500 Subject: [PATCH 1/4] update lokinet monitor to work with iwp --- contrib/py/admin/lokinetmon | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/contrib/py/admin/lokinetmon b/contrib/py/admin/lokinetmon index 1c4258101..26cc3f330 100755 --- a/contrib/py/admin/lokinetmon +++ b/contrib/py/admin/lokinetmon @@ -94,12 +94,12 @@ class Monitor: self.win.addstr("paths: {}".format(len(paths))) for path in paths: y = self._render_path(y, path, "inbound") - for session in status["remoteSessions"]: + for session in (status["remoteSessions"] or []): for path in session["paths"]: y = self._render_path( y, path, "[active] {}".format(session["currentConvoTag"]) ) - for session in status["snodeSessions"]: + for session in (status["snodeSessions"] or []): for path in session["paths"]: y = self._render_path(y, path, "[snode]") return y @@ -201,8 +201,6 @@ class Monitor: s["remoteAddr"], self.speedOf(s["tx"]), self.speedOf(s["rx"]) ) ) - if s["sendBacklog"] > 0: - self.win.addstr("[backlog {}]".format(s["sendBacklog"])) return y def display_dht(self, y, data): From fa15ab567dc9909b5e2f80d82b798fafde256f43 Mon Sep 17 00:00:00 2001 From: Jeff Becker Date: Sat, 8 Feb 2020 11:21:00 -0500 Subject: [PATCH 2/4] update lokinetmon --- contrib/py/admin/lokinetmon | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/contrib/py/admin/lokinetmon b/contrib/py/admin/lokinetmon index 26cc3f330..d81ede68b 100755 --- a/contrib/py/admin/lokinetmon +++ b/contrib/py/admin/lokinetmon @@ -54,6 +54,9 @@ class Monitor: y += 1 self.win.move(y, 1) y += 1 + self.win.addstr("[tx:\t{}]\t[rx:\t{}]".format(self.speedOf(path['tx']), self.speedOf(path['rx']))) + self.win.move(y, 1) + y += 1 self.win.addstr("me -> ") for hop in path["hops"]: self.win.addstr(" {} ->".format(hop["router"][:4])) @@ -201,6 +204,10 @@ class Monitor: s["remoteAddr"], self.speedOf(s["tx"]), self.speedOf(s["rx"]) ) ) + if (s['txMsgs'] or 0) > 1: + self.win.addstr(" [out window:\t{}]".format(s['txMsgs'])) + if (s['rxMsgs'] or 0) > 1: + self.win.addstr(" [in window:\t{}]".format(s['rxMsgs'])) return y def display_dht(self, y, data): From e8b84fcfbdbe7592549a24f6b46bfc2bbd9e584f Mon Sep 17 00:00:00 2001 From: Jeff Becker Date: Sat, 8 Feb 2020 11:21:18 -0500 Subject: [PATCH 3/4] add path speed metrics for lokinetmon --- llarp/path/path.cpp | 17 ++++++++++++++++- llarp/path/path.hpp | 4 ++++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/llarp/path/path.cpp b/llarp/path/path.cpp index 21eeed3dc..4082df1e1 100644 --- a/llarp/path/path.cpp +++ b/llarp/path/path.cpp @@ -103,6 +103,8 @@ namespace llarp bool Path::IsReady() const { + if(Expired(llarp::time_now_ms())) + return false; return intro.latency > 0 && _status == ePathEstablished; } @@ -307,6 +309,8 @@ namespace llarp {"expiresSoon", ExpiresSoon(now)}, {"expiresAt", ExpireTime()}, {"ready", IsReady()}, + {"tx", m_LastTXRate}, + {"rx", m_LastRXRate}, {"hasExit", SupportsAnyRoles(ePathRoleExit)}}; std::vector< util::StatusObject > hopsObj; @@ -359,6 +363,12 @@ namespace llarp if(Expired(now)) return; + m_LastRXRate = m_RXRate; + m_LastTXRate = m_TXRate; + + m_RXRate = 0; + m_TXRate = 0; + m_UpstreamReplayFilter.Decay(now); m_DownstreamReplayFilter.Decay(now); @@ -420,7 +430,11 @@ namespace llarp { for(const auto& msg : msgs) { - if(!r->SendToOrQueue(Upstream(), &msg)) + if(r->SendToOrQueue(Upstream(), &msg)) + { + m_TXRate += msg.X.size(); + } + else { LogDebug("failed to send upstream to ", Upstream()); } @@ -531,6 +545,7 @@ namespace llarp for(const auto& msg : msgs) { const llarp_buffer_t buf(msg.X); + m_RXRate += buf.sz; if(!HandleRoutingMessage(buf, r)) { LogWarn("failed to handle downstream message"); diff --git a/llarp/path/path.hpp b/llarp/path/path.hpp index ed60b4c22..ae3bcad98 100644 --- a/llarp/path/path.hpp +++ b/llarp/path/path.hpp @@ -405,6 +405,10 @@ namespace llarp PathRole _role; util::DecayingHashSet< TunnelNonce > m_UpstreamReplayFilter; util::DecayingHashSet< TunnelNonce > m_DownstreamReplayFilter; + uint64_t m_LastRXRate = 0; + uint64_t m_RXRate = 0; + uint64_t m_LastTXRate = 0; + uint64_t m_TXRate = 0; }; } // namespace path } // namespace llarp From 7374f8f0fdd40739676b14ec2f13bf89a8b3f40e Mon Sep 17 00:00:00 2001 From: Jeff Becker Date: Tue, 11 Feb 2020 10:36:18 -0500 Subject: [PATCH 4/4] update lokinetmon --- contrib/py/admin/lokinetmon | 12 ++++++------ llarp/path/path.cpp | 4 ++-- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/contrib/py/admin/lokinetmon b/contrib/py/admin/lokinetmon index d81ede68b..79159d2f5 100755 --- a/contrib/py/admin/lokinetmon +++ b/contrib/py/admin/lokinetmon @@ -54,7 +54,7 @@ class Monitor: y += 1 self.win.move(y, 1) y += 1 - self.win.addstr("[tx:\t{}]\t[rx:\t{}]".format(self.speedOf(path['tx']), self.speedOf(path['rx']))) + self.win.addstr("[tx:\t{}]\t[rx:\t{}]".format(self.speedOf(path['txRateCurrent']), self.speedOf(path['rxRateCurrent']))) self.win.move(y, 1) y += 1 self.win.addstr("me -> ") @@ -197,17 +197,17 @@ class Monitor: for s in sessions: y += 1 self.win.move(y, 1) - self.txrate += s["tx"] - self.rxrate += s["rx"] + self.txrate += s["txRateCurrent"] + self.rxrate += s["rxRateCurrent"] self.win.addstr( "{}\t[{}\ttx]\t[{}\trx]".format( - s["remoteAddr"], self.speedOf(s["tx"]), self.speedOf(s["rx"]) + s["remoteAddr"], self.speedOf(s["txRateCurrent"]), self.speedOf(s["rxRateCurrent"]) ) ) if (s['txMsgs'] or 0) > 1: - self.win.addstr(" [out window:\t{}]".format(s['txMsgs'])) + self.win.addstr(" [out window:\t{}]".format(s['txMsgQueueSize'])) if (s['rxMsgs'] or 0) > 1: - self.win.addstr(" [in window:\t{}]".format(s['rxMsgs'])) + self.win.addstr(" [in window:\t{}]".format(s['rxMsgQueueSize'])) return y def display_dht(self, y, data): diff --git a/llarp/path/path.cpp b/llarp/path/path.cpp index 4082df1e1..d76e8bfc7 100644 --- a/llarp/path/path.cpp +++ b/llarp/path/path.cpp @@ -309,8 +309,8 @@ namespace llarp {"expiresSoon", ExpiresSoon(now)}, {"expiresAt", ExpireTime()}, {"ready", IsReady()}, - {"tx", m_LastTXRate}, - {"rx", m_LastRXRate}, + {"txRateCurrent", m_LastTXRate}, + {"rxRateCurrent", m_LastRXRate}, {"hasExit", SupportsAnyRoles(ePathRoleExit)}}; std::vector< util::StatusObject > hopsObj;