WIP: minimal sample generation and check

This is early WIP, it only checks if neighbors would be able to
provide all the samples needed by nodes.

Signed-off-by: Csaba Kiraly <csaba.kiraly@gmail.com>
This commit is contained in:
Csaba Kiraly 2024-02-20 12:39:04 +01:00
parent bb6f3e80b4
commit f8d5bfbb30
No known key found for this signature in database
GPG Key ID: 0FE274EE8C95166E
2 changed files with 31 additions and 0 deletions

View File

@ -115,6 +115,7 @@ class Node:
self.bwUplink = shape.bwUplink2
self.bwUplink *= 1e3 / 8 * config.stepDuration / config.segmentSize
self.DASampleSize = 10 # TODO make this an external parameter
self.repairOnTheFly = True
self.sendLineUntilR = self.shape.blockSizeRK # stop sending on a p2p link if at least this amount of samples passed
self.sendLineUntilC = self.shape.blockSizeCK # stop sending on a p2p link if at least this amount of samples passed
@ -159,6 +160,32 @@ class Node:
if symmetric:
peer.columnNeighbors[lineID].update({self.ID : p})
def getNeighbors(self):
"""Collect all neighbors (WIP, to be cached)"""
nn = set()
for neighs in self.rowNeighbors.values():
for n in neighs.values():
nn.add(n.peer.node)
for neighs in self.columnNeighbors.values():
for n in neighs.values():
nn.add(n.peer.node)
return nn
def initDAS(self):
""" Minimal sample init function"""
self.DASample = [(random.randrange(self.shape.blockSizeC), random.randrange(self.shape.blockSizeR))
for i in range(self.DASampleSize)]
def checkDAS(self):
""" Dumb check in all neighbors without messaging """
block = Block.copy(self.block)
for neigh in self.getNeighbors():
block.merge(neigh.block)
found = 0
for rid, cid in self.DASample:
found += block.getSegment(rid, cid)
self.logger.debug("DAS found: %d / %d", found, self.DASampleSize, extra=self.format)
return (found, self.DASampleSize)
def logIDs(self):
"""It logs the assigned rows and columns."""

View File

@ -247,6 +247,8 @@ class Simulator:
progressVector = []
trafficStatsVector = []
steps = 0
for i in range(1,self.shape.numberNodes):
self.validators[i].initDAS()
while(True):
missingVector.append(missingSamples)
oldMissingSamples = missingSamples
@ -264,6 +266,8 @@ class Simulator:
for i in range(0,self.shape.numberNodes):
self.validators[i].logRows()
self.validators[i].logColumns()
for i in range(1,self.shape.numberNodes):
self.validators[i].checkDAS()
# log TX and RX statistics
trafficStats = self.glob.getTrafficStats(self.validators)