diff --git a/DAS/simulator.py b/DAS/simulator.py index 5b60413..3261ad7 100644 --- a/DAS/simulator.py +++ b/DAS/simulator.py @@ -66,8 +66,8 @@ class Simulator: for u, v in G.edges: val1=rowChannels[id][u] val2=rowChannels[id][v] - val1.rowNeighbors[id].update({val2.ID : Neighbor(val2, self.shape.blockSize)}) - val2.rowNeighbors[id].update({val1.ID : Neighbor(val1, self.shape.blockSize)}) + val1.rowNeighbors[id].update({val2.ID : Neighbor(val2, 0, self.shape.blockSize)}) + val2.rowNeighbors[id].update({val1.ID : Neighbor(val1, 0, self.shape.blockSize)}) if (len(columnChannels[id]) <= self.shape.netDegree): self.logger.debug("Graph fully connected with degree %d !" % (len(columnChannels[id]) - 1), extra=self.format) @@ -79,8 +79,8 @@ class Simulator: for u, v in G.edges: val1=columnChannels[id][u] val2=columnChannels[id][v] - val1.columnNeighbors[id].update({val2.ID : Neighbor(val2, self.shape.blockSize)}) - val2.columnNeighbors[id].update({val1.ID : Neighbor(val1, self.shape.blockSize)}) + val1.columnNeighbors[id].update({val2.ID : Neighbor(val2, 1, self.shape.blockSize)}) + val2.columnNeighbors[id].update({val1.ID : Neighbor(val1, 1, self.shape.blockSize)}) if self.logger.isEnabledFor(logging.DEBUG): for i in range(0, self.shape.numberValidators): diff --git a/DAS/validator.py b/DAS/validator.py index 9c43967..aecbc37 100644 --- a/DAS/validator.py +++ b/DAS/validator.py @@ -63,9 +63,10 @@ class Neighbor: """It returns the amount of sent and received data.""" return "%d:%d/%d" % (self.node.ID, self.sent.count(1), self.received.count(1)) - def __init__(self, v, blockSize): + def __init__(self, v, dim, blockSize): """It initializes the neighbor with the node and sets counters to zero.""" self.node = v + self.dim = dim # 0:row 1:col self.receiving = zeros(blockSize) self.received = zeros(blockSize) self.sent = zeros(blockSize) @@ -319,8 +320,12 @@ class Validator: return def sendSegmentToNeigh(self, rID, cID, neigh): - if not neigh.sent[cID] and not neigh.receiving[cID] : - neigh.sent[cID] = 1 + if neigh.dim == 0: #row + i = cID + else: + i = rID + if not neigh.sent[i] and not neigh.receiving[i] : + neigh.sent[i] = 1 neigh.node.receiveSegment(rID, cID, self.ID) self.statsTxInSlot += 1 return True