mirror of
https://github.com/codex-storage/das-research.git
synced 2025-02-23 16:28:27 +00:00
Plots the min, max, avg percentage of samples recived by nodes
This commit is contained in:
parent
a7b82e848a
commit
5f1e007fbf
@ -86,6 +86,7 @@ class Simulator:
|
||||
assignedCols = []
|
||||
maliciousNodesCount = int((self.shape.maliciousNodes / 100) * self.shape.numberNodes)
|
||||
remainingMaliciousNodes = maliciousNodesCount
|
||||
expectedSamples = []
|
||||
|
||||
for i in range(self.shape.numberNodes):
|
||||
if i == 0:
|
||||
@ -139,12 +140,16 @@ class Simulator:
|
||||
for v in range(vpn):
|
||||
vs.append(initValidator(self.shape.nbRows, self.shape.custodyRows, self.shape.nbCols, self.shape.custodyCols))
|
||||
val = Node(i, int(not i!=0), nodeClass, amImalicious_value, self.logger, self.shape, self.config, vs)
|
||||
if i != 0:
|
||||
i_expectedSamples = len(val.columnIDs) * self.shape.nbRows + len(val.rowIDs) * self.shape.nbCols - len(val.columnIDs) * len(val.rowIDs)
|
||||
expectedSamples.append(i_expectedSamples)
|
||||
if i == self.proposerID:
|
||||
val.initBlock()
|
||||
else:
|
||||
val.logIDs()
|
||||
self.validators.append(val)
|
||||
|
||||
|
||||
self.result.addMetric("expectedSamples", expectedSamples)
|
||||
assignedRows.sort()
|
||||
assignedCols.sort()
|
||||
self.logger.debug("Rows assigned: %s" % str(assignedRows), extra=self.format)
|
||||
@ -282,12 +287,14 @@ class Simulator:
|
||||
trafficStatsVector = []
|
||||
malicious_nodes_not_added_count = 0
|
||||
steps = 0
|
||||
|
||||
samplesReceived = []
|
||||
|
||||
while(True):
|
||||
missingVector.append(missingSamples)
|
||||
self.logger.debug("Expected Samples: %d" % expected, extra=self.format)
|
||||
self.logger.debug("Missing Samples: %d" % missingSamples, extra=self.format)
|
||||
oldMissingSamples = missingSamples
|
||||
i_sampleReceived = []
|
||||
|
||||
self.logger.debug("PHASE SEND %d" % steps, extra=self.format)
|
||||
for i in range(0,self.shape.numberNodes):
|
||||
@ -301,6 +308,9 @@ class Simulator:
|
||||
self.logger.debug("PHASE RECEIVE %d" % steps, extra=self.format)
|
||||
for i in range(1,self.shape.numberNodes):
|
||||
self.validators[i].receiveRowsColumns()
|
||||
self.logger.debug("PHASE SAMPLE COUNT %d" % steps, extra=self.format)
|
||||
for i in range(1,self.shape.numberNodes):
|
||||
i_sampleReceived.append(self.validators[i].sampleRecvCount)
|
||||
self.logger.debug("PHASE RESTORE %d" % steps, extra=self.format)
|
||||
for i in range(1,self.shape.numberNodes):
|
||||
self.validators[i].restoreRows()
|
||||
@ -309,7 +319,10 @@ class Simulator:
|
||||
for i in range(0,self.shape.numberNodes):
|
||||
self.validators[i].logRows()
|
||||
self.validators[i].logColumns()
|
||||
|
||||
|
||||
# Store sample received count by each node in current step
|
||||
samplesReceived.append(i_sampleReceived)
|
||||
|
||||
# log TX and RX statistics
|
||||
trafficStats = self.glob.getTrafficStats(self.validators)
|
||||
self.logger.debug("step %d: %s" %
|
||||
@ -365,8 +378,10 @@ class Simulator:
|
||||
missingVector.append(missingSamples)
|
||||
break
|
||||
steps += 1
|
||||
|
||||
|
||||
|
||||
# Store sample received count by each node in each step
|
||||
self.result.addMetric("samplesReceived", samplesReceived)
|
||||
|
||||
for i in range(0,self.shape.numberNodes):
|
||||
if not self.validators[i].amIaddedToQueue :
|
||||
malicious_nodes_not_added_count += 1
|
||||
|
@ -149,6 +149,7 @@ class Visualizor:
|
||||
os.makedirs(plotPath, exist_ok=True)
|
||||
self.plotMissingSegments(result, plotPath)
|
||||
self.plotProgress(result, plotPath)
|
||||
self.plotSamplesReceived(result, plotPath)
|
||||
self.plotSentData(result, plotPath)
|
||||
self.plotRecvData(result, plotPath)
|
||||
self.plotDupData(result, plotPath)
|
||||
@ -1047,7 +1048,46 @@ class Visualizor:
|
||||
conf["data"] = [vector1, vector2, vector3]
|
||||
conf["xdots"] = [x*self.config.stepDuration for x in range(len(vector1))]
|
||||
conf["path"] = plotPath+"/nodesReady.png"
|
||||
conf["yaxismax"] = 1
|
||||
conf["yaxismax"] = 100
|
||||
plotData(conf)
|
||||
print("Plot %s created." % conf["path"])
|
||||
|
||||
def plotSamplesReceived(self, result, plotPath):
|
||||
"""Plots the min, max, avg percentage of samples recived by nodes"""
|
||||
samplesReceived = result.metrics["samplesReceived"]
|
||||
expectedSamples = result.metrics["expectedSamples"]
|
||||
vector1, vector2, vector3 = [], [], []
|
||||
for i in range(len(samplesReceived)):
|
||||
percentages = []
|
||||
for j in range(1, result.numberNodes):
|
||||
percentages.append(samplesReceived[i][j - 1] * 100 / expectedSamples[j - 1])
|
||||
vector1.append(max(percentages))
|
||||
vector2.append(min(percentages))
|
||||
vector3.append(sum(percentages) / len(percentages))
|
||||
conf = {}
|
||||
attrbs = self.__get_attrbs__(result)
|
||||
nodeTypes = self.__getNodeTypes__(attrbs['ntypes'])
|
||||
nodeTypesTxt = ""
|
||||
for _k, _v in nodeTypes.items():
|
||||
nodeTypesTxt += f"Type ({_k}): " + str(_v) + "\n"
|
||||
if nodeTypesTxt != "": nodeTypesTxt = nodeTypesTxt[: -1]
|
||||
conf["textBox"] = "Row Size (N, K): "+attrbs['bsrn']+ ", "+attrbs['bsrk']\
|
||||
+"\nColumn Size: (N, K): "+attrbs['bscn']+ ", "+attrbs['bsck']\
|
||||
+"\nNumber of nodes: "+attrbs['nn']+"\nFailure rate: "+attrbs['fr']+"%"+"\nMalicious Node: "+attrbs['mn']+"%"+"\nNetwork degree: "+attrbs['nd']\
|
||||
+"\nCustody Rows: "+attrbs['cusr']+" (Min: "+attrbs['mcusr']+")"+"\nCustody Cols: "+attrbs['cusc']+" (Min: "+attrbs['mcusc']+")"+"\n"+nodeTypesTxt\
|
||||
+"\nSegment Size: "+str(self.config.segmentSize)
|
||||
conf["title"] = "Percentages of Samples Received"
|
||||
conf["type"] = "plot"
|
||||
conf["legLoc"] = 2
|
||||
conf["desLoc"] = 2
|
||||
conf["colors"] = ["g-", "b-", "r-"]
|
||||
conf["labels"] = ["Max", "Min", "Average"]
|
||||
conf["xlabel"] = "Time (ms)"
|
||||
conf["ylabel"] = "Percentage (%)"
|
||||
conf["data"] = [vector1, vector2, vector3]
|
||||
conf["xdots"] = [x*self.config.stepDuration for x in range(len(vector1))]
|
||||
conf["path"] = plotPath+"/samplesReceivedPercentages.png"
|
||||
conf["yaxismax"] = 100
|
||||
plotData(conf)
|
||||
print("Plot %s created." % conf["path"])
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user