Example #1
0
def _create_host(experiment, host):
    logger.debug("creating host for experiment={}, host={}, pos={}".format(
        experiment, host['name'], host['pos']))
    exp = experiments[experiment]
    host_id = len(exp.hosts) + 1
    hst = exp.addHost(host['name'],
                      ip=Tools.makeIP(host_id),
                      max=Tools.makeMAC(host_id),
                      pos=host['pos'])
    return hst
    def create_switch(self):
        switch_name = 's{}'.format(self._sid)
        host_name = 'h{}'.format(self._sid)
        self.expr.addSwitch(switch_name,
                            dpid=Tools.makeDPID(self._sid),
                            wid=self._wid)
        self.expr.addHost(host_name,
                          ip=self._ip_addr,
                          max=Tools.makeMAC(self._sid),
                          pos=switch_name)
        self.expr.addLink(switch_name, host_name, autoconf=True)

        logging.info('Created switch {} ({}) on worker {}'.format(
            self._sid,
            self._ip_addr,
            self._wid + 1,
        ))
        time.sleep(2)
Example #3
0
	def createDC(self, numofDC, numSr, nodesPerSr, DCtopo, subnet, bwlimit, lat):

		srList = []
		nodeList = []
		DCIdx = numofDC + 1
		srIdx = numofDC * numSr + 1
		nodeIdx = numofDC * numSr * nodesPerSr + 1
		#create service router 

		for i in range(numSr):
			sr = self.addSwitch('sr'+ str(srIdx), dpid=Tools.makeDPID(srIdx),
										**dict(listenPort=(13000+srIdx-1)))
			print("create sr %s" % sr)
			# create nodes
			if i != 0:
				for j in range(nodesPerSr):
					h = self.addHost('h' + str(nodeIdx), mac=Tools.makeMAC(nodeIdx),
									ip=subnet + str(numofDC) + '.' +str(nodeIdx+100)+'/24', defaultRoute ='h'+str(nodeIdx)+'-eth0')
					print("create host %s" % h)
					nodeList.append(h)
					self.addLink(h, sr, bw=2*bwlimit, delay=str(lat)+'ms')
					print("add link between %s and %s" % (h, sr))
					nodeIdx += 1
			srIdx += 1
			
			# if fullmesh, ovs should be defined to break loop!!!
			if DCtopo == 'fullmesh':
			# connect sr to previous srs
				for tempSrIdx in range(len(srList)):
					self.addLink(sr, srList[tempSrIdx], bw=bwlimit, delay=str(lat)+'ms')
					print("add link between %s and %s" % (sr, srList[tempSrIdx]))
			elif DCtopo == 'line':
				if len(srList) > 0:
					self.addLink(sr, srList[-1], bw=2*bwlimit, delay=str(lat)+'ms')
					print("add link between %s and %s" % (sr, srList[-1]))
			srList.append(sr)

		DC = [DCIdx, srList[0]]
		return DC, srList, nodeList
Example #4
0
def create_topo(topo):
    t = Topo()

    i = 1
    for host in topo['hosts']:
        logger.debug("add host {} to topo".format(host['name']))
        t.addHost(host['name'], ip=Tools.makeIP(i), mac=Tools.makeMAC(i))
        i += 1

    i = 1
    for switch in topo['switches']:
        logger.debug("add switch {} to topo".format(switch['name']))
        t.addSwitch(switch['name'], dpid=Tools.makeDPID(i))
        i += 1

    i = 1
    for link in topo['links']:
        logger.debug("add link from {} to {} to topo".format(
            link['node1']['name'], link['node2']['name']))
        t.addLink(link['node1']['name'], link['node2']['name'])
        i += 1

    return t
Example #5
0
# UserSwitch.

import time

from mininet.topo import Topo
from mininet.node import OVSSwitch

from MaxiNet.Frontend import maxinet
from MaxiNet.tools import Tools

# create topology

cluster = maxinet.Cluster(minWorkers=1, maxWorkers=1)

