From 608aad482073205a4fcc2df9d525cfc811c1cfe2 Mon Sep 17 00:00:00 2001 From: Simone Margaritelli Date: Thu, 24 Oct 2019 15:18:04 +0200 Subject: [PATCH] new: observing and reporting total number of peers met per each epoch --- pwnagotchi/ai/epoch.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/pwnagotchi/ai/epoch.py b/pwnagotchi/ai/epoch.py index 11c2b6d..8da6fec 100644 --- a/pwnagotchi/ai/epoch.py +++ b/pwnagotchi/ai/epoch.py @@ -37,6 +37,8 @@ class Epoch(object): self.num_hops = 0 # number of seconds sleeping self.num_slept = 0 + # number of peers seen during this epoch + self.num_peers = 0 # any activity at all during this epoch? self.any_activity = False # when the current epoch started @@ -74,10 +76,11 @@ class Epoch(object): else: self.blind_for = 0 + self.num_peers = len(peers) + num_aps = len(aps) + 1e-10 num_sta = sum(len(ap['clients']) for ap in aps) + 1e-10 - num_peers = len(peers) + 1e-10 - + num_peers = self.num_peers + 1e-10 # avoid division by 0 aps_per_chan = [0.0] * wifi.NumChannels sta_per_chan = [0.0] * wifi.NumChannels peers_per_chan = [0.0] * wifi.NumChannels @@ -162,6 +165,7 @@ class Epoch(object): 'active_for_epochs': self.active_for, 'missed_interactions': self.num_missed, 'num_hops': self.num_hops, + 'num_peers': self.num_peers, 'num_deauths': self.num_deauths, 'num_associations': self.num_assocs, 'num_handshakes': self.num_shakes, @@ -173,7 +177,7 @@ class Epoch(object): self._epoch_data['reward'] = self._reward(self.epoch + 1, self._epoch_data) self._epoch_data_ready.set() - logging.info("[epoch %d] duration=%s slept_for=%s blind=%d inactive=%d active=%d hops=%d missed=%d " + logging.info("[epoch %d] duration=%s slept_for=%s blind=%d inactive=%d active=%d peers=%d hops=%d missed=%d " "deauths=%d assocs=%d handshakes=%d cpu=%d%% mem=%d%% temperature=%dC reward=%s" % ( self.epoch, utils.secs_to_hhmmss(self.epoch_duration), @@ -181,6 +185,7 @@ class Epoch(object): self.blind_for, self.inactive_for, self.active_for, + self.num_peers, self.num_hops, self.num_missed, self.num_deauths, @@ -195,6 +200,7 @@ class Epoch(object): self.epoch_started = now self.did_deauth = False self.num_deauths = 0 + self.num_peers = 0 self.did_associate = False self.num_assocs = 0 self.num_missed = 0