Commit 3a6da863 authored by mshahbaz's avatar mshahbaz
Browse files

initial commits

parents
#!/usr/bin/python
import matplotlib.pyplot as plt
from utils import *
from output.aggregateEdges import *
from output.out import links as links_c, switches as switches_c, groupSize as groupSize_c
coreLinks_c = []
podLinks_c = []
edgeLinks_c = []
coreSwitches_c = []
aggrSwitches_c = []
edgeSwitches_c = []
for link in links_c.keys():
if link.find('C') == 0:
coreLinks_c.append(links_c[link])
elif link.find('A') == 0:
podLinks_c.append(links_c[link])
elif link.find('E') == 0:
edgeLinks_c.append(links_c[link])
else:
print link
for switch in switches_c.keys():
if switch.find('C') == 0:
coreSwitches_c.append(switches_c[switch])
if switch.find('A') == 0:
aggrSwitches_c.append(switches_c[switch])
if switch.find('E') == 0:
edgeSwitches_c.append(switches_c[switch])
plt.figure(0)
ccdf_hosts_c = CCDF(groupSize_c['members'], 1000)
ccdf_pods_c = CCDF(groupSize_c['pods'], 1000)
ccdf_edges_c = CCDF(groupSize_c['edges'], 1000)
ccdf_addr_core_c = CDF(coreSwitches_c, 1000)
ccdf_addr_aggr_c = CDF(aggrSwitches_c, 1000)
ccdf_addr_edge_c = CDF(edgeSwitches_c, 1000)
ccdf_addr_edge_aggr = CDF(switches[1], 1000)
ccdf_link_core_c = CDF(coreLinks_c, 100)
ccdf_link_aggr_c = CDF(podLinks_c, 1000)
ccdf_link_edge_c = CDF(edgeLinks_c, 10000)
ccdf_link_edge_aggr = CDF(links[1],10000)
plt.figure(1)
#plt.suptitle('CCDF of multicast addresses on switches\n dashed -> after aggregation ')
#plt.subplots_adjust(hspace=1.5)
ax1 = plt.subplot(211)
p1, = plt.plot(ccdf_addr_core_c[0], ccdf_addr_core_c[1], 'b-')
p2, = plt.plot(ccdf_addr_aggr_c[0], ccdf_addr_aggr_c[1], 'g-')
p3, = plt.plot(ccdf_addr_edge_c[0], ccdf_addr_edge_c[1], 'r-')
p4, = plt.plot(ccdf_addr_edge_aggr[0], ccdf_addr_edge_aggr[1], 'r--')
label1 = 'core'
label2 = 'aggr'
label3 = 'edge'
label4 = 'edge'
plt.legend([p1,p2,p3,p4], [label1, label2, label3, label4], \
bbox_to_anchor=(1,0), loc=4, prop={'size':10})
plt.xlabel('number of multicast addresses on a switch')
#plt.xlim(0,8000)
plt.ylim(0,1)
ax1.xaxis.grid(True, linestyle='-', which='major', color='lightgrey', alpha=0.5)
ax1.yaxis.grid(True, linestyle='-', which='major', color='lightgrey', alpha=0.5)
ax1.set_axisbelow(True)
ax2 = plt.subplot(212)
p1, = plt.plot(ccdf_link_core_c[0], ccdf_link_core_c[1], 'b-')
p2, = plt.plot(ccdf_link_aggr_c[0], ccdf_link_aggr_c[1], 'g-')
p3, = plt.plot(ccdf_link_edge_c[0], ccdf_link_edge_c[1], 'r-')
p4, = plt.plot(ccdf_link_edge_aggr[0], ccdf_link_edge_aggr[1], 'r--')
label1 = 'core-aggr'
label2 = 'aggr-edge'
label3 = 'edge-host'
label4 = 'edge-host'
plt.legend([p1,p2,p3,p4], [label1, label2, label3, label4], \
bbox_to_anchor=(1,0), loc=4, prop={'size':10})
plt.xlabel('traffic rate on a link')
#plt.xlim(0,30000)
plt.ylim(0,1)
ax2.xaxis.grid(True, linestyle='-', which='major', color='lightgrey', alpha=0.5)
ax2.yaxis.grid(True, linestyle='-', which='major', color='lightgrey', alpha=0.5)
ax2.set_axisbelow(True)
plt.show()
#!/usr/bin/python
import matplotlib.pyplot as plt
from matplotlib.patches import Polygon
from utils import *
from output.out import *
from output.aggregateEdges import switches as edgeSwitches, links as edgeLinks
plt.rc('pdf',fonttype = 42)
plt.rc('ps',fonttype = 42)
coreS = []
aggrS = []
edgeS = []
edgeS_ = edgeSwitches[1]
aggrM = []
edgeM = []
coreL = []
aggrL = []
edgeL = []
edgeL_ = edgeLinks[1]
for switch in switches.keys():
if switch.find('C') == 0:
coreS.append(switches[switch])
if switch.find('A') == 0:
aggrS.append(switches[switch])
aggrM.append(switches[switch]-unicast[switch])
if switch.find('E') == 0:
edgeS.append(switches[switch])
edgeM.append(switches[switch]-unicast[switch])
print max(aggrS)
for link in links.keys():
if link.find('C') == 0:
coreL.append(links[link])
elif link.find('A') == 0:
aggrL.append(links[link])
elif link.find('E') == 0:
edgeL.append(links[link])
def boxplot(data,pos,linecolor,boxcolor,ax):
bp = plt.boxplot(data,vert=0,whis=5,positions=pos,widths=0.5)
plt.setp(bp['boxes'], color=linecolor)
plt.setp(bp['whiskers'], color=linecolor, linestyle='-')
plt.setp(bp['medians'], color=linecolor)
plt.setp(bp['fliers'], color=linecolor, marker='+')
plt.setp(bp['caps'], color=linecolor)
box = bp['boxes'][0]
boxX = []
boxY = []
for j in range(5):
boxX.append(box.get_xdata()[j])
boxY.append(box.get_ydata()[j])
boxCoords = zip(boxX,boxY)
boxPolygon = Polygon(boxCoords, facecolor=boxcolor)
ax.add_patch(boxPolygon)
med = bp['medians'][0]
plt.plot([np.average(data)], [np.average(med.get_ydata())],
color='w', marker='.', markeredgecolor=linecolor)
return bp
fig = plt.figure()
colors = ['black','white','grey','blue','forestgreen','orangered','darkviolet','crimson']
ax1 = fig.add_subplot(211)
boxplot(edgeS_,[1],colors[3],colors[1],ax1)
boxplot(edgeS,[2],colors[0],colors[1],ax1)
#boxplot(aggrM,[3],colors[0],colors[1],ax1)
boxplot(aggrS,[3],colors[0],colors[1],ax1)
boxplot(coreS,[4],colors[0],colors[1],ax1)
plt.ylim(0.5,4.5)
plt.tick_params(labelsize=11)
plt.yticks([1,2,3,4], ['(la) E','E','A','C'],size=11)
plt.xlabel('No. of multicast addresses on a switch',size=11)
ax1.xaxis.grid(True, linestyle='-', which='major', color='lightgrey')
ax1.set_axisbelow(True)
#plt.figtext(0.6, 0.86, 'after local aggregation ',
# backgroundcolor=colors[2], color='blue', weight='roman', size=9)
ax2 = fig.add_subplot(212)
boxplot(edgeL_,[1],colors[3],colors[1],ax2)
boxplot(edgeL,[2],colors[0],colors[1],ax2)
boxplot(aggrL,[3],colors[0],colors[1],ax2)
boxplot(coreL,[4],colors[0],colors[1],ax2)
plt.ylim(0.5,4.5)
plt.xlim(-1000, 26000)
plt.tick_params(labelsize=11)
plt.yticks([1,2,3,4], ['(la) E-H','E-H','A-E','C-A'],size=11)
plt.xlabel('Traffic rate on a link',size=11)
ax2.xaxis.grid(True, linestyle='-', which='major', color='lightgrey')
ax2.set_axisbelow(True)
plt.show()
#!/usr/bin/python
import matplotlib.pyplot as plt
from utils import *
from output.failover import *
plt.rc('pdf',fonttype = 42)
plt.rc('ps',fonttype = 42)
M = 4
plt.figure(0)
ccdf_stretch = [0]*M
ccdf_unreachable = [0]*M
ccdf_unreachable_r = [0]*M
for i in range(M):
ccdf_stretch[i] = CCDF(stretch[i], 1000)
ccdf_unreachable[i] = CCDF(unreachable[i], 1000)
ccdf_unreachable_r[i] = CCDF(unreachable_r[i], 1000)
plt.figure(1)
ax1 = plt.subplot(211)
p1, = plt.plot(ccdf_stretch[0][0], ccdf_stretch[0][1], '-*')
p1.set_markevery(200)
p2, = plt.plot(ccdf_stretch[1][0], ccdf_stretch[1][1], '-o')
p2.set_markevery(200)
p3, = plt.plot(ccdf_stretch[2][0], ccdf_stretch[2][1], '-^')
p3.set_markevery(200)
p4, = plt.plot(ccdf_stretch[3][0], ccdf_stretch[3][1], '-s')
p4.set_markevery(200)
label1 = '10 failures'
label2 = '50 failures'
label3 = '100 failures'
label4 = '200 failures'
l = plt.legend([p4,p3,p2,p1], [label4, label3, label2, label1], \
bbox_to_anchor=(1,1), loc=1, prop={'size':9}, numpoints=1, markerscale=0.8)
l.set_frame_on(False)
plt.yscale('log')
plt.ylabel('CCDF', size=11)
plt.xlabel('Average route stretch of a multicast group',size=11)
plt.xlim(1,2)
plt.ylim(0.000001,1)
plt.tick_params(labelsize=11)
ax1.xaxis.grid(True, linestyle='-', which='major', color='lightgrey')
ax1.yaxis.grid(True, linestyle='-', which='major', color='lightgrey')
ax2 = plt.subplot(212)
p1, = plt.plot(ccdf_unreachable_r[0][0], ccdf_unreachable_r[0][1], '-*')
p1.set_markevery(200)
p2, = plt.plot(ccdf_unreachable_r[1][0], ccdf_unreachable_r[1][1], '-o')
p2.set_markevery(200)
p3, = plt.plot(ccdf_unreachable_r[2][0], ccdf_unreachable_r[2][1], '-^')
p3.set_markevery(200)
p4, = plt.plot(ccdf_unreachable_r[3][0], ccdf_unreachable_r[3][1], '-s')
p4.set_markevery(200)
label1 = '10 failures'
label2 = '50 failures'
label3 = '100 failures'
label4 = '200 failures'
l = plt.legend([p4,p3], [label4, label3], \
bbox_to_anchor=(1,1), loc=1, prop={'size':9}, numpoints=1, markerscale=0.8)
l.set_frame_on(False)
plt.yscale('log')
plt.ylabel('CCDF',size=11)
plt.xlabel('Unreachable hosts of a multicast group',size=11)
plt.xlim(0,1)
#plt.ylim(0,1)
plt.tick_params(labelsize=11)
#plt.xticks([0,0.1,0.2,0.3,0.4,0.5], ['0','10%','20%','30%','40%','50%'])
plt.xticks([0,0.2,0.4,0.6,0.8,1], ['0','20%','40%','60%','80%','100%'])
ax2.xaxis.grid(True, linestyle='-', which='major', color='lightgrey')
ax2.yaxis.grid(True, linestyle='-', which='major', color='lightgrey')
plt.show()
#!/usr/bin/python
import random
import matplotlib.pyplot as plt
from utils import *
#random.seed(0)
def randomSample(N, method, _min):
size = 0
if method == 'tri': # triangular distribution
size = int(random.triangular(_min-1, N+3, _min+4))%N+1
elif method == 'beta': # beta distribution
size = int((N-_min+1)*random.betavariate(0.6, 0.6))+_min
elif method == 'norm_r': # reverse norm distribution
p = random.gauss(0.5,0.25)
if p < 0.5: p = abs(0.5-p)
else: p = abs(1.5-p)
size = int(N*p)%N+1
elif method == 'expo': # exponential distribution
size = int(random.expovariate(0.12))%N+1
elif method == 'expo_r': # reverse exponential distribution
size = N-int(random.expovariate(0.12))%N
elif method == 'gamma': # gamma distribution
size = int(random.gammavariate(2.5,2)*N/15+_min-1)%N+1
elif method == 'gamma': # gamma distribution
size = int(random.gammavariate(2.5,2)*N/15+_min-1)%N+1
elif method == 'mix1':
seed = random.random()
if seed < 0.1:
size = random.randint(_min,N)
else:
size = int(random.gammavariate(2.5,0.5)*N/15+_min-1)%N+1
elif method == 'mix2':
r = random.random()
if r < 0.01:
size = N-int(random.gammavariate(1,0.1)*N/15)%N
else:
size = int(random.gammavariate(1.4,0.1)*N/15+_min-1)%N+1
elif method == 'mix3':
r = random.random()
if r < 0.02:
size = N-int(random.gammavariate(1,0.1)*N/15)%N
else:
size = int(random.gammavariate(2,0.2)*N/15+_min-1)%N+1
elif method == 'mix4':
r = random.random()
if r < 0.02:
size = N-int(random.gammavariate(1,0.1)*N/15)%N
elif r >= 0.02 and r < 0.42:
size = random.randint(_min, N)
else:
size = int(random.gammavariate(2,0.2)*N/15+_min-1)%N+1
else: # uniform distribution
size = random.randint(_min,N)
size = max(size, _min)
return size
UserNum = 1000
GroupNum = 100000
groupSize = [0]*GroupNum
for i in range(GroupNum):
groupSize[i] = randomSample(UserNum, 'mix3', 4)
plt.figure(0)
ccdf_groupSize = CDF(groupSize, 1000)
plt.figure(1)
ax1 = plt.subplot(211)
#plt.title('Histogram of group size distribution')
plt.hist(groupSize, bins = UserNum-3)
#plt.xlabel('number of hosts per group')
plt.ylabel('frequency')
plt.grid('on')
plt.yticks([])
ax2 = plt.subplot(212, sharex=ax1)
#plt.title('CCDF of group size distribution')
p1, = plt.plot(ccdf_groupSize[0], ccdf_groupSize[1])
label1 = StatLabel(groupSize)
plt.legend([p1], [label1], bbox_to_anchor=(1,0), loc=4, prop={'size':10})
plt.xlabel('number of hosts per group')
#plt.xscale('log')
#plt.yscale('log')
plt.ylim(0,1)
plt.grid('on')
plt.setp(ax1.get_xticklabels(), visible=False)
plt.figure(2)
p1, = plt.plot(ccdf_groupSize[0], ccdf_groupSize[1])
label1 = StatLabel(groupSize)
plt.legend([p1], [label1], bbox_to_anchor=(1,0), loc=4, prop={'size':10})
plt.xlabel('number of hosts per group')
plt.xscale('log')
#plt.yscale('log')
plt.ylim(0,1)
plt.grid('on')
plt.show()
#!/usr/bin/python
import random
import matplotlib.pyplot as plt
from utils import *
from output.groupsize_rand_out import groupSize as groupsize
random.seed(0)
plt.rc('pdf',fonttype = 42)
plt.rc('ps',fonttype = 42)
def randomSample(N, method, _min):
size = 0
if method == 'tri': # triangular distribution
size = int(random.triangular(_min-1, N+3, _min+4))%N+1
elif method == 'beta': # beta distribution
size = int((N-_min+1)*random.betavariate(0.6, 0.6))+_min
elif method == 'norm_r': # reverse norm distribution
p = random.gauss(0.5,0.25)
if p < 0.5: p = abs(0.5-p)
else: p = abs(1.5-p)
size = int(N*p)%N+1
elif method == 'expo': # exponential distribution
size = int(random.expovariate(0.12))%N+1
elif method == 'expo_r': # reverse exponential distribution
size = N-int(random.expovariate(0.12))%N
elif method == 'gamma': # gamma distribution
size = int(random.gammavariate(2.5,2)*N/15+_min-1)%N+1
elif method == 'gamma': # gamma distribution
size = int(random.gammavariate(2.5,2)*N/15+_min-1)%N+1
elif method == 'mix1':
seed = random.random()
if seed < 0.1:
size = random.randint(_min,N)
else:
size = int(random.gammavariate(2.5,0.5)*N/15+_min-1)%N+1
elif method == 'mix2':
r = random.random()
if r < 0.01:
size = N-int(random.gammavariate(1,0.1)*N/15)%N
else:
size = int(random.gammavariate(1.4,0.1)*N/15+_min-1)%N+1
elif method == 'mix3':
r = random.random()
if r < 0.02:
size = N-int(random.gammavariate(1,0.1)*N/15)%N
else:
size = int(random.gammavariate(2,0.2)*N/15+_min-1)%N+1
elif method == 'mix4':
r = random.random()
if r < 0.02:
size = N-int(random.gammavariate(1,0.1)*N/15)%N
elif r >= 0.02 and r < 0.42:
size = random.randint(_min, N)
else:
size = int(random.gammavariate(2,0.2)*N/15+_min-1)%N+1
else: # uniform distribution
size = random.randint(_min,N)
size = max(size, _min)
return size
UserNum = 200
GroupNum = 3000
groupSize = [0]*GroupNum
for i in range(GroupNum):
groupSize[i] = randomSample(UserNum, '', 5)
plt.figure(0)
groupsize = groupsize['members']
cdf_groupSize = CDF(groupSize, 10000)
ccdf_hosts = CDF(groupsize, 50000)
plt.figure(1)
ax1 = plt.subplot(211)
plt.hist(groupSize, bins = UserNum-4, normed=True, facecolor='black')
plt.ylabel('frequency',size=11)
plt.yticks([0,0.005,0.01])
#plt.ylim(0,0.01)
#p1, = plt.plot(cdf_groupSize[0], cdf_groupSize[1])
#plt.ylabel('CDF')
plt.xlabel('Group size (a sample tenant with 200 VMs)', size=11)
ax3 = plt.subplot(212)
p1, = plt.plot(ccdf_hosts[0], ccdf_hosts[1])
label1 = StatLabel(groupsize)
#plt.legend([p1], [label1], bbox_to_anchor=(1,0), loc=4, prop={'size':9})
plt.figtext(0.60, 0.18, label1,
backgroundcolor='white', color='black', weight='roman', size=10)
plt.xlabel('Group size (all tenants)',size=11)
plt.xscale('log')
plt.ylabel('CDF',size=11)
plt.xlim(4,10000)
plt.xticks([4,5,6,7,8,9,10,20,30,40,50,60,70,80,90,100,200,300,400,500,600,700,800,900,1000,2000,3000,4000,5000,6000,7000,8000,9000,10000])
#plt.yscale('log')
plt.ylim(0,1)
#plt.grid('on')
ax3.xaxis.grid(True, linestyle='-', which='major', color='lightgrey')
ax3.yaxis.grid(True, linestyle='-', which='major', color='lightgrey')
plt.show()
#!/usr/bin/python
import random
import matplotlib.pyplot as plt
from utils import *
from output.groupsize_wve_out import groupSize as groupsize
random.seed(0)
plt.rc('pdf',fonttype = 42)
plt.rc('ps',fonttype = 42)
def randomSample(N, method, _min):
size = 0
if method == 'tri': # triangular distribution
size = int(random.triangular(_min-1, N+3, _min+4))%N+1
elif method == 'beta': # beta distribution
size = int((N-_min+1)*random.betavariate(0.6, 0.6))+_min
elif method == 'norm_r': # reverse norm distribution
p = random.gauss(0.5,0.25)
if p < 0.5: p = abs(0.5-p)
else: p = abs(1.5-p)
size = int(N*p)%N+1
elif method == 'expo': # exponential distribution
size = int(random.expovariate(0.12))%N+1
elif method == 'expo_r': # reverse exponential distribution
size = N-int(random.expovariate(0.12))%N
elif method == 'gamma': # gamma distribution
size = int(random.gammavariate(2.5,2)*N/15+_min-1)%N+1
elif method == 'gamma': # gamma distribution
size = int(random.gammavariate(2.5,2)*N/15+_min-1)%N+1
elif method == 'mix1':
seed = random.random()
if seed < 0.1:
size = random.randint(_min,N)
else:
size = int(random.gammavariate(2.5,0.5)*N/15+_min-1)%N+1
elif method == 'mix2':
r = random.random()
if r < 0.01:
size = N-int(random.gammavariate(1,0.1)*N/15)%N
else:
size = int(random.gammavariate(1.4,0.1)*N/15+_min-1)%N+1
elif method == 'mix3':
r = random.random()
if r < 0.02:
size = N-int(random.gammavariate(2,0.1)*N/15)%N
else:
size = int(random.gammavariate(2,0.2)*N/15+_min-1)%N+1
elif method == 'mix4':
r = random.random()
if r < 0.02:
size = N-int(random.gammavariate(1,0.1)*N/15)%N
elif r >= 0.02 and r < 0.42:
size = random.randint(_min, N)
else:
size = int(random.gammavariate(2,0.2)*N/15+_min-1)%N+1
else: # uniform distribution
size = random.randint(_min,N)
size = max(size, _min)
return size
UserNum = 200
GroupNum = 1000
groupSize = [0]*GroupNum
for i in range(GroupNum):
groupSize[i] = randomSample(UserNum, 'mix3', 5)
#groupSize[i] = float(groupSize[i]-5)/float(UserNum-5)
plt.figure(0)
groupsize = groupsize['members']
ccdf_groupSize = CCDF(groupSize, 10000)
ccdf_hosts = CDF(groupsize, 50000)
plt.figure(1)
ax1 = plt.subplot(211)
#plt.title('Histogram of group size distribution')
plt.hist(groupSize, bins = UserNum-4, normed=True, facecolor='black')
plt.ylabel('frequency',size=11)
plt.xlabel('Group size (a sample tenant with 200 VMs)',size=11)
plt.yticks([0,0.05,0.1,0.15])
#plt.xlabel('(group size - min size) / (tenant size - min size)')
#plt.grid('on')
ax2 = ax1.twinx()
ax2.plot(ccdf_groupSize[0],ccdf_groupSize[1],'b-')
ax2.set_ylabel('CCDF',color='b',size=11)
for tl in ax2.get_yticklabels():
tl.set_color('b')
ax2.set_yscale('log')
#ax2.set_ylim(0.001,1)
#ax2.set_yticks([0.01,0.1,1])
ax2.set_xlim(0,UserNum+10)
#ax2.set_xticks([])
#plt.xticks([0, UserNum/5, UserNum*2/5, UserNum*3/5, UserNum*4/5, UserNum],
# [0,0.2,0.4,0.6,0.8,1])
ax3 = plt.subplot(212)
p1, = plt.plot(ccdf_hosts[0], ccdf_hosts[1])
label1 = StatLabel(groupsize)
#plt.legend([p1], [label1], bbox_to_anchor=(1,0), loc=4, prop={'size':9})
plt.figtext(0.60, 0.18, label1,
backgroundcolor='white', color='black', weight='roman', size=10)
plt.xlabel('Group size (all tenants)',size=11)
plt.xscale('log')
plt.ylabel('CDF',size=11)
plt.xlim(4,10000)
plt.xticks([4,5,6,7,8,9,10,20,30,40,50,60,70,80,90,100,200,300,400,500,600,700,800,900,1000,2000,3000,4000,5000,6000,7000,8000,9000,10000])
#plt.yscale('log')
plt.ylim(0,1)
#plt.grid('on')
ax3.xaxis.grid(True, linestyle='-', which='major', color='lightgrey')
ax3.yaxis.grid(True, linestyle='-', which='major', color='lightgrey')
plt.show()
#!/usr/bin/python
import matplotlib.pyplot as plt
from utils import *
plt.rc('pdf',fonttype = 42)
plt.rc('ps',fonttype = 42)
capacity = [100, 500, 1000, 2000, 3000, 4000, 5000, 6000]
collocate_wve_la = [10.1, 51, 101, 198, 305, 390, 505, 602]
collocate_rand_la = [10.4, 49, 100, 190, 298, 399, 501, 607]
spread_wve_la = [3.2, 16.5, 31, 65, 97, 128, 157, 195]
spread_rand_la = [0.95, 1.9, 9.8, 19, 28.7, 37, 47.1, 56]
collocate_wve = [3.07, 16.1, 31, 62, 87, 122.2, 153.8, 184]
collocate_rand = [1.54, 7.7, 15.6, 32, 47, 62, 78, 94]
spread_wve = [2.3, 4.6, 23.8, 47.7, 71, 95.2, 117, 142]
spread_rand = [0.4, 1.97, 3.94, 7.9, 11.8, 15.6, 20.1, 23.6]
plt.figure(1)
ax1 = plt.subplot(111)
p1, = plt.plot(capacity, collocate_wve_la, '-o', color='blue')
p2, = plt.plot(capacity, collocate_wve, '-.o', color='blue')
p1.set_markeredgecolor('blue')
p1.set_markerfacecolor('white')
p2.set_markeredgecolor('blue')
p2.set_markerfacecolor('white')
p3, = plt.plot(capacity, collocate_rand_la, '-^', color='red')
p4, = plt.plot(capacity, collocate_rand, '-.^', color='red')
p3.set_markeredgecolor('red')
p3.set_markerfacecolor('white')
p4.set_markeredgecolor('red')
p4.set_markerfacecolor('white')
p5, = plt.plot(capacity, spread_wve_la, '-s', color='green')
p6, = plt.plot(capacity, spread_wve, '-.s', color='green')
p5.set_markeredgecolor('green')
p5.set_markerfacecolor('white')
p6.set_markeredgecolor('green')
p6.set_markerfacecolor('white')
p7, = plt.plot(capacity, spread_rand_la, '-*', color='black')
p8, = plt.plot(capacity, spread_rand, '-.*', color='black')
label1 = 'Near, WVE, la'
label2 = 'Near, WVE'
label3 = 'Near, U, la'
label4 = 'Near, U'
label5 = 'Rand, WVE, la'
label6 = 'Rand, WVE'
label7 = 'Rand, U, la'
label8 = 'Rand, U'
l1 = plt.legend([p3,p4,p7,p8], \
[label3, label4, label7, label8], \
bbox_to_anchor=(0,1), loc=2, prop={'size':9}, numpoints=1, markerscale=0.8)
l1.set_frame_on(False)
l2 = plt.legend([p1,p2,p5,p6], \
[label1, label2, label5, label6], \
bbox_to_anchor=(1,1), loc=1, prop={'size':9}, numpoints=1, markerscale=0.8)
l2.set_frame_on(False)
plt.gca().add_artist(l1) # add l1 as a separate artist to the axes
plt.tick_params(labelsize=11)
plt.xlabel('Multicast address capacity on a switch', size=11)
plt.ylabel('Number of groups',size=11)
plt.xlim(0,6300)
plt.ylim(-10,320)
plt.yticks(range(0,301,50),[0,'50K','100K','150K','200K','250K','300K'], size=11)
plt.show()
#!/usr/bin/python
import matplotlib.pyplot as plt
from utils import *
from output.out import *
coreLinks = []
podLinks = []
edgeLinks = []
coreSwitches = []
aggrSwitches = []
edgeSwitches = []
distribution = ''
for link in links.keys():
if link.find('C') == 0:
coreLinks.append(links[link])
elif link.find('A') == 0:
podLinks.append(links[link])
elif link.find('E') == 0:
edgeLinks.append(links[link])
else:
print link
for switch in switches.keys():
if switch.find('C') == 0:
coreSwitches.append(switches[switch])
if switch.find('A') == 0:
aggrSwitches.append(switches[switch])
if switch.find('E') == 0:
edgeSwitches.append(switches[switch])
groupHosts = []
for host in hosts.keys():
groupHosts.append(hosts[host])
plt.figure(0)
ccdf_hosts = CDF(groupSize['members'], 1000)
ccdf_pods = CDF(groupSize['pods'], 1000)
ccdf_edges = CDF(groupSize['edges'], 1000)
ccdf_group_hosts = CDF(groupHosts, 1000)
ccdf_addr_core = CCDF(coreSwitches, 1000)
ccdf_addr_aggr = CCDF(aggrSwitches, 1000)
ccdf_addr_edge = CCDF(edgeSwitches, 1000)
ccdf_link_core = CCDF(coreLinks, 100)
ccdf_link_aggr = CCDF(podLinks, 1000)
ccdf_link_edge = CCDF(edgeLinks, 1000)
plt.figure(1)
#plt.suptitle('CDF of group size and distribution')
plt.subplots_adjust(hspace=0.5)
plt.subplot(411)
p1, = plt.plot(ccdf_hosts[0], ccdf_hosts[1])
label1 = distribution+StatLabel(groupSize['members'])
plt.legend([p1], [label1], bbox_to_anchor=(1,0), loc=4, prop={'size':10})
plt.xlabel('number of hosts per group')
plt.xscale('log')
#plt.yscale('log')
plt.ylim(0,1)
plt.grid('on')
plt.subplot(412)
p1, = plt.plot(ccdf_pods[0], ccdf_pods[1])
label1 = distribution+StatLabel(groupSize['pods'])
plt.legend([p1], [label1], bbox_to_anchor=(1,0), loc=4, prop={'size':10})
plt.xlabel('number of pods per group')
plt.ylim(0,1)
plt.grid('on')
plt.subplot(413)
p1, = plt.plot(ccdf_edges[0], ccdf_edges[1])
label1 = distribution+StatLabel(groupSize['edges'])
plt.legend([p1], [label1], bbox_to_anchor=(1,0), loc=4, prop={'size':10})
plt.xlabel('number of edge switches per pod per group')
plt.ylim(0,1)
plt.grid('on')
plt.subplot(414)
p1, = plt.plot(ccdf_group_hosts[0], ccdf_group_hosts[1])
label1 = StatLabel(groupHosts)
plt.legend([p1], [label1], bbox_to_anchor=(1,0), loc=4, prop={'size':10})
plt.xlabel('number of groups per host')
#plt.yscale('log')
plt.ylim(0,1)
plt.grid('on')
plt.figure(2)
#plt.suptitle('CCDF of multicast addresses on switches')
ax1 = plt.subplot(211)
p1, = plt.plot(ccdf_addr_core[0], ccdf_addr_core[1], 'b-')
p2, = plt.plot(ccdf_addr_aggr[0], ccdf_addr_aggr[1], 'g-')
p3, = plt.plot(ccdf_addr_edge[0], ccdf_addr_edge[1], 'r-')
label1 = 'core '+StatLabel(coreSwitches)
label2 = 'aggr '+StatLabel(aggrSwitches)
label3 = 'edge '+StatLabel(edgeSwitches)
plt.legend([p1,p2,p3], [label1, label2, label3], \
bbox_to_anchor=(1,1), loc=1, prop={'size':8})
plt.ylim(0,1)
plt.grid('on')
ax2 = plt.subplot(212, sharex=ax1)
p1, = plt.plot(ccdf_addr_core[0], ccdf_addr_core[1], 'b-')
p2, = plt.plot(ccdf_addr_aggr[0], ccdf_addr_aggr[1], 'g-')
p3, = plt.plot(ccdf_addr_edge[0], ccdf_addr_edge[1], 'r-')
plt.xlabel('number of group addresses on a switch')
plt.yscale('log')
plt.ylim(0,1)
plt.grid('on')
plt.setp(ax1.get_xticklabels(), visible=False)
plt.figure(3)
#plt.suptitle('CCDF of traffic rate on links')
ax1 = plt.subplot(211)
p1, = plt.plot(ccdf_link_core[0], ccdf_link_core[1], 'b-')
p2, = plt.plot(ccdf_link_aggr[0], ccdf_link_aggr[1], 'g-')
p3, = plt.plot(ccdf_link_edge[0], ccdf_link_edge[1], 'r-')
label1 = 'core-aggr '+StatLabel(coreLinks)
label2 = 'aggr-edge '+StatLabel(podLinks)
label3 = 'edge-host '+StatLabel(edgeLinks)
plt.legend([p1,p2,p3], [label1, label2, label3], \
bbox_to_anchor=(1,1), loc=1, prop={'size':8})
plt.ylim(0,1)
plt.grid('on')
ax2 = plt.subplot(212, sharex=ax1)
p1, = plt.plot(ccdf_link_core[0], ccdf_link_core[1], 'b-')
p2, = plt.plot(ccdf_link_aggr[0], ccdf_link_aggr[1], 'g-')
p3, = plt.plot(ccdf_link_edge[0], ccdf_link_edge[1], 'r-')
plt.xlabel('traffic rate on a link')
plt.yscale('log')
plt.ylim(0,1)
plt.grid('on')
plt.setp(ax1.get_xticklabels(), visible=False)
plt.show()
#!/usr/bin/python
import matplotlib.pyplot as plt
from utils import *
from output.out import *
coreLinks = []
podLinks = []
edgeLinks = []
coreSwitches = []
aggrSwitches = []
edgeSwitches = []
aggrMcast = []
edgeMcast = []
distribution = ''
for link in links.keys():
if link.find('C') == 0:
coreLinks.append(links[link])
elif link.find('A') == 0:
podLinks.append(links[link])
elif link.find('E') == 0:
edgeLinks.append(links[link])
else:
print link
for switch in switches.keys():
if switch.find('C') == 0:
coreSwitches.append(switches[switch])
if switch.find('A') == 0:
aggrSwitches.append(switches[switch])
aggrMcast.append(switches[switch]-unicast[switch])
if switch.find('E') == 0:
edgeSwitches.append(switches[switch])
edgeMcast.append(switches[switch]-unicast[switch])
groupHosts = []
for host in hosts.keys():
groupHosts.append(hosts[host])
plt.figure(0)
ccdf_hosts = CDF(groupSize['members'], 50000)
ccdf_pods = CDF(groupSize['pods'], 1000)
ccdf_edges = CDF(groupSize['edges'], 1000)
ccdf_group_hosts = CDF(groupHosts, 1000)
ccdf_addr_core = CDF(coreSwitches, 1000)
ccdf_addr_aggr = CDF(aggrSwitches, 1000)
ccdf_addr_edge = CDF(edgeSwitches, 1000)
ccdf_addr_amcast = CDF(aggrMcast, 1000)
ccdf_addr_emcast = CDF(edgeMcast, 1000)
ccdf_link_core = CDF(coreLinks, 100)
ccdf_link_aggr = CDF(podLinks, 1000)
ccdf_link_edge = CDF(edgeLinks, 1000)
plt.figure(1)
#plt.suptitle('CDF of group size and distribution')
plt.subplots_adjust(hspace=0.5)
'''
plt.subplot(311)
p1, = plt.plot(ccdf_pods[0], ccdf_pods[1])
label1 = distribution+StatLabel(groupSize['pods'])
plt.legend([p1], [label1], bbox_to_anchor=(0,1), loc=3, prop={'size':9}, borderaxespad=0.)
plt.xlabel('number of pods per group')
plt.ylim(0,1)
plt.grid('on')
'''
plt.subplot(211)
p1, = plt.plot(ccdf_edges[0], ccdf_edges[1])
label1 = distribution+StatLabel(groupSize['edges'])
plt.legend([p1], [label1], bbox_to_anchor=(0,1), loc=3, prop={'size':9}, borderaxespad=0.)
plt.xlabel('number of edge switches per pod per group')
plt.ylim(0,1)
plt.grid('on')
plt.subplot(212)
p1, = plt.plot(ccdf_hosts[0], ccdf_hosts[1])
label1 = distribution+StatLabel(groupSize['members'])
plt.legend([p1], [label1], bbox_to_anchor=(0,1), loc=3, prop={'size':10}, borderaxespad=0.)
plt.xlabel('number of hosts per group')
plt.xscale('log')
plt.xticks([1,2,3,4,5,6,7,8,9,10,20,30,40,50,60,70,80,90,100,200,300,400,500,600,700,800,900,1000,2000,3000,4000,5000,6000,7000,8000,9000,10000])
plt.ylim(0,1)
plt.grid('on')
plt.figure(2)
#plt.suptitle('CCDF of multicast addresses on switches')
#ax1 = plt.subplot(211)
p1, = plt.plot(ccdf_addr_core[0], ccdf_addr_core[1], 'b-')
p2, = plt.plot(ccdf_addr_aggr[0], ccdf_addr_aggr[1], 'g-')
p3, = plt.plot(ccdf_addr_edge[0], ccdf_addr_edge[1], 'r-')
p4, = plt.plot(ccdf_addr_amcast[0], ccdf_addr_amcast[1], 'g--')
p5, = plt.plot(ccdf_addr_emcast[0], ccdf_addr_emcast[1], 'r--')
label1 = 'core '+StatLabel(coreSwitches)
label2 = 'aggr '+StatLabel(aggrSwitches)
label3 = 'edge '+StatLabel(edgeSwitches)
label4 = 'amcast '+StatLabel(aggrMcast)
label5 = 'emcast '+StatLabel(edgeMcast)
plt.legend([p1,p2,p3,p4,p5], [label1, label2, label3, label4, label5], \
bbox_to_anchor=(1,0), loc=4, prop={'size':8})
plt.ylim(0,1)
plt.xlabel('number of group addresses on a switch')
plt.grid('on')
'''
ax2 = plt.subplot(212, sharex=ax1)
p1, = plt.plot(ccdf_addr_core[0], ccdf_addr_core[1], 'b-')
p2, = plt.plot(ccdf_addr_aggr[0], ccdf_addr_aggr[1], 'g-')
p3, = plt.plot(ccdf_addr_edge[0], ccdf_addr_edge[1], 'r-')
plt.xlabel('number of group addresses on a switch')
plt.yscale('log')
plt.ylim(0,1)
plt.grid('on')
plt.setp(ax1.get_xticklabels(), visible=False)
#plt.figure(3)
#plt.suptitle('CCDF of traffic rate on links')
ax2 = plt.subplot(212)
p1, = plt.plot(ccdf_link_core[0], ccdf_link_core[1], 'b-')
p2, = plt.plot(ccdf_link_aggr[0], ccdf_link_aggr[1], 'g-')
p3, = plt.plot(ccdf_link_edge[0], ccdf_link_edge[1], 'r-')
label1 = 'core-aggr '+StatLabel(coreLinks)
label2 = 'aggr-edge '+StatLabel(podLinks)
label3 = 'edge-host '+StatLabel(edgeLinks)
plt.legend([p1,p2,p3], [label1, label2, label3], \
bbox_to_anchor=(1,0), loc=4, prop={'size':8})
plt.ylim(0,1)
plt.xlabel('traffic rate on a link')
plt.grid('on')
ax2 = plt.subplot(212, sharex=ax1)
p1, = plt.plot(ccdf_link_core[0], ccdf_link_core[1], 'b-')
p2, = plt.plot(ccdf_link_aggr[0], ccdf_link_aggr[1], 'g-')
p3, = plt.plot(ccdf_link_edge[0], ccdf_link_edge[1], 'r-')
plt.xlabel('traffic rate on a link')
plt.yscale('log')
plt.ylim(0,1)
plt.grid('on')
plt.setp(ax1.get_xticklabels(), visible=False)
'''
plt.show()
#!/usr/bin/python
import matplotlib.pyplot as plt
from utils import *
from output.tenant import *
tenantsLen = []
for i in range(len(tenants)):
tenantsLen.append(len(tenants[i]))
hostTenants = []
for host in hosts.keys():
hostTenants.append(len(hosts[host]))
plt.figure(0)
cdf_tenants = CDF(tenantsLen, 1000)
cdf_hosts = CDF(hostTenants, 1000)
plt.figure(1)
plt.subplots_adjust(hspace=0.3)
plt.subplot(211)
#plt.title('CDF of tenant size distribution')
p1, = plt.plot(cdf_tenants[0], cdf_tenants[1])
label1 = StatLabel(tenantsLen)
plt.legend([p1], [label1], bbox_to_anchor=(1,0), loc=4, prop={'size':9})
plt.xlabel('number of hosts per tenant')
#plt.xscale('log')
plt.ylim(0,1)
plt.grid('on')
plt.subplot(212)
#plt.title('CDF of number of tenants per host')
p1, = plt.plot(cdf_hosts[0], cdf_hosts[1])
label1 = StatLabel(hostTenants)
plt.legend([p1], [label1], bbox_to_anchor=(0,1), loc=2, prop={'size':9})
plt.xlabel('number of tenants per host')
plt.ylim(0,1)
#plt.xlim(0,9)
plt.grid('on')
plt.show()
#!/usr/bin/python
from utils import *
from output.out import *
coreS = []
aggrS = []
edgeS = []
aggrM = []
edgeM = []
for switch in switches.keys():
if switch.find('C') == 0:
coreS.append(switches[switch])
if switch.find('A') == 0:
aggrS.append(switches[switch])
aggrM.append(switches[switch]-unicast[switch])
if switch.find('E') == 0:
edgeS.append(switches[switch])
edgeM.append(switches[switch]-unicast[switch])
print 'core: ', max(coreS)
print 'aggr: ', max(aggrS), max(aggrM)
print 'edge: ', max(edgeS), max(edgeM)
import matplotlib.pyplot as plt
import numpy as np
def CDF(array, bins):
n, bins, patches = plt.hist(array, bins, normed=True, cumulative=1, histtype='step')
x = list(bins)
y = list(n)
y[0] = 0
y.append(1)
return [x, y]
def CCDF(array, bins):
n, bins, patches = plt.hist(array, bins, normed=True, cumulative=-1, histtype='step')
x = list(bins)
y = list(n)
y.append(0)
return [x, y]
def StatLabel_(array):
label = '(min=%d, max=%d, median=%.1f, mean=%.1f, std=%.1f)'%\
(min(array), max(array), np.median(array), np.mean(array), np.std(array))
return label
def StatLabel(array):
label = 'min=%d, max=%d\nmedian=%d, mean=%.1f'%\
(min(array), max(array), np.median(array), np.mean(array))
return label
def histPlot(x, bins, xlabel, ylabel):
plt.hist(x, bins)
plt.xlabel(xlabel+' (median = %.1f, mean = %.1f)'%(median(x), mean(x)))
plt.ylabel(ylabel)
plt.show()
#!/usr/bin/python
from network import *
from multicast import *
import matplotlib.pyplot as plt
def writeOutput(network, G, aggrGroupEdges):
outFile = open('plot/output/out.py', 'w')
outFile.write('links = ' + str(network.links)+'\n\n' \
+ 'switches = ' + str(network.switches)+'\n\n' \
+ 'groupSize = ' + str(G.groupSize())+'\n\n' \
+ 'hosts = ' +str(network.hosts['groups']))
if len(aggrGroupEdges) > 0:
aggrFile = open('plot/output/aggregateAggrs.py', 'w')
aggrFile.write('aggrSwitches = '+str(network.aggrs) +'\n\n' \
+ 'aggrLinks = '+str(network.aggrlinks))
def writeTenant(network, tenants):
tenantFile = open('plot/output/tenant.py', 'w')
tenantFile.write('tenants = '+ str(tenants)+'\n\n' \
+ 'hosts = '+ str(network.hosts['tenants']))
k = 48
n = 64
r = 9
pa = 3
pb = 3
C = 1000 # multicast capacity
N = 30000 # group number
network = ABFatTree(k)
distribution = AddressDistribution(k, n, r, pa, pb)
#tenants = Tenants_x(network, 80, 1000,'c')
tenants = Tenants_(network, 500, 100, 5000, 'r')
writeTenant(network, tenants)
G = Groups(k, n, N, tenants, network)
aggrGroupEdges = doAggregate(k, G, network, distribution, C, pa, pb, 'a')
Trees = GenerateTrees(N, G, network, distribution, aggrGroupEdges)
writeOutput(network, G, aggrGroupEdges)
#!/usr/bin/python
import random
from aggregate import *
import matplotlib.pyplot as plt
portNum = 24
groupNum = 3000
metaNum = 1000
def initialize(portNum, groupNum, metaNum):
P = [0]*portNum
G = [0]*groupNum
M = [0]*metaNum
G_unassigned = set(range(groupNum)) # groups which are not assigned to meta-groups
M_empty = set(range(portNum, metaNum-1)) # meta-groups which have no group
for i in range(portNum):
P[i] = Port(i)
for i in range(groupNum):
ports = randomSample(range(portNum), 'expo')
rate = random.randint(1, 10)
G[i] = Group(i, i, ports, rate, P)
for i in range(metaNum):
M[i] = MetaGroup(i)
return [P, G, M, G_unassigned, M_empty]
def simpleAggregation(P, G, M, G_unassigned, M_empty, th_B):
count = 0
while len(G_unassigned) > 0:
Aggregate(G[G_unassigned.pop()], M, G, P, M_empty, th_B)
count += 1
if count %1000 == 0:
print 'aggregated %d groups'%count
def deAggregateAll(P, G, M, G_unassigned, M_empty):
for i in range(len(G)):
if i not in G_unassigned:
Remove(G[i], M[G[i].meta], P, G, M_empty)
G_unassigned.add(i)
if (i+1) %1000 == 0:
print 'de-aggregated %d groups'%(i+1)
def reAggregateAll(P, G, M, G_unassigned, M_empty):
for i in range(len(M)):
if i not in M_empty:
reAggregate(M[i], G, P, M, M_empty)
def groupDynamic(group, P, G, M, M_empty):
ports_in = group.ports
ports_out = set(range(len(P))) - group.ports
join = True
leave = False
if (random.random() < 0.5 and len(ports_out) != 0) or len(ports_in) == 1:
action = join
ports = set(random.sample(ports_out, 1))
else:
action = leave
ports = set(random.sample(ports_in, 1))
if action == join:
Join(ports, group, M[group.meta], P, G)
if action == leave:
Leave(ports, group, M[group.meta], P, G)
#reAggregate(M[group.meta], G, P, M, M_empty)
def main():
init = initialize(portNum, groupNum, metaNum)
P = init[0]
G = init[1]
M = init[2]
G_unassigned = init[3]
M_empty = init[4]
simpleAggregation(P, G, M, G_unassigned, M_empty, portNum)
Print(['s'], P, G, M)
'''
for i in range(groupNum):
groupDynamic(G[i], P, G, M, M_empty)
if (i+1) %100 == 0:
print 'dynamic %d groups'%(i+1)
Print(['s'], P, G, M)
for i in range(10):
reAggregateAll(P, G, M, G_unassigned, M_empty)
Print(['s'], P, G, M)
'''
def Print(args, P, G, M):
if 'group' in args or 'g' in args:
for i in range(groupNum):
printGroup(G[i])
print ''
if 'meta' in args or 'm' in args:
for i in range(metaNum):
printMeta(M[i])
print ''
if 'port' in args or 'p' in args:
for i in range(portNum):
printPort(P[i])
print ''
if 'stat' in args or 's' in args:
totalCost = TotalCost(P)
print 'total cost: ', totalCost[0]
print 'effective cost: ', totalCost[1]
effective = 0
extra = 0
duplicate = 0
for i in range(len(M)):
effective += M[i].metaRate[0]
duplicate += M[i].metaRate[1]
extra += M[i].metaRate[2]
if duplicate == 0:
print 'meta rate: [%d, %d, %d]'%(effective, duplicate, extra)
else:
print 'meta rate: [%d, %d, %d, %.2f]'%(effective, duplicate, extra, extra/float(duplicate))
extra_send = []
extra_recv = []
group_rate = []
for i in range(len(G)):
group_rate.append(G[i].groupRate[0])
extra_send.append(G[i].groupRate[2])
extra_recv.append(G[i].groupRate[3])
print 'group total rate [min, max, mean, median]: [%d, %d, %.2f, %.1f]'\
%(min(group_rate), max(group_rate), mean(group_rate), median(group_rate))
print 'group extra_send [min, max, mean, median]: [%d, %d, %.2f, %.1f]'\
%(min(extra_send), max(extra_send), mean(extra_send), median(extra_send))
print 'group extra_recv [min, max, mean, median]: [%d, %d, %.2f, %.1f]'\
%(min(extra_recv), max(extra_recv), mean(extra_recv), median(extra_recv))
def Plot(P, G, M):
linkEffective = []
linkRate = []
if __name__ == "__main__":
main()
#!/usr/bin/python
from network import *
from multicast import *
import matplotlib.pyplot as plt
def mean(array):
return sum(array)/float(len(array))
def median(array):
values = sorted(array)
if len(values) % 2 == 1:
return values[(len(values)+1)/2-1]
else:
lower = values[len(values)/2-1]
upper = values[len(values)/2]
return (float(lower + upper)) / 2
#linkFile = open('trace/links.py', 'w')
#switchFile = open('trace/switches.py', 'w')
#groupFile = open('trace/groupSize.py', 'w')
k = 48
n = 64
r = 9
pa = 3
pb = 3
c = 2000 # multicast capacity
N = 10000 # group number
network = ABFatTree(k)
distribution = AddressDistribution(k, n, r, pa, pb)
tenants = Tenants_x(network, 80, 1000,'random')
#tenants = Tenants(network, 300, 100, 5000, 'random')
G = Groups(k, n, N, tenants, network)
groupSize = {}
groupSize['pods'] = [0]*N
groupSize['edges'] = []
groupSize['members'] = [0]*N
for i in range(N):
groupSize['pods'][i] = len(G.groups[i].members.keys())
for pod in G.groups[i].members.keys():
groupSize['edges'].append(len(G.groups[i].members[pod].keys()))
groupSize['members'][i] = G.groups[i].size
'''
index = 2
#print tenants[219]
print ''
print 'id: ', G.groups[index].id
print 'block: ', G.groups[index].block
print 'rate: ', G.groups[index].rate
print 'tenant:', G.groups[index].tenant
print 'member:', G.groups[index].members
print 'hosts: ', G.groups[index].hosts
print 'size: ', G.groups[index].size
'''
update = {}
update['cores_J'] = []
update['aggrs_J'] = []
update['cores_L'] = []
update['aggrs_L'] = []
M = 200
updates = [0]*N
for i in range(N):
if i%10 == 0:
print 'dynamic %d'%i
updates[i]={}
updates[i]['cores_J'] = 0
updates[i]['aggrs_J'] = 0
updates[i]['edges_J'] = 0
updates[i]['cores_L'] = 0
updates[i]['aggrs_L'] = 0
updates[i]['edges_L'] = 0
for j in range(M):
Dynamic(G.groups[i], tenants, network, updates[i])
update['cores_J'].append(updates[i]['cores_J']/float(updates[i]['edges_J']))
update['aggrs_J'].append(updates[i]['aggrs_J']/float(updates[i]['edges_J']))
update['cores_L'].append(updates[i]['cores_L']/float(updates[i]['edges_L']))
update['aggrs_L'].append(updates[i]['aggrs_L']/float(updates[i]['edges_L']))
updateFile = open('plot/updates.py', 'w')
updateFile.write('updates = '+str(update))
print mean(update['cores_J'])
print mean(update['aggrs_J'])
print mean(update['cores_L'])
print mean(update['aggrs_L'])
'''
tenantsLen = []
total = 0
print len(tenants)
for i in range(len(tenants)):
tenantsLen.append(len(tenants[i]))
total += len(tenants[i])
#print '----'
print len(tenants[i])
#print tenants[i]
print total
#tenantsGroup = [0]*len(tenants)
#for i in range(N):
# tenantsGroup[G.groups[i].tenant] += 1
#print tenantsGroup
plt.hist(tenantsLen,50)
plt.suptitle('Example of tenant size distribution of setting 1&2')
plt.xlabel('number of hosts per tenant (median = %.1f, mean = %.1f)'%(median(tenantsLen),mean(tenantsLen)))
plt.ylabel('number of tenants')
plt.show()
Trees = [0]*N
for i in range(N):
if i%1000 == 0:
print 'create tree %d'%i
Trees[i] = multicastTree_simple(G.groups[i], network, distribution)
linkFile.write('links = '+str(network.links))
switchFile.write('switches = '+str(network.switches))
groupFile.write('groupSize = '+str(groupSize))
'''
#!/usr/bin/python
from network import *
from multicast import *
import matplotlib.pyplot as plt
def mean(array):
return sum(array)/float(len(array))
def median(array):
values = sorted(array)
if len(values) % 2 == 1:
return values[(len(values)+1)/2-1]
else:
lower = values[len(values)/2-1]
upper = values[len(values)/2]
return (float(lower + upper)) / 2
#linkFile = open('trace/links.py', 'w')
#switchFile = open('trace/switches.py', 'w')
#groupFile = open('trace/groupSize.py', 'w')
k = 48
n = 64
r = 9
pa = 3
pb = 3
c = 1000 # multicast capacity
N = 10000 # group number
network = ABFatTree(k)
distribution = AddressDistribution(k, n, r, pa, pb)
#tenants = Tenants_x(network, 80, 1000,'random')
tenants = Tenants_(network, 3000, 10, 5000, 'c')
G = Groups(k, n, N, tenants, network)
groupSize = {}
groupSize['pods'] = [0]*N
groupSize['edges'] = []
groupSize['members'] = [0]*N
for i in range(N):
groupSize['pods'][i] = len(G.groups[i].members.keys())
for pod in G.groups[i].members.keys():
groupSize['edges'].append(len(G.groups[i].members[pod].keys()))
groupSize['members'][i] = G.groups[i].size
'''
index = 2
#print tenants[219]
print ''
print 'id: ', G.groups[index].id
print 'block: ', G.groups[index].block
print 'rate: ', G.groups[index].rate
print 'tenant:', G.groups[index].tenant
print 'member:', G.groups[index].members
print 'hosts: ', G.groups[index].hosts
print 'size: ', G.groups[index].size
'''
update = {}
update['cores_J'] = []
update['aggrs_J'] = []
update['cores_L'] = []
update['aggrs_L'] = []
M = 200
updates = [0]*N
for i in range(N):
if i%10 == 0:
print 'dynamic %d'%i
updates[i]={}
updates[i]['cores_J'] = 0
updates[i]['aggrs_J'] = 0
updates[i]['edges_J'] = 0
updates[i]['cores_L'] = 0
updates[i]['aggrs_L'] = 0
updates[i]['edges_L'] = 0
for j in range(M):
Dynamic(G.groups[i], tenants, network, updates[i])
update['cores_J'].append(updates[i]['cores_J']/float(updates[i]['edges_J']))
update['aggrs_J'].append(updates[i]['aggrs_J']/float(updates[i]['edges_J']))
update['cores_L'].append(updates[i]['cores_L']/float(updates[i]['edges_L']))
update['aggrs_L'].append(updates[i]['aggrs_L']/float(updates[i]['edges_L']))
updateFile = open('plot/update/updates.py', 'w')
updateFile.write('updates = '+str(update))
print mean(update['cores_J'])
print mean(update['aggrs_J'])
print mean(update['cores_L'])
print mean(update['aggrs_L'])
'''
tenantsLen = []
total = 0
print len(tenants)
for i in range(len(tenants)):
tenantsLen.append(len(tenants[i]))
total += len(tenants[i])
#print '----'
print len(tenants[i])
#print tenants[i]
print total
#tenantsGroup = [0]*len(tenants)
#for i in range(N):
# tenantsGroup[G.groups[i].tenant] += 1
#print tenantsGroup
plt.hist(tenantsLen,50)
plt.suptitle('Example of tenant size distribution of setting 1&2')
plt.xlabel('number of hosts per tenant (median = %.1f, mean = %.1f)'%(median(tenantsLen),mean(tenantsLen)))
plt.ylabel('number of tenants')
plt.show()
Trees = [0]*N
for i in range(N):
if i%1000 == 0:
print 'create tree %d'%i
Trees[i] = multicastTree_simple(G.groups[i], network, distribution)
linkFile.write('links = '+str(network.links))
switchFile.write('switches = '+str(network.switches))
groupFile.write('groupSize = '+str(groupSize))
'''
#!/usr/bin/python
import random
from network import *
from multicast import *
k = 48
n = 64
r = 9
pa = 3
pb = 3
C = 1000 # multicast capacity
N = 30000 # group number
network = ABFatTree(k)
distribution = AddressDistribution(k, n, r, pa, pb)
#tenants = Tenants_x(network, 80, 1000,'c')
tenants = Tenants_(network, 3000, 10, 5000, 'r')
failed_switchess = set()
switches =set()
for p in range(k):
for a in range(k/2):
switches.add('A%d.%d'%(p,a))
M = 4
T = 10
failed_switches = [0]*M
for i in range(M):
failed_switches[i] = []
for i in range(T):
failed_switches[0].append(set(random.sample(switches, 10)))
failed_switches[1].append(set(random.sample(switches, 50)))
failed_switches[2].append(set(random.sample(switches, 100)))
failed_switches[3].append(set(random.sample(switches, 200)))
G = Groups(k, n, N, tenants, network)
route = [0]*M
stretch = [0]*M
unreachable = [0]*M
unreachable_r = [0]*M
for j in range(M):
route[j] = []
stretch[j] = []
unreachable[j] = []
unreachable_r[j] = []
for i in range(N):
if i%1000 == 0:
print 'compute stretch for group %d'%i
for j in range(M):
for t in range(T):
route[j].append(multicast_failover(G.groups[i], network, distribution, failed_switches[j][t], pa, pb))
for i in range(N):
for j in range(M):
if route[j][i][0] > 0:
stretch[j].append(route[j][i][0])
unreachable_r[j].append(route[j][i][1])
unreachable[j].append(route[j][i][2])
outFile = open('plot/output/failover.py', 'w')
outFile.write('stretch = ' + str(stretch) + '\n\n' \
+ 'unreachable_r = ' + str(unreachable_r) + '\n\n' \
+ 'unreachable = ' + str(unreachable))
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment