Iam_Sandeep

Untitled

May 14th, 2022
141
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.11 KB | None | 0 0
  1. import sys
  2. from nest.experiment import *
  3. from nest.topology import *
  4. from topo_helper import topo_helper
  5.  
  6. class PodError(Exception):
  7. def __init__(self,message):
  8. self.message=message
  9.  
  10.  
  11. class Pod:
  12. def __init__(self,switch_cnt,net):
  13. self.switch_cnt=switch_cnt
  14. self.agg_switches=[Switch('as'+str(i+1)) for i in range(switch_cnt)]
  15. self.edge_switches=[Switch('as'+str(i+1)) for i in range(switch_cnt)]
  16. t=k**2/4
  17.  
  18. self.hosts=[Node('h'+str(i+1)) for i in range(t)]
  19. '''
  20. Connections between host to Edge switch
  21. '''
  22. for i,switch in enumerate(self.edge_switches):
  23. start=i*(k/2)
  24. for j in range(start,start+k/2):
  25. with net:
  26. (i1,i2)=connect(switch,self.hosts[j])
  27.  
  28.  
  29. '''
  30. Connectins between edge switch to agg switch
  31. '''
  32. for a_switch in self.agg_switches:
  33. for e_switch in self.edge_switches:
  34. with net:
  35. (i1,i2)=connect(a_switch,e_switch)
  36.  
  37.  
  38.  
  39.  
  40.  
  41.  
  42.  
  43.  
  44.  
  45.  
  46. class Fat_tree_helper(topo_helper):
  47. def __init__(self,pod_cnt,nid):
  48. if pod_cnt<0:
  49. raise PodError("Negative pod count")
  50. elif pod_cnt%2==1:
  51. raise PodError("Odd pod count")
  52.  
  53. self.pod_cnt=pod_cnt
  54. self.core_cnt=(pod_cnt//2)**2
  55. self.core_switches=[Switch('cs'+str(i+1)) for i in range(self.core_cnt)]
  56.  
  57. self.nid=Network(nid)
  58. self.blocks=[Pod(pod_cnt,nid)]*pod_cnt
  59.  
  60.  
  61. '''
  62. Connections betwween core switch to agg switch
  63. '''
  64.  
  65. for block in self.blocks:
  66. start=0
  67. for s in block.agg_switches:
  68. for i in range(start,start+k/2):
  69. t=self.core_switches[i]
  70. with self.net:
  71. (i1,i2)=connect(s,t)
  72.  
  73.  
  74. start+=(k/2)
  75.  
  76. AddressHelper.assign_address()
  77.  
  78. def get_nid(self):
  79.  
  80.  
  81.  
  82.  
  83.  
  84.  
  85.  
  86.  
  87.  
  88.  
  89.  
  90. def __str__(self):
  91. return "This is Fat tree class"
Advertisement
Add Comment
Please, Sign In to add comment