From 1403ca7ad03b4128475e20d99ef5e62084da3e1f Mon Sep 17 00:00:00 2001 From: Csaba Kiraly Date: Tue, 14 Feb 2023 02:18:37 +0100 Subject: [PATCH] add random scheduler --- DAS/validator.py | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/DAS/validator.py b/DAS/validator.py index a887bb5..67ef141 100644 --- a/DAS/validator.py +++ b/DAS/validator.py @@ -321,6 +321,35 @@ class Validator: self.sendQueue.popleft() + 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 + for n in self.sched: neigh = n.neigh toSend = n.toSend