topo = Topo()
topo.addHost("h1", ip=Tools.makeIP(1), mac=Tools.makeMAC(1))
topo.addHost("h2", ip=Tools.makeIP(2), mac=Tools.makeMAC(2))
topo.addHost("h3", ip=Tools.makeIP(3), mac=Tools.makeMAC(3))
topo.addHost("h4", ip=Tools.makeIP(4), mac=Tools.makeMAC(4))
topo.addHost("h5", ip=Tools.makeIP(5), mac=Tools.makeMAC(5))
topo.addHost("h6", ip=Tools.makeIP(6), mac=Tools.makeMAC(6))
topo.addHost("h7", ip=Tools.makeIP(7), mac=Tools.makeMAC(7))
topo.addHost("h8", ip=Tools.makeIP(8), mac=Tools.makeMAC(8))

topo.addSwitch("s1", dpid=Tools.makeDPID(1))
topo.addSwitch("s2", dpid=Tools.makeDPID(2))
topo.addSwitch("s3", dpid=Tools.makeDPID(3))
topo.addSwitch("s4", dpid=Tools.makeDPID(4))
topo.addSwitch("s5", dpid=Tools.makeDPID(5))
topo.addSwitch("s6", dpid=Tools.makeDPID(6))
topo.addSwitch("s7", dpid=Tools.makeDPID(7))
Example #6
0
# emulated hosts.
#

import subprocess

from mininet.node import OVSSwitch
from mininet.topo import Topo

from MaxiNet.Frontend import maxinet
from MaxiNet.tools import Tools

topo = Topo()

topo.addSwitch("s1")
topo.addSwitch("s2")
topo.addHost("h1", ip=Tools.makeIP(1), mac=Tools.makeMAC(1))
topo.addHost("h2", ip=Tools.makeIP(2), mac=Tools.makeMAC(2))
topo.addLink("h1", "s1")
topo.addLink("s1", "s2")
topo.addLink("h2", "s2")

cluster = maxinet.Cluster()

# we need to add the root node after the simulation has started as we do
# not know which worker id the frontend machine will get. Therefore we
# need a dynamic topology which is only supported in openvswitch
exp = maxinet.Experiment(cluster, topo, switch=OVSSwitch)
exp.setup()

# Start ssh servers
h1 = exp.get("h1")
Example #7
0
# start cluster
cluster = maxinet.Cluster(minWorkers=2, maxWorkers=2)

# start experiment on cluster
exp = maxinet.Experiment(cluster, topo, switch=OVSSwitch)
exp.setup()

print('****Setting up topology part 1')

print('Creating switches s1 (on worker1) and s2 (on worker2)...')
exp.addSwitch("s1", dpid="00:00:00:00:00:00:00:01", wid=0)
exp.addSwitch("s2", dpid="00:00:00:00:00:00:00:02", wid=1)

print('Adding hosts h1 in worker 1...')
exp.addHost('h1',ip=Tools.makeIP(1), max=Tools.makeMAC(1), pos='s1')

print('Adding hosts h2 in worker 2...')
exp.addHost('h2',ip=Tools.makeIP(2), max=Tools.makeMAC(2), pos='s2')

print('Connecting h1 with s1')
exp.addLink("h1", "s1", autoconf=True)

print('Connecting h2 with s2')
exp.addLink("h2", "s2", autoconf=True)

print('Connecting s1 and s2...')
exp.addLink("s1", "s2", autoconf=True)

maxinet.Experiment.CLI(exp, None, None)
# start cluster
cluster = maxinet.Cluster(minWorkers=2, maxWorkers=2)

# start experiment on cluster
exp = maxinet.Experiment(cluster, topo, switch=OVSSwitch)
exp.setup()

print('****Setting up topology part 1')

print('Creating switches s1 (on worker1) and s2 (on worker2)...')
exp.addSwitch("s1", dpid="00:00:00:00:00:00:00:01", wid=0)
exp.addSwitch("s2", dpid="00:00:00:00:00:00:00:02", wid=1)

