From 382954de027071fb6ffc4a8aa35e880dbc521971 Mon Sep 17 00:00:00 2001 From: Csaba Kiraly Date: Tue, 14 Feb 2023 02:11:44 +0100 Subject: [PATCH] add segment level send/receive Signed-off-by: Csaba Kiraly --- DAS/block.py | 6 ++++++ DAS/validator.py | 23 +++++++++++++++++++++++ 2 files changed, 29 insertions(+) diff --git a/DAS/block.py b/DAS/block.py index 693d7b6..e052fcb 100644 --- a/DAS/block.py +++ b/DAS/block.py @@ -20,6 +20,12 @@ class Block: """It merges (OR) the existing block with the received one.""" self.data |= merged.data + def getSegment(self, rowID, columnID): + return self.data[rowID*self.blockSize + columnID] + + def setSegment(self, rowID, columnID, v = 1): + self.data[rowID*self.blockSize + columnID] = v + def getColumn(self, columnID): """It returns the block column corresponding to columnID.""" return self.data[columnID::self.blockSize] diff --git a/DAS/validator.py b/DAS/validator.py index fcdebf4..5cec9e3 100644 --- a/DAS/validator.py +++ b/DAS/validator.py @@ -177,6 +177,20 @@ class Validator: else: pass + def receiveSegment(self, rID, cID, src): + # register receive so that we are not sending back + if rID in self.rowIDs: + if src in self.rowNeighbors[rID]: + self.rowNeighbors[rID][src].receiving[cID] = 1 + if cID in self.columnIDs: + if src in self.columnNeighbors[cID]: + self.columnNeighbors[cID][src].receiving[rID] = 1 + if not self.receivedBlock.getSegment(rID, cID): + self.receivedBlock.setSegment(rID, cID) + # else: + # self.statsRxDuplicateInSlot += 1 + self.statsRxInSlot += 1 + def receiveRowsColumns(self): """It receives rows and columns.""" @@ -266,6 +280,15 @@ class Validator: if not count: return + def sendSegmentToNeigh(self, rID, cID, neigh): + if not neigh.sent[cID] and not neigh.receiving[cID] : + neigh.sent[cID] = 1 + neigh.node.receiveSegment(rID, cID, self.ID) + self.statsTxInSlot += 1 + return True + else: + return False # received or already sent + def send(self): """ Send as much as we can in the timeslot, limited by bwUplink """