def test_ue1(): # Parametros de la unidad experimental setLogLevel("info") info("Configurando unidad experimental\n") c_ryu = RYU('c0') topo_tree = TreeTopo(depth=2, fanout=2) ue1 = UnidadExperimental(topo=topo_tree, controller=c_ryu) ue1.definirNodosClaves('h1', 'h2', 'h3') # Iniciando mininet a partir de la unidad experimental info("Configurando e inicializando la red\n") net = Mininet(topo=ue1.getTopo(), controller=ue1.getController()) net.start() net.pingAll() CLI(net) net.stop()
def setController(self, controller, appsController): """ Asigna el controlador a la unidad experimental. Parameters ---------- controller: str nombre del controlador a usar Returns ------- None Raises ------ No hay manejo de errores """ if controller == 'ryu': self.controller = RYU(name='c0', ryuArgs=appsController) else: self.controller = POX(name='c0') # Mejorar ---------------
from mininet.topo import SingleSwitchTopo from signal import SIGKILL # We assume you are in the same directory as pox.py # or that it is loadable via PYTHONPATH from controlador import RYU, POX import os import subprocess import time # Solucion tomada de http://csie.nqu.edu.tw/smallko/sdn/openflow_pkts.htm if __name__ == "__main__": setLogLevel('info') # Creando la red: RYU + Single topo net = Mininet(topo=SingleSwitchTopo(k=3), controller=RYU('c0'), build=False) # Obteniendo las interfaces de los switches """ Lanzando el proceso asociado al comando """ # Proceso padre info("Iniciando topologia mininet") net.build() net.start() net.getNodeByName('c0').cmd("tcpdump -i any -nn port 6653 -U -w mylog &") time.sleep(3) CLI(net) net.stop() net.getNodeByName('c0').cmd("pkill tcpdump")
# kill del proceso del ataque self.attack_process.kill() self.timer.cancel() def launchAttack(self): info("Launch attack: %s ---> %s\n" % (str(self.atk.IP()), str(self.dst.IP()))) self.attack_process = self.atk.popen( ['hping3', '--flood', '--rand-source', self.dst.IP()]) # Atacante if self.attack_process != 0: self.timer_atk.cancel() ue1 = UnidadExperimental(topo=SingleSwitchTopo(k=3, bw=100), controller=RYU('c0')) ue1.definirNodosClaves('h1', 'h2', 'h3') ue2 = UnidadExperimental(topo=SingleSwitchTopo(k=3, bw=100), controller=POX('c0')) ue2.definirNodosClaves('h1', 'h2', 'h3') class TopologiaTest(Topo): def __init__(self, bw=100): # Initialize topology Topo.__init__(self) self.bw = bw h1 = self.addHost('h1', ip='10.0.0.1') # Cliente h2 = self.addHost('h2', ip='10.0.0.2') # Atacante h3 = self.addHost('h3', ip='10.0.0.3') # Victima
def setController(self, controller, appsController='simple_switch_13.py'): if controller == 'ryu': self.controller = RYU(name='c0', ryuArgs=appsController) else: self.controller = POX(name='c0') # Mejorar
from select import poll, POLLIN from trafico import TraficoAtaque, TraficoNormal from unidadExperimental import UnidadExperimental from topologia import TopologiaPOX, TopologiaRyu, TopologiaTest from controlador import RYU, POX from experimento import Experimento import dexpy.factorial import dexpy.power import dexpy.alias import pandas as pd import numpy as np import dexpy.design import random import sys controladores = {'ryu': RYU('c0', ), 'pox': POX('c0')} topologias = { 'topoRyu': TopologiaRyu(), 'topoPOX': TopologiaPOX(), 'topoTest': TopologiaTest() } """ Caso Ryu-Normal """ def experimentoRyuNormal(): # Unidad experimental ryu_normal = UnidadExperimental() ryu_normal.setTopo(topologias['topoTest']) ryu_normal.setController('ryu') ryu_normal.definirNodosClaves(C='h2', V='h3')
h1 = self.addHost('h1', ip='10.0.0.1') # Cliente h2 = self.addHost('h2', ip='10.0.0.2') # Atacante h3 = self.addHost('h3', ip='10.0.0.3') # Victima # Add switches info('*** Adding switches\n') s1 = self.addSwitch('s1', protocols='OpenFlow13') # Add links info('*** Creating links\n') self.addLink(h1, s1, bw=self.bw) self.addLink(h2, s1, bw=self.bw) self.addLink(h3, s1, bw=self.bw) ue_ryu = UnidadExperimental(topo=TopologiaTest(bw=100), controller=RYU('c0')) ue_ryu.definirNodosClaves('h1', 'h2', 'h3') ue_pox = UnidadExperimental(topo=TopologiaTest(bw=100), controller=POX('c0')) ue_pox.definirNodosClaves('h1', 'h2', 'h3') def monitoring_ping_normal(ue, nombreArchivo=None): # Parametros de la unidad experimental setLogLevel("info") info("Configurando unidad experimental\n") info("Configurando trafico normal\n") info("Configurando la red\n") net = Mininet(topo=ue.getTopo(), controller=ue.getController(), link=TCLink,
from mininet.log import setLogLevel, info from mininet.net import Mininet from mininet.topolib import TreeTopo from mininet.cli import CLI from mininet.topo import SingleSwitchTopo from signal import SIGKILL # We assume you are in the same directory as pox.py # or that it is loadable via PYTHONPATH from controlador import RYU,POX import os import subprocess if __name__ == "__main__": setLogLevel( 'info' ) # Creando la red: RYU + Single topo net = Mininet( topo=SingleSwitchTopo(k = 3), controller=RYU('c0')) # Obteniendo las interfaces de los switches net_sw = {} for k,v in net.items(): if 's' in k: sw_int = [] for i in range(1,len(v.ports)): sw_int.append(k + '-eth' + str(i)) net_sw[k]=sw_int sw_int = [] filename="monitoreo.csv" # Agrupando de insterfaces para pasar al comando bwm-ng list_interfaces = '' for k in net_sw: for int_sw in net_sw[k]: