def __init__(self, logger=None): if logger: self.logger = logger else: self.logger = chordLogger() #basic stuff self.name_space_size = 2**NUM_BITS self.t = 0 self.nodes = {} self.growing = False #parameters for randomization/event distribution #exponential distributin. mostly one node will join per tick. less often 2 nodes, less often 3 nodes...etc. self.concurent_join_alpha = 4 #the rate at which nodes leave/join teh network self.churn_rate = 0.05 self.ids = None
def __init__(self, logger=None): if logger: self.logger = logger else: self.logger = chordLogger() # basic stuff self.name_space_size = 2 ** NUM_BITS self.t = 0 self.nodes = {} self.growing = False # parameters for randomization/event distribution # exponential distributin. mostly one node will join per tick. less often 2 nodes, less often 3 nodes...etc. self.concurent_join_alpha = 4 # the rate at which nodes leave/join teh network self.churn_rate = 0.05 self.ids = None
""" simple test. full network, all 16 nodes are there, all routing tables are set """ def tick(self): print "", # TODO: check if any node's TTL has run out, if has, remove from list # assumes that the network will also retire all nodes whose TTL has run out... def __init__(self): self.nodes = [] self.t = 0 if __name__ == "__main__": print "## CHORD TESTER ##" """ Make class instances """ tester = ChordTest() logger = chordLogger() #viz = ChordWindow() nw = chord.Network(logger) """ Bootstrap/Initialize network """ # add a fixed number (currently 1) of nodes per tick # keep track of nodes that have been added # nodes should have random ID (assume no collisions? or check) # stop at MAX_NODES * JOIN_LATENCY print "\nBootstrapping Network" print "---------------------" raw_input("Press ENTER to continue... ") # Pause nw.bootstrap(3)