print('Adding hosts h1 in worker 1...')
exp.addHost('h1', ip=Tools.makeIP(1), max=Tools.makeMAC(1), pos='s1')

print('Adding hosts h2 in worker 2...')
exp.addHost('h2', ip=Tools.makeIP(2), max=Tools.makeMAC(2), pos='s2')

print('Connecting h1 with s1')
exp.addLink("h1", "s1", autoconf=True)

print('Connecting h2 with s2')
exp.addLink("h2", "s2", autoconf=True)

print('Connecting s1 and s2...')
exp.addLink("s1", "s2", autoconf=True)

raw_input('[Continue]')
Example #9
0
# emulated hosts.
#

import subprocess

from mininet.node import OVSSwitch
from mininet.topo import Topo

from MaxiNet.Frontend import maxinet
from MaxiNet.tools import Tools

topo = Topo()

topo.addSwitch("s1")
topo.addSwitch("s2")
topo.addHost("h1", ip=Tools.makeIP(1), mac=Tools.makeMAC(1))
topo.addHost("h2", ip=Tools.makeIP(2), mac=Tools.makeMAC(2))
topo.addLink("h1", "s1")
topo.addLink("s1", "s2")
topo.addLink("h2", "s2")

cluster = maxinet.Cluster()

# we need to add the root node after the simulation has started as we do
# not know which worker id the frontend machine will get. Therefore we
# need a dynamic topology which is only supported in openvswitch
exp = maxinet.Experiment(cluster, topo, switch=OVSSwitch)
exp.setup()

# Start ssh servers
h1 = exp.get("h1")
Example #10
0
topo = Topo() #empty topo
cluster = maxinet.Cluster(minWorkers=5, maxWorkers=5)
exp = maxinet.Experiment(cluster, topo, switch=OVSSwitch)
exp.setup()

# SIGN

print "adding switches on workers..."
exp.addSwitch("s1", dpid=Tools.makeDPID(1), wid=0)
exp.addSwitch("s2", dpid=Tools.makeDPID(2), wid=1)
exp.addSwitch("s3", dpid=Tools.makeDPID(3), wid=2)
exp.addSwitch("s4", dpid=Tools.makeDPID(4), wid=3)
exp.addSwitch("s5", dpid=Tools.makeDPID(2), wid=4)

print "adding 5 hosts..."
exp.addHost("h1", ip=Tools.makeIP(1), max=Tools.makeMAC(1), pos="s1")
exp.addHost("h2", ip=Tools.makeIP(2), max=Tools.makeMAC(2), pos="s2")
exp.addHost("h3", ip=Tools.makeIP(3), max=Tools.makeMAC(3), pos="s3")
exp.addHost("h4", ip=Tools.makeIP(4), max=Tools.makeMAC(4), pos="s4")
exp.addHost("h5", ip=Tools.makeIP(5), max=Tools.makeMAC(5), pos="s5")


print "add links between h_i and s_i"
exp.addLink("s1", "h1", autoconf=True)
exp.addLink("s2", "h2", autoconf=True)
exp.addLink("s3", "h3", autoconf=True)
exp.addLink("s4", "h4", autoconf=True)
exp.addLink("s5", "h5", autoconf=True)

print "add links between s1 and s2345..."
exp.addLink("s1", "s2", autoconf=True)
Example #11
0
print exp.get_node("d2").cmd("ifconfig")

print "waiting 5 seconds for routing algorithms on the controller to converge"
#time.sleep(5)

print "ping d1 ---> d2"
print exp.get_node("d1").cmd("ping -c 5 10.0.0.252")
print "ping d2 ---> d1"
print exp.get_node("d2").cmd("ping -c 5 10.0.0.251")

#exp.CLI(locals(), globals())

print "add d3 at runtime"
#worker = exp.get_worker('s1')
#worker.addDocker('d4', dimage="ubuntu:trusty")
d3 = exp.addDocker("d3", pos="s1", dimage="ubuntu:trusty", ip="10.0.0.254", max=Tools.makeMAC(3))
#d3.setIP(ip='10.0.0.254')
#h3 = exp.get_worker("s1").addHost('h3', ip=Tools.makeIP(3), max=Tools.makeMAC(3))
#d3 = exp.get_worker("s1").addDocker('d3', dimage="ubuntu:trusty")

print "add link s1 <---> d3"
#exp.addLink(exp.get_node("d3"), exp.get_node("s1"), params1={"ip": "10.0.0.254/8"})
exp.addLink("d3", "s1", autoconf=True)


print "wait 5 seconds"
time.sleep(5)

print "ping d3 --> d1"
print d3.cmd("ping -c 5 10.0.0.251")
print "ping d1 --> d3"
Example #12
0
os.rename("t1_experiment.cfg", "experiment.cfg")
os.system("sudo rm /log/*")

# Now also copy the given input topo file as in_topo.json in each of worker
copy2(topo_fname, 'in_topo.json')
print "File sucessfully copied as in_topo.json..."

with open('in_topo.json') as data_file:
    data = json.load(data_file)

hnames = data["hosts"]
hlen = len(hnames)
cnt = 1
for x in range(0, hlen):
    tmp = str(hnames[x])
    myglobalTopo.addHost(tmp, ip=Tools.makeIP(cnt), mac=Tools.makeMAC(cnt))
    cnt = cnt + 1

my_swlist = []
for key, value in dict.items(data["switches"]):
    my_swlist.append(key)  # Add to list of switches in topology
    cnt = 1
    for value1, value2 in dict.items(data["switches"][key]):
        tmp = str(key)
        myglobalTopo.addSwitch(tmp, dpid=Tools.makeDPID(cnt))
        cnt = cnt + 1

#hnames = data["hosts"]
hnames = data["links"]
hlen = len(hnames)
for x in range(0, hlen):
Example #13
0
# Dynamic adding and removing of nodes also does not work when using the
# UserSwitch.


import time

from mininet.topo import Topo
from mininet.node import OVSSwitch

from MaxiNet.Frontend import maxinet
from MaxiNet.tools import Tools


# create topology
topo = Topo()
topo.addHost("h1", ip=Tools.makeIP(1), mac=Tools.makeMAC(1))
topo.addHost("h2", ip=Tools.makeIP(2), mac=Tools.makeMAC(2))
topo.addSwitch("s1", dpid=Tools.makeDPID(1))
topo.addLink("h1", "s1")
topo.addLink("h2", "s1")

# start cluster
cluster = maxinet.Cluster(minWorkers=5, maxWorkers=5)

# start experiment with OVSSwitch on cluster
exp = maxinet.Experiment(cluster, topo, switch=OVSSwitch)
exp.setup()

print "waiting 5 seconds for routing algorithms on the controller to converge"
time.sleep(5)
Example #14
0
# Dynamic adding and removing of nodes also does not work when using the
# UserSwitch.


import time

from mininet.topo import Topo
from mininet.node import OVSSwitch

from MaxiNet.Frontend import maxinet
from MaxiNet.tools import Tools


# create topology
topo = Topo()
topo.addHost("h1", ip=Tools.makeIP(1), mac=Tools.makeMAC(1))
topo.addHost("h2", ip=Tools.makeIP(2), mac=Tools.makeMAC(2))
topo.addSwitch("s1", dpid=Tools.makeDPID(1))
topo.addLink("h1", "s1")
topo.addLink("h2", "s1")

# start cluster
cluster = maxinet.Cluster(minWorkers=2, maxWorkers=2)

# start experiment with OVSSwitch on cluster
exp = maxinet.Experiment(cluster, topo, switch=OVSSwitch)
exp.setup()

print "waiting 5 seconds for routing algorithms on the controller to converge"
time.sleep(5)