From 3c0898c92524900f61cac344210553125dc03ae2 Mon Sep 17 00:00:00 2001 From: Csaba Kiraly Date: Sun, 9 Apr 2023 23:49:11 +0200 Subject: [PATCH 1/3] adding failureModes with special erasure patterns Signed-off-by: Csaba Kiraly --- DAS/shape.py | 4 +++- DAS/validator.py | 52 ++++++++++++++++++++++++++++++++++++++++++++---- smallConf.py | 9 ++++++--- 3 files changed, 57 insertions(+), 8 deletions(-) diff --git a/DAS/shape.py b/DAS/shape.py index d83351d..9f6d573 100644 --- a/DAS/shape.py +++ b/DAS/shape.py @@ -3,11 +3,12 @@ class Shape: """This class represents a set of parameters for a specific simulation.""" - def __init__(self, blockSize, numberNodes, failureRate, class1ratio, chi, vpn1, vpn2, netDegree, bwUplinkProd, bwUplink1, bwUplink2, run): + def __init__(self, blockSize, numberNodes, failureModel, failureRate, class1ratio, chi, vpn1, vpn2, netDegree, bwUplinkProd, bwUplink1, bwUplink2, run): """Initializes the shape with the parameters passed in argument.""" self.run = run self.numberNodes = numberNodes self.blockSize = blockSize + self.failureModel = failureModel self.failureRate = failureRate self.netDegree = netDegree self.class1ratio = class1ratio @@ -24,6 +25,7 @@ class Shape: shastr = "" shastr += "bs-"+str(self.blockSize) shastr += "-nn-"+str(self.numberNodes) + shastr += "-fm-"+str(self.failureModel) shastr += "-fr-"+str(self.failureRate) shastr += "-c1r-"+str(self.class1ratio) shastr += "-chi-"+str(self.chi) diff --git a/DAS/validator.py b/DAS/validator.py index bd7769e..0c37891 100644 --- a/DAS/validator.py +++ b/DAS/validator.py @@ -122,10 +122,54 @@ class Validator: self.logger.warning("I am not a block proposer", extra=self.format) else: self.logger.debug("Creating block...", extra=self.format) - order = [i for i in range(self.shape.blockSize * self.shape.blockSize)] - order = random.sample(order, int((1 - self.shape.failureRate/100) * len(order))) - for i in order: - self.block.data[i] = 1 + if self.shape.failureModel == "random": + order = [i for i in range(self.shape.blockSize * self.shape.blockSize)] + order = random.sample(order, int((1 - self.shape.failureRate/100) * len(order))) + for i in order: + self.block.data[i] = 1 + elif self.shape.failureModel == "sequential": + order = order[:int((1 - self.shape.failureRate/100) * len(order))] + for i in order: + self.block.data[i] = 1 + elif self.shape.failureModel == "MEP": # Minimal size non-recoverable Erasure Pattern + for r in range(self.shape.blockSize): + for c in range(self.shape.blockSize): + k = self.shape.blockSize/2 + if r > k or c > k: + self.block.setSegment(r,c) + elif self.shape.failureModel == "MEP+1": # MEP +1 segment to make it recoverable + for r in range(self.shape.blockSize): + for c in range(self.shape.blockSize): + k = self.shape.blockSize/2 + if r > k or c > k: + self.block.setSegment(r,c) + self.block.setSegment(0, 0) + elif self.shape.failureModel == "DEP": + for r in range(self.shape.blockSize): + for c in range(self.shape.blockSize): + k = self.shape.blockSize/2 + if (r+c) % self.shape.blockSize > k: + self.block.setSegment(r,c) + elif self.shape.failureModel == "DEP+1": + for r in range(self.shape.blockSize): + for c in range(self.shape.blockSize): + k = self.shape.blockSize/2 + if (r+c) % self.shape.blockSize > k: + self.block.setSegment(r,c) + self.block.setSegment(0, 0) + elif self.shape.failureModel == "MREP": # Minimum size Recoverable Erasure Pattern + for r in range(self.shape.blockSize): + for c in range(self.shape.blockSize): + k = self.shape.blockSize/2 + if r < k and c < k: + self.block.setSegment(r,c) + elif self.shape.failureModel == "MREP-1": # make MREP non-recoverable + for r in range(self.shape.blockSize): + for c in range(self.shape.blockSize): + k = self.shape.blockSize/2 + if r < k and c < k: + self.block.setSegment(r,c) + self.block.setSegment(0, 0, 0) nbFailures = self.block.data.count(0) measuredFailureRate = nbFailures * 100 / (self.shape.blockSize * self.shape.blockSize) diff --git a/smallConf.py b/smallConf.py index 782a2c0..042ca50 100644 --- a/smallConf.py +++ b/smallConf.py @@ -50,6 +50,9 @@ runs = range(3) # Number of validators numberNodes = range(128, 513, 128) +# select failure model between: "random, sequential, MEP, MEP+1, DEP, DEP+1, MREP, MREP-1" +failureModels = ["random"] + # Percentage of block not released by producer failureRates = range(40, 81, 20) @@ -97,9 +100,9 @@ diagnostics = False saveGit = False def nextShape(): - for run, fr, class1ratio, chi, vpn1, vpn2, blockSize, nn, netDegree, bwUplinkProd, bwUplink1, bwUplink2 in itertools.product( - runs, failureRates, class1ratios, chis, validatorsPerNode1, validatorsPerNode2, blockSizes, numberNodes, netDegrees, bwUplinksProd, bwUplinks1, bwUplinks2): + for run, fm, fr, class1ratio, chi, vpn1, vpn2, blockSize, nn, netDegree, bwUplinkProd, bwUplink1, bwUplink2 in itertools.product( + runs, failureModels, failureRates, class1ratios, chis, validatorsPerNode1, validatorsPerNode2, blockSizes, numberNodes, netDegrees, bwUplinksProd, bwUplinks1, bwUplinks2): # Network Degree has to be an even number if netDegree % 2 == 0: - shape = Shape(blockSize, nn, fr, class1ratio, chi, vpn1, vpn2, netDegree, bwUplinkProd, bwUplink1, bwUplink2, run) + shape = Shape(blockSize, nn, fm, fr, class1ratio, chi, vpn1, vpn2, netDegree, bwUplinkProd, bwUplink1, bwUplink2, run) yield shape From cec9b9f6a728865858d0aa6a36621da3794114e8 Mon Sep 17 00:00:00 2001 From: Csaba Kiraly Date: Wed, 12 Apr 2023 16:02:51 +0200 Subject: [PATCH 2/3] fixup: fix missing 'order' in failureModel == "sequential" Signed-off-by: Csaba Kiraly --- DAS/validator.py | 1 + 1 file changed, 1 insertion(+) diff --git a/DAS/validator.py b/DAS/validator.py index 0c37891..eab4977 100644 --- a/DAS/validator.py +++ b/DAS/validator.py @@ -128,6 +128,7 @@ class Validator: for i in order: self.block.data[i] = 1 elif self.shape.failureModel == "sequential": + order = [i for i in range(self.shape.blockSize * self.shape.blockSize)] order = order[:int((1 - self.shape.failureRate/100) * len(order))] for i in order: self.block.data[i] = 1 From 293914e1c365fc1433ec089bcc8ed68c4b72b1bf Mon Sep 17 00:00:00 2001 From: Csaba Kiraly Date: Tue, 18 Apr 2023 16:12:46 +0200 Subject: [PATCH 3/3] move initBlock code after network setup Signed-off-by: Csaba Kiraly --- DAS/simulator.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/DAS/simulator.py b/DAS/simulator.py index 0a3073e..1250558 100644 --- a/DAS/simulator.py +++ b/DAS/simulator.py @@ -91,10 +91,6 @@ class Simulator: else: val = Validator(i, int(not i!=0), self.logger, self.shape) - if i == self.proposerID: - val.initBlock() - else: - val.logIDs() self.validators.append(val) assignedRows.sort() @@ -219,6 +215,11 @@ class Simulator: def run(self): """It runs the main simulation until the block is available or it gets stucked.""" self.glob.checkRowsColumns(self.validators) + for i in range(0,self.shape.numberNodes): + if i == self.proposerID: + self.validators[i].initBlock() + else: + self.validators[i].logIDs() arrived, expected, ready, validatedall, validated = self.glob.checkStatus(self.validators) missingSamples = expected - arrived missingVector = []