From 7e4074938a48e5181efcabf27e5f5a6704521e90 Mon Sep 17 00:00:00 2001 From: Csaba Kiraly Date: Mon, 20 Mar 2023 14:33:35 +0100 Subject: [PATCH] add duplicate statistics Signed-off-by: Csaba Kiraly --- DAS/observer.py | 5 ++++- DAS/simulator.py | 6 +++--- DAS/validator.py | 6 +++++- 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/DAS/observer.py b/DAS/observer.py index 26b0632..6af4507 100644 --- a/DAS/observer.py +++ b/DAS/observer.py @@ -70,11 +70,14 @@ class Observer: def getTrafficStats(self, validators): statsTxInSlot = [v.statsTxInSlot for v in validators] statsRxInSlot = [v.statsRxInSlot for v in validators] + statsRxDupInSlot = [v.statsRxDupInSlot for v in validators] TX_prod = statsTxInSlot[0] RX_prod = statsRxInSlot[0] TX_avg = mean(statsTxInSlot[1:]) TX_max = max(statsTxInSlot[1:]) Rx_avg = mean(statsRxInSlot[1:]) Rx_max = max(statsRxInSlot[1:]) + RxDup_avg = mean(statsRxDupInSlot[1:]) + RxDup_max = max(statsRxDupInSlot[1:]) - return (TX_prod, RX_prod, TX_avg, TX_max, Rx_avg, Rx_max) + return (TX_prod, RX_prod, TX_avg, TX_max, Rx_avg, Rx_max, RxDup_avg, RxDup_max) diff --git a/DAS/simulator.py b/DAS/simulator.py index 82d9594..e860d17 100644 --- a/DAS/simulator.py +++ b/DAS/simulator.py @@ -188,9 +188,9 @@ class Simulator: self.validators[i].logColumns() # log TX and RX statistics - TX_prod, RX_prod, TX_avg, TX_max, Rx_avg, Rx_max = self.glob.getTrafficStats(self.validators) - self.logger.debug("step %d: TX_prod=%.1f, RX_prod=%.1f, TX_avg=%.1f, TX_max=%.1f, Rx_avg=%.1f, Rx_max=%.1f" % - (steps, TX_prod, RX_prod, TX_avg, TX_max, Rx_avg, Rx_max), extra=self.format) + TX_prod, RX_prod, TX_avg, TX_max, Rx_avg, Rx_max, RxDup_avg, RxDup_max = self.glob.getTrafficStats(self.validators) + self.logger.info("step %d: TX_prod=%.1f, RX_prod=%.1f, TX_avg=%.1f, TX_max=%.1f, Rx_avg=%.1f, Rx_max=%.1f, RxDup_avg=%.1f, RxDup_max=%.1f" % + (steps, TX_prod, RX_prod, TX_avg, TX_max, Rx_avg, Rx_max ,RxDup_avg, RxDup_max), extra=self.format) for i in range(0,self.shape.numberNodes): self.validators[i].updateStats() diff --git a/DAS/validator.py b/DAS/validator.py index 49165a0..cfa7fac 100644 --- a/DAS/validator.py +++ b/DAS/validator.py @@ -79,6 +79,8 @@ class Validator: self.statsTxPerSlot = [] self.statsRxInSlot = 0 self.statsRxPerSlot = [] + self.statsRxDupInSlot = 0 + self.statsRxDupPerSlot = [] # Set uplink bandwidth. In segments (~560 bytes) per timestep (50ms?) # 1 Mbps ~= 1e6 / 20 / 8 / 560 ~= 11 @@ -163,7 +165,7 @@ class Validator: self.receivedQueue.append((rID, cID)) else: self.logger.trace("Recv DUP: %d->%d: %d,%d", src, self.ID, rID, cID, extra=self.format) - # self.statsRxDuplicateInSlot += 1 + self.statsRxDupInSlot += 1 self.statsRxInSlot += 1 def addToSendQueue(self, rID, cID): @@ -205,8 +207,10 @@ class Validator: """It updates the stats related to sent and received data.""" self.logger.debug("Stats: tx %d, rx %d", self.statsTxInSlot, self.statsRxInSlot, extra=self.format) self.statsRxPerSlot.append(self.statsRxInSlot) + self.statsRxDupPerSlot.append(self.statsRxDupInSlot) self.statsTxPerSlot.append(self.statsTxInSlot) self.statsRxInSlot = 0 + self.statsRxDupInSlot = 0 self.statsTxInSlot = 0 def checkSegmentToNeigh(self, rID, cID, neigh):