def leftNode (self, data): global observers_done global retriever_receiving global success MeshNode.leftNode (self, data) print self.name + " => " + data + " left" if (data != "node0"): print "Wrong node left!" success = False reactor.crash() return if (self.mesh.done < observers_done): print "Observer done before getting all info" success = False reactor.crash() return observers_done += 1 if (observers_done == NUMOBSERVERS -1): retriever_receiving = True if (observers_done == NUMOBSERVERS): reactor.crash() retriever.pushInput("blaat\n");
def leftNode(self, data): global observers_done global retriever_receiving global success MeshNode.leftNode(self, data) print self.name + " => " + data + " left" if (data != "node0"): print "Wrong node left!" success = False reactor.crash() return if (self.mesh.done < observers_done): print "Observer done before getting all info" success = False reactor.crash() return observers_done += 1 if (observers_done == NUMOBSERVERS - 1): retriever_receiving = True if (observers_done == NUMOBSERVERS): reactor.crash() retriever.pushInput("blaat\n")
def newNode(self, data): MeshNode.newNode(self, data) print "node0 - Added " + data self.nodes += 1 if self.nodes == NUMOBSERVERS + 1: print "Everybody who could joined" for x in xrange(0, NUMPACKETS): reactor.callLater(0.1 * x, (lambda y: self.push_packet(y)), x)
def newNode (self, data): MeshNode.newNode (self, data) print "node0 - Added " + data self.nodes += 1 if self.nodes == NUMNODES - 1: print "Everybody who could joined" for x in xrange(0, NUMPACKETS): reactor.callLater(0.1 * x, (lambda y: self.pushInput(str(y) + "\n")), x)
def newNode (self, data): MeshNode.newNode (self, data) print "node0 - Added " + data self.nodes += 1 if self.nodes == NUMOBSERVERS + 1: print "Everybody who could joined" for x in xrange(0, NUMPACKETS): reactor.callLater(0.1 * x, (lambda y: self.push_packet(y)), x)
def newNode (self, data): MeshNode.newNode (self, data) print "node0 - Added " + data self.nodes += 1 if self.nodes == NUMNODES: print "Everybody joined" for x in xrange(0, NUMPACKETS): reactor.callLater(0.1 * x, (lambda y: self.pushInput(str(y) + "\n")), x)
def newNode(self, data): MeshNode.newNode(self, data) print data + " joined" if (data == failnode.name): m.removeMeshNode(failnode) n = MeshNode("joinnode", m) m.addMeshNode(n) m.connect_duplex(self, n, 1024, 50, 0.30) if (data == "joinnode"): global success success = True reactor.crash()
def leftNode(self, data): global observers_done MeshNode.leftNode(self, data) print data + " left" if (data != "node0"): print "Wrong node left!" success = False reactor.stop() if (self.mesh.done < observers_done): print "Observer done before getting all info" success = False reactor.stop() observers_done += 1 if (observers_done == NUMOBSERVERS): reactor.stop()
def leftNode (self, data): global observers_done MeshNode.leftNode (self, data) print data + " left" if (data != "node0"): print "Wrong node left!" success = False reactor.stop() if (self.mesh.done < observers_done): print "Observer done before getting all info" success = False reactor.stop() observers_done += 1 if (observers_done == NUMOBSERVERS): reactor.stop()
print node.name + " - " + sender + " - " + data.rstrip() if self.expected == None: self.expected = value if self.expected > 2 and self.expected != value: print "Expected: " + str(self.expected) + " But got: " + str(value) success = False reactor.crash() self.expected = value + 1 if self.expected > 50: reactor.crash() m = TestMesh() for x in xrange(0, 3): n = MeshNode("node" + str(x), m) nodes.append(n) m.addMeshNode(n) n = TestMeshNode("node3", m) nodes.append(n) m.addMeshNode(n) #connect node 0 and 1 together with dropfree links, and 0 <->2 and 1 <-> 2 # with quite lossy links m.connect_duplex(nodes[0], nodes[1], 100, 0, 0) m.connect_duplex(nodes[0], nodes[2], 100, 0, 0) m.connect_duplex(nodes[1], nodes[2], 100, 0, 0)
def node_disconnected(self): global retriever # Let the retriever receive packets again and let it fail the sender retriever.fail(self.name) MeshNode.node_disconnected(self)
def node_connected(self): MeshNode.node_connected(self) print "Connected"
def lostNode(self, data): MeshNode.lostNode(self, data) print data + " lost"
def sendPacket (self, data): if packet_type(data) != WHOIS_REPLY: MeshNode.sendPacket(self, data)
m.addMeshNode(n) m.connect_duplex(self, n, 1024, 50, 0.30) if (data == "joinnode"): global success success = True reactor.crash() def lostNode(self, data): MeshNode.lostNode(self, data) print data + " lost" n = TestMeshNode("node", m) m.addMeshNode(n) failnode = MeshNode("failnode", m) m.addMeshNode(failnode) # Connect all nodes to all others. 1024 bytes/s bandwidth, 50ms delay and 0% # packet loss.. (bandwidth and delay aren't implemented just yet) m.connect_full(1024, 50, 0.30) reactor.run() if not success: print "FAILED" exit(1) print "SUCCESS" exit(0)
def leftNode (self, data): MeshNode.leftNode (self, data) print data.rstrip() + " left" reactor.stop()
def newNode (self, data): MeshNode.newNode (self, data) print data + " joined"
def __init__(self, name, mesh): MeshNode.__init__(self, name, mesh)
def sendPacket(self, data): if (not self.send_data and packet_type(data) == DATA): return if packet_type(data) == BYE: self.send_data = True MeshNode.sendPacket(self, data)
def __init__ (self, name, mesh): MeshNode.__init__(self, name, mesh)
def leftNode (self, data): MeshNode.leftNode (self, data) print data + " left"
def __init__(self, name, mesh): MeshNode.__init__(self, name, mesh) self.count = 0
def sendPacket (self, data): if packet_type(data) != ATTEMPT_JOIN: MeshNode.sendPacket(self, data)
def leftNode(self, data): MeshNode.leftNode(self, data) print data.rstrip() + " left" reactor.stop()
def node_connected (self): MeshNode.node_connected(self) reactor.callLater (0.5, self.push)
def sendPacket(self, data): if packet_type(data) != ATTEMPT_JOIN: MeshNode.sendPacket(self, data)
def sendPacket (self, data): if (not self.send_data and packet_type(data) == DATA): return if packet_type(data) == BYE: self.send_data = True MeshNode.sendPacket (self, data)