Advertisement
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
- from nest.topology.address_helper import AddressHelper
- class PodError(Exception):
- def __init__(self,message):
- self.message=message
- class Pod:
- def __init__(self,k,net,bw,delay):
- self.agg_switches=[Switch('as'+str(i+1)) for i in range(k/2)]
- self.edge_switches=[Switch('as'+str(i+1)) for i in range(k/2)]
- t=k**3/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])
- i1.set_attributes(bw, delay)
- '''
- 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)
- i1.set_attributes(bw, delay)
- class Fat_tree_helper(topo_helper):
- def __init__(self,k,nid,bw='100mbit',delay='1ms'):
- super().__init__(bw,delay)
- if k<0:
- raise PodError("Negative pod count")
- elif k%2==1:
- raise PodError("Odd pod count")
- self.pod_cnt=k
- self.core_cnt=(k//2)**2
- self.core_switches=[Switch('cs'+str(i+1)) for i in range(self.core_cnt)]
- self.nid=Network(nid)
- self.blocks=[Pod(k,nid)]*k
- bw=topo_helper.get_bandwidth()
- delay=topo_helper.get_delay()
- '''
- 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.nid:
- (i1,i2)=connect(s,t)
- i1.set_attributes(bw, delay)
- start+=(k/2)
- AddressHelper.assign_address()
- def __str__(self):
- return "This is Fat tree class"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement