Advertisement
Guest User

Untitled

a guest
Mar 25th, 2017
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.29 KB | None | 0 0
  1. import random
  2.  
  3. bootstrap_node_list_recieved = [] #List of all nodes addresses recieved during the bootstrap peroid - Is a list so we can compare duplicatition probability etc
  4. average_getAdrr_no_node_response = 100 #Number or nodes typically sent when a node requests a getAddr message
  5. network_ip_node_size = 5000 # Number of IP addresses / nodes that have been seen on the network in the past 2 weeks
  6.  
  7.  
  8. #Move into calculations.py when ready
  9. #Number of nodes recieved (Bootstrap)
  10. def bootstrap_node_getAddr():
  11. #### TODO ####
  12. #Random generation of nodes (number represents a single node), from 1 to x for an average amount of nodes
  13. # node_list=[random.randrange(1,network_ip_node_size,1) for _ in range (average_getAdrr_no_node_response)]
  14. for i in range (average_getAdrr_no_node_response):
  15. bootstrap_node_list_recieved.append(random.randrange(1,network_ip_node_size,1))
  16. print 'bootstrap_node_getAddr: ', bootstrap_node_list_recieved
  17. # return bootstrap_node_list_recieved
  18.  
  19. bootstrap_node_getAddr()
  20.  
  21. Traceback (most recent call last):
  22. File "BootstrapBTC.py", line 117, in query_dns_servers
  23. bootstrap_node_getAddr()
  24. File "/home/richard/Dropbox/PhD/Simulator BTC - Ours/Calculations.py", line 33, in bootstrap_node_getAddr
  25. bootstrap_node_list_recieved.append(random.randrange(1,network_ip_node_size,1))
  26. AttributeError: 'builtin_function_or_method' object has no attribute 'randrange'
  27.  
  28. The above exception was the direct cause of the following exception:
  29.  
  30. Traceback (most recent call last):
  31. File "BootstrapBTC.py", line 90, in run
  32. yield self.env.process(query_dns_servers(env, self))
  33. AttributeError: 'builtin_function_or_method' object has no attribute 'randrange'
  34.  
  35. The above exception was the direct cause of the following exception:
  36.  
  37. Traceback (most recent call last):
  38. File "BootstrapBTC.py", line 178, in <module>
  39. env.run()
  40. File "/usr/local/lib/python2.7/dist-packages/simpy/core.py", line 137, in run
  41. self.step()
  42. File "/usr/local/lib/python2.7/dist-packages/simpy/core.py", line 229, in step
  43. raise exc
  44. AttributeError: 'builtin_function_or_method' object has no attribute 'randrange
  45.  
  46. yield self.env.process(query_dns_servers(env, self))
  47.  
  48. #Average respsonse time from a DNS server
  49. def DnsServerResponse(env, self):
  50. yield self.env.timeout(dns_average_response)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement