Beispiel #1
0
def topology(coord):
    "Create a network."
    net = Mininet_wifi(controller=Controller, accessPoint=OVSKernelAP)

    info("*** Creating nodes\n")
    h1 = net.addHost('h1', mac='00:00:00:00:00:01', ip='10.0.0.1/8')
    sta1 = net.addStation('sta1', mac='00:00:00:00:00:02', ip='10.0.0.2/8')
    sta2 = net.addStation('sta2', mac='00:00:00:00:00:03', ip='10.0.0.3/8')
    ap1 = net.addAccessPoint('ap1',
                             ssid='new-ssid',
                             mode='g',
                             channel='1',
                             position='45,40,0')
    c1 = net.addController('c1', controller=Controller)

    info("*** Configuring wifi nodes\n")
    net.configureWifiNodes()

    info("*** Associating and Creating links\n")
    net.addLink(ap1, h1)

    net.plotGraph(max_x=200, max_y=200)

    if coord:
        sta1.coord = ['40.0,30.0,0.0', '31.0,10.0,0.0', '31.0,30.0,0.0']
        sta2.coord = ['40.0,40.0,0.0', '55.0,31.0,0.0', '55.0,81.0,0.0']

    net.startMobility(time=0, repetitions=1)
    if coord:
        net.mobility(sta1, 'start', time=1)
        net.mobility(sta2, 'start', time=2)
        net.mobility(sta1, 'stop', time=12)
        net.mobility(sta2, 'stop', time=22)
    else:
        net.mobility(sta1, 'start', time=1, position='40.0,30.0,0.0')
        net.mobility(sta2, 'start', time=2, position='40.0,40.0,0.0')
        net.mobility(sta1, 'stop', time=12, position='31.0,10.0,0.0')
        net.mobility(sta2, 'stop', time=22, position='55.0,31.0,0.0')
    net.stopMobility(time=23)

    info("*** Starting network\n")
    net.build()
    c1.start()
    ap1.start([c1])

    info("*** Running CLI\n")
    CLI_wifi(net)

    info("*** Stopping network\n")
    net.stop()
Beispiel #2
0
def topology(is_enable_cli=False):
    """
    create a network.

    mode (str): miminet or containernet
    is_enable_cli (bool): running CLI
    """
    c1 = RemoteController('c1', ip='172.17.20.12', port=6633)
    net = Mininet_wifi(accessPoint=OVSKernelAP)
    info("*** Starting network\n")
    net.build()
    c1.start()
    if is_enable_cli:
        info("*** Running CLI\n")
        CLI_wifi(net)
    info("*** Stopping network\n")
    net.stop()
Beispiel #3
0
 def start(self):
     log.info("*** Starting network\n")
     # self.net.plotGraph(max_x=200, max_y=200)
     self.ts_netstart = time()
     # trigger attachment
     self.net.startMobility(time=0, repetitions=1)
     for sta_name, sta_obj in iteritems(self.sta_dict):
         self.net.mobility(sta_obj, 'start', time=1, position='0,0,0')
         self.net.mobility(sta_obj, 'stop', time=2, position='0,0,0')
     self.net.stopMobility(time=3)
     self.net.build()
     self.c1.start()
     for ap_name, ap_obj in iteritems(self.ap_dict):
         ap_obj.start([self.c1])
     sleep(5)  # wait for setup
     CLI_wifi(self.net)
     # TODO: clean this shit
     result = self.exec_cmd('h1', 'ping 10.0.0.13 -c 1')
     log.info(result)
     result = self.exec_cmd('sta1', 'ping 10.0.0.11 -c 1')
     log.info(result)
     result = self.exec_cmd('sta2', 'ping 10.0.0.12 -c 1')
     log.info(result)
     result = self.exec_cmd(
         'h1',
         'python main.py color_finder 10.0.0.11:18800 10.0.0.13:18800 &')
     log.info(result)
     result = self.exec_cmd(
         'sta1',
         'python main.py data_forwarder 172.17.0.2:18800 10.0.0.11:18800 True &'
     )
     log.info(result)
     result = self.exec_cmd(
         'sta2',
         'python main.py data_forwarder 10.0.0.13:18800 192.168.56.102:18900 False &'
     )
     log.info(result)
Beispiel #4
0
 def run_cli(self):
     log.info("*** Running CLI\n")
     CLI_wifi(self.net)
Beispiel #5
0
def topology():
    "Create a network."

    c1 = RemoteController('c1', ip='172.17.20.11', port=6633)
    net = Mininet_wifi(accessPoint=OVSKernelAP)
    net.propagationModel(model="logDistance", exp=3)

    info("*** Creating nodes\n")
    #mode = 'mininet'
    mode = 'containernet'
    if mode == 'mininet':
        h1 = net.addHost('h1',
                         cls=Node,
                         mac='00:00:00:00:00:01',
                         ip='10.0.0.11/8')
        sta1 = net.addStation('sta1',
                              cls=Station,
                              mac='00:00:00:00:00:02',
                              ip='10.0.0.12/8')
        sta2 = net.addStation('sta2',
                              cls=Station,
                              mac='00:00:00:00:00:03',
                              ip='10.0.0.13/8')
    else:
        dimage_name = 'kumokay/ubuntu14_wifi:latest'
        h1 = net.addHost('h1',
                         cls=Docker,
                         dimage=dimage_name,
                         mac='00:00:00:00:00:01',
                         ip='10.0.0.11/8')
        sta1 = net.addStation('sta1',
                              cls=DockerStation,
                              dimage=dimage_name,
                              mac='00:00:00:00:00:02',
                              ip='10.0.0.12/8')
        sta2 = net.addStation('sta2',
                              cls=DockerStation,
                              dimage=dimage_name,
                              mac='00:00:00:00:00:03',
                              ip='10.0.0.13/8')
    ap1 = net.addAccessPoint('ap1',
                             ssid='new-ssid',
                             mode='g',
                             channel='1',
                             position='0,0,0')
    net.addController(c1)

    info("*** Configuring wifi nodes\n")
    net.configureWifiNodes()

    info("*** Associating and Creating links\n")
    net.addLink(ap1, h1)

    # net.plotGraph(max_x=200, max_y=200)

    net.startMobility(time=0, repetitions=1)
    net.mobility(sta1, 'start', time=1, position='0.0,0.0,0.0')
    net.mobility(sta2, 'start', time=1, position='0.0,0.0,0.0')
    net.mobility(sta1, 'stop', time=22, position='40.0,40.0,0.0')
    net.mobility(sta2, 'stop', time=22, position='20.0,20.0,0.0')
    net.stopMobility(time=23)

    info("*** Starting network\n")
    net.build()
    c1.start()
    ap1.start([c1])

    info("*** Running CLI\n")
    CLI_wifi(net)

    info("*** Stopping network\n")
    net.stop()
Beispiel #6
0
 def __init__(self, mininet, stdin=sys.stdin, script=None):
     CLI_wifi.__init__(self, mininet, stdin=sys.stdin, script=None)
 def start_cil(self):
     CLI_wifi(self.net)
     return True