Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import sys
- from nest.experiment import *
- from nest.topology import *
- from topo_helper import topo_helper
- class PodError(Exception):
- def __init__(self,message):
- self.message=message
- class Pod:
- def __init__(self,switch_cnt,net):
- self.switch_cnt=switch_cnt
- self.agg_switches=[Switch('as'+str(i+1)) for i in range(switch_cnt)]
- self.edge_switches=[Switch('as'+str(i+1)) for i in range(switch_cnt)]
- t=k**2/4
- self.hosts=[Node('h'+str(i+1)) for i in range(t)]
- '''
- Connections between host to Edge switch
- '''
- for i,switch in enumerate(self.edge_switches):
- start=i*(k/2)
- for j in range(start,start+k/2):
- with net:
- (i1,i2)=connect(switch,self.hosts[j])
- '''
- Connectins between edge switch to agg switch
- '''
- for a_switch in self.agg_switches:
- for e_switch in self.edge_switches:
- with net:
- (i1,i2)=connect(a_switch,e_switch)
- class Fat_tree_helper(topo_helper):
- def __init__(self,pod_cnt,nid):
- if pod_cnt<0:
- raise PodError("Negative pod count")
- elif pod_cnt%2==1:
- raise PodError("Odd pod count")
- self.pod_cnt=pod_cnt
- self.core_cnt=(pod_cnt//2)**2
- self.core_switches=[Switch('cs'+str(i+1)) for i in range(self.core_cnt)]
- self.nid=Network(nid)
- self.blocks=[Pod(pod_cnt,nid)]*pod_cnt
- '''
- Connections betwween core switch to agg switch
- '''
- for block in self.blocks:
- start=0
- for s in block.agg_switches:
- for i in range(start,start+k/2):
- t=self.core_switches[i]
- with self.net:
- (i1,i2)=connect(s,t)
- start+=(k/2)
- AddressHelper.assign_address()
- def get_nid(self):
- def __str__(self):
- return "This is Fat tree class"
Advertisement
Add Comment
Please, Sign In to add comment