From 0c91eff67be2594f1625446cb25b80d8fd8f9481 Mon Sep 17 00:00:00 2001 From: Csaba Kiraly Date: Wed, 15 Feb 2023 03:15:00 +0100 Subject: [PATCH] add dumbRandomScheduler parameter Signed-off-by: Csaba Kiraly --- DAS/validator.py | 60 ++++++++++++++++++++++++++---------------------- 1 file changed, 32 insertions(+), 28 deletions(-) diff --git a/DAS/validator.py b/DAS/validator.py index aecbc37..8e52f93 100644 --- a/DAS/validator.py +++ b/DAS/validator.py @@ -123,6 +123,7 @@ class Validator: self.perNeighborQueue = False # queue incoming messages to outgoing connections on arrival (as typical GossipSub impl) self.perNodeQueue = False # keep a global queue of incoming messages for later sequential dispatch + self.dumbRandomScheduler = False # dumb random scheduler self.sched = self.nextToSend() def logIDs(self): @@ -374,34 +375,37 @@ class Validator: if self.statsTxInSlot >= self.bwUplink: return - tries = 100 - while tries: - if self.rowIDs: - rID = random.choice(self.rowIDs) - cID = random.randrange(0, self.shape.blockSize) - if self.block.getSegment(rID, cID) : - neigh = random.choice(list(self.rowNeighbors[rID].values())) - if not neigh.sent[cID] and not neigh.receiving[cID] : - neigh.sent[cID] = 1 - neigh.node.receiveSegment(rID, cID, self.ID) - self.statsTxInSlot += 1 - tries = 100 - if self.statsTxInSlot >= self.bwUplink: - return - if self.columnIDs: - cID = random.choice(self.columnIDs) - rID = random.randrange(0, self.shape.blockSize) - if self.block.getSegment(rID, cID) : - neigh = random.choice(list(self.columnNeighbors[cID].values())) - if not neigh.sent[rID] and not neigh.receiving[rID] : - neigh.sent[rID] = 1 - neigh.node.receiveSegment(rID, cID, self.ID) - self.statsTxInSlot += 1 - tries = 100 - tries -= 1 - if self.statsTxInSlot >= self.bwUplink: - return - return + if self.dumbRandomScheduler: + # dumb random scheduler picking segments at random and trying to send it + tries = 100 + t = tries + while t: + if self.rowIDs: + rID = random.choice(self.rowIDs) + cID = random.randrange(0, self.shape.blockSize) + if self.block.getSegment(rID, cID) : + neigh = random.choice(list(self.rowNeighbors[rID].values())) + if not neigh.sent[cID] and not neigh.receiving[cID] : + neigh.sent[cID] = 1 + neigh.node.receiveSegment(rID, cID, self.ID) + self.statsTxInSlot += 1 + t = tries + if self.statsTxInSlot >= self.bwUplink: + return + if self.columnIDs: + cID = random.choice(self.columnIDs) + rID = random.randrange(0, self.shape.blockSize) + if self.block.getSegment(rID, cID) : + neigh = random.choice(list(self.columnNeighbors[cID].values())) + if not neigh.sent[rID] and not neigh.receiving[rID] : + neigh.sent[rID] = 1 + neigh.node.receiveSegment(rID, cID, self.ID) + self.statsTxInSlot += 1 + t = tries + t -= 1 + if self.statsTxInSlot >= self.bwUplink: + return + return for n in self.sched: neigh = n.neigh