From d97b323674ab36b2aa171cf97e328090650dd102 Mon Sep 17 00:00:00 2001 From: Csaba Kiraly Date: Wed, 12 Apr 2023 18:28:03 +0200 Subject: [PATCH] configure bandwidth in mbps Signed-off-by: Csaba Kiraly --- DAS/simulator.py | 4 ++-- DAS/validator.py | 9 +++++---- config_example.py | 9 ++++----- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/DAS/simulator.py b/DAS/simulator.py index 07d3555..90fdf95 100644 --- a/DAS/simulator.py +++ b/DAS/simulator.py @@ -66,9 +66,9 @@ class Simulator: end = offset+((j+1)*self.shape.chi) r = set(rows[start:end]) c = set(columns[start:end]) - val = Validator(i, int(not i!=0), self.logger, self.shape, r, c) + val = Validator(i, int(not i!=0), self.logger, self.shape, self.config, r, c) else: - val = Validator(i, int(not i!=0), self.logger, self.shape) + val = Validator(i, int(not i!=0), self.logger, self.shape, self.config) if i == self.proposerID: val.initBlock() else: diff --git a/DAS/validator.py b/DAS/validator.py index b8d04c4..09b93fa 100644 --- a/DAS/validator.py +++ b/DAS/validator.py @@ -38,7 +38,7 @@ class Validator: """It returns the validator ID.""" return str(self.ID) - def __init__(self, ID, amIproposer, logger, shape, rows = None, columns = None): + def __init__(self, ID, amIproposer, logger, shape, config, rows = None, columns = None): """It initializes the validator with the logger shape and rows/columns. If rows/columns are specified these are observed, otherwise (default) @@ -87,15 +87,16 @@ class Validator: self.statsRxDupInSlot = 0 self.statsRxDupPerSlot = [] - # Set uplink bandwidth. In segments (~560 bytes) per timestep (50ms?) - # 1 Mbps ~= 1e6 / 20 / 8 / 560 ~= 11 - # TODO: this should be a parameter + # Set uplink bandwidth. + # Assuming segments of ~560 bytes and timesteps of 50ms, we get + # 1 Mbps ~= 1e6 mbps * 0.050 s / (560*8) bits ~= 11 segments/timestep if self.amIproposer: self.bwUplink = shape.bwUplinkProd elif self.nodeClass == 1: self.bwUplink = shape.bwUplink1 else: self.bwUplink = shape.bwUplink2 + self.bwUplink *= 1e3 / 8 * config.stepDuration / config.segmentSize self.repairOnTheFly = True self.sendLineUntil = (self.shape.blockSize + 1) // 2 # stop sending on a p2p link if at least this amount of samples passed diff --git a/config_example.py b/config_example.py index 658ba54..b0b8496 100644 --- a/config_example.py +++ b/config_example.py @@ -65,11 +65,10 @@ class1ratios = [0.8, 0.9] validatorsPerNode1 = [1] validatorsPerNode2 = [500] -# Set uplink bandwidth. In segments (~560 bytes) per timestep (50ms?) -# 1 Mbps ~= 1e6 / 20 / 8 / 560 ~= 11 -bwUplinksProd = [2200] -bwUplinks1 = [110] -bwUplinks2 = [2200] +# Set uplink bandwidth in megabits/second +bwUplinksProd = [200] +bwUplinks1 = [10] +bwUplinks2 = [200] # Step duration in miliseconds (Classic RTT is about 100ms) stepDuration = 50