datacenter_mptcp.py 2.02 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
# This file modifies the 3-tier data center topology
# in order for the hosts to have multiple interfaces towards
# ToR switches making MP-TCP working
from mininet.topo import Topo
from mininet.net import Mininet
from mininet.link import TCLink
from mininet.log import setLogLevel
from mininet.node import CPULimitedHost
from mininet.node import Controller
from mininet.nodelib import NAT

class MyTopo( Topo ):
    "Simple topology example."

    def __init__( self, core=2, aggregation=4, edge=8, h=1, **opts):
        "Create custom topo."
	Core= [core]
	Aggr= [aggregation]
	Edge=[edge]
	self.Host=[edge*h]

	"Topo.__init__(self)"
	super(MyTopo, self).__init__(**opts)

        # Add hosts and switches
	"Creating Core Switches"
        for i in range(core):
                Core.append(self.addSwitch('s%s' % i))
		print(Core[i+1])		

	"Creating Aggregation Switches"
	for i in range(aggregation):
                Aggr.append(self.addSwitch('s%s' % (i+core)))

	"Creating Edge Switches"
        for i in range(edge):
                Edge.append(self.addSwitch('s%s' % (i+core+aggregation)))

	"Creating Hosts"
        for i in range (h*edge):
                self.Host.append(self.addHost('h%s' % i)) 

	

        # Add links
	"Links between Core and Aggregation Switches: All connected"
        for i in range (core):
                for j in range (aggregation):
                        self.addLink( Core[i+1], Aggr[j+1], bw=10000)			

	"""LInks between Aggregation and Edge Switches: We make groups depending on 
	the number of core switches"""
	n=0
	m=0
	for k in range (core):
		for i in range(n,aggregation/core+n):
			for j in range (m, edge/core+m):
				self.addLink(Aggr[i+1], Edge[j+1], bw=1000)
		n=n+aggregation/core
		m=m+edge/core
	
	n=0
	m=0
	"""Links between Edge Switches and hosts: h hosts for each Switch"""
	for k in range (core):
		for i in range(n,edge/core+n):
			for j in range (m, edge*h/core+m):
				self.addLink(Edge[i+1], self.Host[j+1], bw=1000)
		n=n+edge/core
		m=m+edge*h/core

topos = { 'mytopo': MyTopo }
print("Ha terminado")