예제 #1
0
 def genDevice(self):
     """
     Generate logical device instance and add thrift link to host
     """
     for i in range(self.vertexNum):
         thriftPort = 9090 + i
         self.switches.append(
             Switch('s' + str(i), thriftPort, SwitchRuntime(thriftPort=thriftPort)))
         if self.hostList[i] == 1:
             self.hosts.append(
                 Host('h' + str(i), self.genMac(i), self.genIp(i), self.genIp(i, True)))
         else:
             self.hosts.append(None)
예제 #2
0
 def callback():
     if label.get() == "host":
         device = self.canvas.create_oval(event.x - 10, event.y - 10, event.x + 10, event.y + 10, fill="blue")
         device_id.append([device, 0])
         devices.append(Host(ip=self.set_ip))
         text_id = self.canvas.create_text(event.x, event.y, text=self.set_ip, fill="white")
         self.set_ip += 1
         master.destroy()
     elif label.get() == "router":
         device = self.canvas.create_oval(event.x - 10, event.y - 10, event.x + 10, event.y + 10, fill="green")
         device_id.append([device, 1])
         devices.append(Router(ip=self.set_ip))
         text_id = self.canvas.create_text(event.x, event.y, text=self.set_ip, fill="white")
         self.set_ip += 1
         master.destroy()
예제 #3
0
 def __init__(self):
     jsonObject = self.readData()
     # initialize the hosts,flows,routers,links
     self.queue = EventQueue(0)
     self.routers = {}
     for r in jsonObject['routers']:
         self.routers[r['id']] = Router(r['id'])
     self.hosts = {}
     for h in jsonObject['hosts']:
         self.hosts[h['id']] = Host(h['id'])
     self.links = {}
     for l in jsonObject['links']:
         self.links[l['id']] = Link(l)
         self.links[l['id']].scheduler = self.queue
         if (l['endpoints'][0][0] == 'H' or l['endpoints'][0][0] == 'S'
                 or l['endpoints'][0][0] == 'T'):
             self.links[l['id']].pointA = self.hosts[l['endpoints'][0]]
             self.hosts[l['endpoints'][0]].link = self.links[l['id']]
         else:
             self.links[l['id']].pointA = self.routers[l['endpoints'][0]]
             self.routers[l['endpoints'][0]].links.append(
                 self.links[l['id']])
         if (l['endpoints'][1][0] == 'H' or l['endpoints'][1][0] == 'S'
                 or l['endpoints'][1][0] == 'T'):
             self.links[l['id']].pointB = self.hosts[l['endpoints'][1]]
             self.hosts[l['endpoints'][1]].link = self.links[l['id']]
         else:
             self.links[l['id']].pointB = self.routers[l['endpoints'][1]]
             self.routers[l['endpoints'][1]].links.append(
                 self.links[l['id']])
     self.flows = {}
     for f in jsonObject['flows']:
         self.flows[f['id']] = Flow(f)
         self.flows[f['id']].event_queue = self.queue
         self.flows[f['id']].controller.event_scheduler = self.queue
         self.flows[f['id']].source = self.hosts[f['source']]
         self.hosts[f['source']].flow[f['id']] = self.flows[f['id']]
         self.flows[f['id']].destination = self.hosts[f['destination']]
         self.hosts[f['destination']].flow[f['id']] = self.flows[f['id']]
     self.queue.blind(self.routers)
예제 #4
0
import simpy
from device import Host
from device import Router
from link import Link
from utils import flow
from utils import dynamic_routing
from utils import graph_live
env = simpy.Environment()

# routing table maps to link object, not the idx in list
devices = [
    Host(ip=0),
    Host(ip=1),
    Host(ip=2),
    Host(ip=3),
    Host(ip=4),
    Host(ip=5),
    Router(ip=6),
    Router(ip=7),
    Router(ip=8),
    Router(ip=9),
]

links = [
    Link(l_id=0,
         link_rate=(1562500),
         link_delay=10,
         max_buffer_size=128000,
         env=env),
    Link(l_id=1,
         link_rate=(1.25 * 10**6),
예제 #5
0
import simpy
from device import Host
from link import Link
from utils import flow
from utils import graph_live

env = simpy.Environment()

data1 = 20 * 10 ** 6
devices = [Host(ip=0), Host(ip=1)]
links = [
Link(l_id=0, link_rate=(2.578 * 10 ** 11), link_delay=10, max_buffer_size=64000, env=env)]

devices[0].add_link(links[0])
devices[1].add_link(links[0])

links[0].add_device(devices[0])
links[0].add_device(devices[1])

p = env.process(flow(data1, 1000, devices[0], 1, env, 'Reno'))
p = env.process(graph_live(devices, links, env, [0, 1], [0]))

env.run()
예제 #6
0
import simpy
from device import Host
from device import Router
from link import Link
from utils import flow
from utils import dynamic_routing
from utils import graph_live
env = simpy.Environment()

# data1 = 20 * 10 ** 6
data1 = 1024 * 2000

devices = [
    Host(ip=0),
    Host(ip=1),
    Router(ip=2),
    Router(ip=3),
    Router(ip=4),
    Router(ip=5)
]
links = [
    Link(l_id=0,
         link_rate=(1562500),
         link_delay=10,
         max_buffer_size=64000,
         env=env),
    Link(l_id=1,
         link_rate=(1.25 * 10**6),
         link_delay=10,
         max_buffer_size=64000,
         env=env),