示例#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_link_with(self, link_switch):
     switch_name_1 = 's{}'.format(self._sid)
     switch_name_2 = 's{}'.format(link_switch)
     self.expr.addLink(switch_name_1, switch_name_2, autoconf=True)
     logging.info('Built link: {} ({}) <-> {} ({})'.format(
         self._sid,
         self._ip_addr,
         link_switch,
         Tools.makeIP(link_switch),
     ))
     time.sleep(2)
示例#3
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
示例#4
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))
示例#5
0
文件: sshd.py 项目: CN-UPB/MaxiNet
# 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")
示例#6
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]')
示例#8
0
文件: sshd.py 项目: zlorb/MaxiNet
# 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")
 def __init__(self, switch_id, worker_id, children):
     self._sid = switch_id
     self._wid = worker_id
     self._children = children
     self._ip_addr = Tools.makeIP(self._sid)
示例#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)
示例#11
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):
示例#12
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)
示例#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=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)