Esempio n. 1
0
def topology():
    "Create a network."
    net = Mininet_wifi()

    info("*** Creating nodes\n")
    sta1 = net.addStation('sta1', ip='192.168.0.1/24')
    sta2 = net.addStation('sta2', ip='192.168.1.1/24')
    r1 = net.addStation('r1', wlans=2)

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

    r1.setMasterMode(intf='r1-wlan0', ssid='r1-ssid1', channel='1', mode='n')
    r1.setMasterMode(intf='r1-wlan1', ssid='r1-ssid2', channel='6', mode='n')

    info("*** Starting network\n")
    net.build()

    r1.cmd('sysctl net.ipv4.ip_forward=1')
    r1.cmd('ifconfig r1-wlan0 192.168.0.100')
    r1.cmd('ifconfig r1-wlan1 192.168.1.100')
    r1.cmd('ip route add to 192.168.1.1 via 192.168.1.100')
    r1.cmd('ip route add to 192.168.0.1 via 192.168.0.100')
    sta1.cmd('iw dev sta1-wlan0 connect r1-ssid1')
    sta2.cmd('iw dev sta2-wlan0 connect r1-ssid2')

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

    info("*** Stopping network\n")
    net.stop()
Esempio n. 2
0
    def create_network(self):
        """ Create the mininet network object, and store it as self.net.

            Side effects:
                - Mininet topology instance stored as self.topo
                - Mininet instance stored as self.net
        """
        self.logger("Building mininet topology.")

        defaultapClass = configureP4AP(sw_path=self.bmv2_exe,
                                       json_path=self.ap_json,
                                       log_console=True,
                                       pcap_dump=self.pcap_dir)

        defaultSwitchClass = configureP4Switch(sw_path=self.bmv2_exe,
                                               json_path=self.ap_json,
                                               log_console=True,
                                               pcap_dump=self.pcap_dir)

        self.topo = ExerciseTopo(self.stations, self.aps, self.hosts,
                                 self.switches, self.links, self.log_dir,
                                 self.bmv2_exe, self.pcap_dir)

        self.net = Mininet_wifi(topo=self.topo,
                                station=P4Station,
                                host=P4Host,
                                switch=defaultSwitchClass,
                                accessPoint=defaultapClass,
                                controller=None,
                                link=wmediumd,
                                wmediumd_mode=interference)
 def testDefaultDpid(self):
     """Verify that the default dpid is assigned using a valid provided
     canonical apname if no dpid is passed in ap creation."""
     ap = Mininet_wifi(topo=Topo_WiFi(),
                       accessPoint=self.accessPointClass,
                       station=Station, controller=Controller,
                      ).addAccessPoint('ap1')
     self.assertEqual(ap.defaultDpid(), ap.dpid)
Esempio n. 4
0
    def __init__(self, parser=argparse.ArgumentParser(), topo=None, topoFile=None, noTopo=False, link=WirelessLink, **mininetParams):
        """Create Mini-NDN-Wifi object
        parser: Parent parser of Mini-NDN-Wifi parser (use to specify experiment arguments)
        topo: Mininet topo object (optional)
        topoFile: topology file location (optional)
        noTopo: Allows specification of topology after network object is initialized (optional)
        link: Allows specification of default Mininet/Mininet-Wifi link type for connections between nodes (optional)
        mininetParams: Any params to pass to Mininet-WiFi
        """
        self.parser = self.parseArgs(parser)
        self.args = self.parser.parse_args()

        Minindn.workDir = self.args.workDir
        Minindn.resultDir = self.args.resultDir

        self.topoFile = None
        if not topoFile:
            # Args has default topology if none specified
            self.topoFile = self.args.topoFile
        else:
            self.topoFile = topoFile

        if topo is None and not noTopo:
            try:
                info('Using topology file {}\n'.format(self.topoFile))
                self.topo = self.processTopo(self.topoFile)
            except configparser.NoSectionError as e:
                info('Error reading config file: {}\n'.format(e))
                sys.exit(1)
        else:
            self.topo = topo

        if not noTopo:
            self.net = Mininet_wifi(topo=self.topo, ifb=self.args.ifb, link=link, **mininetParams)
        else:
            self.net = Mininet_wifi(ifb=self.args.ifb, link=link, **mininetParams)

        # Prevents crashes running mixed topos
        nodes = self.net.stations + self.net.hosts + self.net.cars
        self.initParams(nodes)

        try:
            process = Popen(['ndnsec-get-default', '-k'], stdout=PIPE, stderr=PIPE)
            output, error = process.communicate()
            if process.returncode == 0:
                Minindn.ndnSecurityDisabled = '/dummy/KEY/-%9C%28r%B8%AA%3B%60' in output
                info('Dummy key chain patch is installed in ndn-cxx. Security will be disabled.\n')
            else:
                debug(error)
        except:
            pass

        self.cleanups = []
Esempio n. 5
0
    def mobility(self, nodes, Mininet_wifi):
        if nodes is None:
            nodes = Mininet_wifi.stations + Mininet_wifi.aps
        for node in nodes:
            if isinstance(node, Station):
                if 'position' in node.params and node not in mobility.stations:
                    mobility.stations.append(node)
            if isinstance(node, AP):
                if 'position' in node.params and node not in mobility.aps:
                    mobility.aps.append(node)

        if Mininet_wifi.DRAW:
            Mininet_wifi.isReplaying=False
            Mininet_wifi.checkDimension(nodes)
            plot = plot2d
            if Mininet_wifi.max_z != 0:
                plot = plot3d

        currentTime = time()
        for node in nodes:
            if 'speed' not in node.params:
                node.params['speed'] = 1.0
            node.currentTime = 1 / node.params['speed']
            node.timestamp = float(1.0 / node.params['speed'])
            node.isStationary = False
            if hasattr(node, 'time'):
                self.timestamp = True

        calc_pos = self.notimestamp_
        if self.timestamp:
            calc_pos = self.timestamp_

        while mobility.thread_._keep_alive:
            time_ = time() - currentTime
            if len(nodes) == 0:
                break
            for node in nodes:
                if hasattr(node, 'position'):
                    calc_pos(node, time_)
                    if len(node.position) == 0:
                        nodes.remove(node)
                    mobility.configLinks()
                    if Mininet_wifi.DRAW:
                        plot.update(node)
            if Mininet_wifi.DRAW:
                plot.pause()
 def testActualDpidAssignment(self):
     """Verify that AP dpid is the actual dpid assigned if dpid is
     passed in ap creation."""
     dpid = self.dpidFrom(0xABCD)
     ap = Mininet_wifi(topo=Topo_WiFi(), accessPoint=self.accessPointClass,
                       station=Station, controller=Controller,
                      ).addAccessPoint('ap1', dpid=dpid)
     self.assertEqual(ap.dpid[1:], dpid)
Esempio n. 7
0
    def mobility(self, nodes, Mininet_wifi):
        if nodes is None:
            nodes = Mininet_wifi.stations + Mininet_wifi.aps
        for node in nodes:
            if isinstance(node, Station):
                if 'position' in node.params and node not in mobility.stations:
                    mobility.stations.append(node)
            if isinstance(node, AP):
                if 'position' in node.params and node not in mobility.aps:
                    mobility.aps.append(node)

        if Mininet_wifi.DRAW:
            Mininet_wifi.isReplaying = False
            Mininet_wifi.checkDimension(nodes)
            plot = plot2d
            if Mininet_wifi.max_z != 0:
                plot = plot3d

        currentTime = time()
        for node in nodes:
            if 'speed' not in node.params:
                node.params['speed'] = 1.0
            node.currentTime = 1 / node.params['speed']
            node.timestamp = float(1.0 / node.params['speed'])
            node.isStationary = False
            if hasattr(node, 'time'):
                self.timestamp = True

        calc_pos = self.notimestamp_
        if self.timestamp:
            calc_pos = self.timestamp_

        while mobility.thread_._keep_alive:
            time_ = time() - currentTime
            if len(nodes) == 0:
                break
            for node in nodes:
                if hasattr(node, 'position'):
                    calc_pos(node, time_)
                    if len(node.position) == 0:
                        nodes.remove(node)
                    mobility.configLinks()
                    if Mininet_wifi.DRAW:
                        plot.update(node)
            if Mininet_wifi.DRAW:
                plot.pause()
    def testDefaultDpidLen(self):
        """Verify that Default dpid length is 16 characters consisting of
        16 - len(hex of first string of contiguous digits passed in ap
        name) 0's followed by hex of first string of contiguous digits passed
        in ap name."""
        ap = Mininet_wifi(topo=Topo_WiFi(), accessPoint=self.accessPointClass,
                          station=Station, controller=Controller,
                         ).addAccessPoint('ap123')

        self.assertEqual(ap.dpid, self.dpidFrom(123))
Esempio n. 9
0
    def generate(self):
        net = Mininet_wifi(link=wmediumd,
                           wmediumd_mode=interference,
                           noise_th=-91,
                           fading_cof=1)
        #net = Mininet_wifi(link=wmediumd, wmediumd_mode=interference)
        #net = Mininet_wifi(link=wmediumd)
        num = self.x * self.y

        info("*** Creating nodes\n")
        self.stas = []

        print("*** Creating nodes")
        interval = 70
        for i in range(num):
            self.stas.append(
                net.addStation('sta' + str(i + 1),
                               position=str(i % self.x * interval) + ',' +
                               str(math.floor(i / self.x) * interval) + ',0',
                               range=100))

        info("*** Configuring Propagation Model\n")
        net.setPropagationModel(model="logDistance", exp=4)

        print("*** Configuring wifi nodes")
        net.configureWifiNodes()

        print("*** Creating links")
        for i in range(num):
            net.addLink(self.stas[i],
                        cls=adhoc,
                        intf='sta' + str(i + 1) + '-wlan0',
                        ssid='adhocNet',
                        mode='g',
                        channel=5,
                        ht_cap='HT40+')
            #net.addLink(self.stas[i], cls=adhoc, intf='sta'+str(i+1)+'-wlan0',ssid='adhocNet',mode='g', channel=5)
        #net.plotGraph(max_x=500, max_y=500)

        return net
Esempio n. 10
0
def topology():
    "Create a network."
    net = Mininet_wifi( controller=Controller, switch=OVSKernelSwitch )

    info("*** Creating nodes\n")
    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='50,50,0' )
    c1 = net.addController( 'c1', controller=Controller )

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

    info("*** Adding Link\n")
    sta1.params['associatedTo'][0] = ap1
    sta2.params['associatedTo'][0] = ap1

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

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

    path = os.path.dirname(os.path.abspath(__file__))
    getTrace(sta1, '%s/replayingRSSI/node1_rssiData.dat' % path)
    getTrace(sta2, '%s/replayingRSSI/node2_rssiData.dat' % path)

    replayingRSSI(net)

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

    info("*** Stopping network\n")
    net.stop()
Esempio n. 11
0
def topology():
    "Create a network."
    net = Mininet_wifi(controller=Controller,
                       accessPoint=OVSKernelAP,
                       link=wmediumd,
                       wmediumd_mode=interference,
                       configure4addr=True,
                       autoAssociation=False)

    info("*** Creating nodes\n")
    ap1 = net.addAccessPoint('ap1',
                             _4addr="ap",
                             ssid="wds-ssid1",
                             mode="g",
                             channel="1",
                             position='30,30,0')
    ap2 = net.addAccessPoint('ap2',
                             _4addr="client",
                             ssid="wds-ssid2",
                             mode="g",
                             channel="1",
                             position='40,60,0')
    ap3 = net.addAccessPoint('ap3',
                             _4addr="client",
                             ssid="wds-ssid3",
                             mode="g",
                             channel="1",
                             position='50,30,0')
    sta1 = net.addStation('sta1', ip="192.168.0.1/24", position='31,32,0')
    sta2 = net.addStation('sta2', ip="192.168.0.2/24", position='32,34,0')
    sta3 = net.addStation('sta3', ip="192.168.0.3/24", position='41,62,0')
    sta4 = net.addStation('sta4', ip="192.168.0.4/24", position='42,64,0')
    sta5 = net.addStation('sta5', ip="192.168.0.5/24", position='51,32,0')
    sta6 = net.addStation('sta6', ip="192.168.0.6/24", position='52,34,0')
    c0 = net.addController('c0',
                           controller=Controller,
                           ip='127.0.0.1',
                           port=6633)

    info("*** Configuring Propagation Model\n")
    net.propagationModel(model="logDistance", exp=4.5)

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

    info("*** Adding Link\n")
    net.addLink(ap1, ap2, cls=_4address)
    net.addLink(ap1, ap3, cls=_4address)
    net.addLink(sta1, ap1)
    net.addLink(sta2, ap1)
    net.addLink(sta3, ap2)
    net.addLink(sta4, ap2)
    net.addLink(sta5, ap3)
    net.addLink(sta6, ap3)

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

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

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

    info("*** Stopping network\n")
    net.stop()
Esempio n. 12
0
def topology():
    "Create a network."
    net = Mininet_wifi(link=wmediumd,
                       wmediumd_mode=interference,
                       configureWiFiDirect=True)

    info("*** Creating nodes\n")
    sta1 = net.addStation('sta1', ip='10.0.0.1/8', position='10,10,0')
    sta2 = net.addStation('sta2', ip='10.0.0.2/8', position='20,20,0')

    info("*** Configuring Propagation Model\n")
    net.setPropagationModel(model="logDistance", exp=3.5)

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

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

    info("*** Starting WiFi Direct\n")
    net.addLink(sta1, cls=wifiDirectLink)
    net.addLink(sta2, cls=wifiDirectLink)

    info("*** Starting network\n")
    net.build()

    sta1.cmd('wpa_cli -ista1-wlan0 p2p_find')
    sta2.cmd('wpa_cli -ista2-wlan0 p2p_find')
    sta2.cmd('wpa_cli -ista2-wlan0 p2p_peers')
    sleep(3)
    sta1.cmd('wpa_cli -ista1-wlan0 p2p_peers')
    sleep(3)
    pin = sta1.cmd('wpa_cli -ista1-wlan0 p2p_connect %s pin auth'
                   % sta2.params['mac'][0])
    sleep(3)
    sta2.cmd('wpa_cli -ista2-wlan0 p2p_connect %s %s'
             % (sta1.params['mac'][0], pin))

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

    info("*** Stopping network\n")
    net.stop()
Esempio n. 13
0
def topology(mobility):
    "Create a network."
    net = Mininet_wifi(link=wmediumd, wmediumd_mode=interference)

    info("*** Creating nodes\n")
    if mobility:
        sta1 = net.addStation('sta1')
        sta2 = net.addStation('sta2')
        sta3 = net.addStation('sta3')
    else:
        sta1 = net.addStation('sta1', position='10,10,0')
        sta2 = net.addStation('sta2', position='50,10,0')
        sta3 = net.addStation('sta3', position='90,10,0')

    info("*** Configuring Propagation Model\n")
    net.setPropagationModel(model="logDistance", exp=4)

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

    info("*** Creating links\n")
    net.addLink(sta1, cls=mesh, ssid='meshNet',
                channel=5, ht_cap='HT40+') #, passwd='thisisreallysecret')
    net.addLink(sta2, cls=mesh, ssid='meshNet',
                channel=5, ht_cap='HT40+') #, passwd='thisisreallysecret')
    net.addLink(sta3, cls=mesh, ssid='meshNet',
                channel=5, ht_cap='HT40+') #, passwd='thisisreallysecret')

    if mobility:
        net.plotGraph(max_x=100, max_y=100)
        net.startMobility(time=0, model='RandomDirection',
                          max_x=100, max_y=100,
                          min_v=0.5, max_v=0.8, seed=20)

    info("*** Starting network\n")
    net.build()

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

    info("*** Stopping network\n")
    net.stop()
def topology():
    "Create a network."
    net = Mininet_wifi(link=wmediumd, wmediumd_mode=interference)

    info("*** Creating nodes\n")
    sta1 = net.addStation('sta1', position='10,10,0', inNamespace=False)
    sta2 = net.addStation('sta2', position='50,10,0')
    sta3 = net.addStation('sta3', position='90,10,0')

    net.propagationModel(model="logDistance", exp=4)

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

    info("*** Creating links\n")
    # intf: physical interface
    net.addLink(sta1,
                cls=physicalMesh,
                intf='wlxf4f26d193319',
                ssid='meshNet',
                channel=5)
    net.addLink(sta2, cls=mesh, ssid='meshNet', channel=5)
    net.addLink(sta3, cls=mesh, ssid='meshNet', channel=5)

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

    info("*** Starting network\n")
    net.build()

    # This is the interface/ip addr of the physical node
    os.system('ip addr add 10.0.0.4/8 dev physta1-mp0')

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

    # Delete the interface created previously
    os.system('iw dev physta1-mp0 del')

    info("*** Stopping network\n")
    net.stop()
def topology():
    "Create a network."
    net = Mininet_wifi(link=wmediumd, wmediumd_mode=interference,
                       configureWiFiDirect=True, autoAssociation=False)

    info("*** Creating nodes\n")
    sta1 = net.addStation('sta1', ip='10.0.0.1/8', position='10,10,0',
                          inNamespace=False)
    sta2 = net.addStation('sta2', ip='10.0.0.2/8', position='20,20,0')

    info("*** Configuring Propagation Model\n")
    net.setPropagationModel(model="logDistance", exp=3.5)

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

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

    info("*** Starting WiFi Direct\n")
    intf='wlxf4f26d193319'
    net.addLink(sta1, cls=physicalWifiDirectLink, intf=intf)
    net.addLink(sta2, cls=wifiDirectLink)

    info("*** Starting network\n")
    net.build()

    sta1.cmd('wpa_cli -ista1-wlan0 p2p_find')
    sta2.cmd('wpa_cli -ista2-wlan0 p2p_find')
    sta2.cmd('wpa_cli -ista2-wlan0 p2p_peers')
    sleep(3)
    sta1.cmd('wpa_cli -ista1-wlan0 p2p_peers')
    sleep(3)
    pin = sta1.cmd('wpa_cli -ista1-wlan0 p2p_connect %s pin auth'
                   % sta2.params['mac'][0])
    sleep(3)
    sta2.cmd('wpa_cli -ista2-wlan0 p2p_connect %s %s'
             % (sta1.params['mac'][0], pin))

    # This is the interface/ip addr of the physical node
    os.system('ip addr add 10.0.0.3/8 dev %s' % intf)

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

    info("*** Stopping network\n")
    net.stop()
Esempio n. 16
0
def topology():
    "Create a network."
    net = Mininet_wifi(link=wmediumd, wmediumd_mode=interference)

    info("*** Creating nodes\n")
    sta1 = net.addStation('sta1', position='10,10,0', inNamespace=False)
    sta2 = net.addStation('sta2', position='50,10,0')
    sta3 = net.addStation('sta3', position='90,10,0')

    net.setPropagationModel(model="logDistance", exp=4)

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

    info("*** Creating links\n")
    # intf: physical interface
    net.addLink(sta1, cls=physicalMesh, intf='wlxf4f26d193319',
                ssid='meshNet', channel=5)
    net.addLink(sta2, cls=mesh, ssid='meshNet', channel=5)
    net.addLink(sta3, cls=mesh, ssid='meshNet', channel=5)

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

    info("*** Starting network\n")
    net.build()

    # This is the interface/ip addr of the physical node
    os.system('ip addr add 10.0.0.4/8 dev physta1-mp0')

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

    # Delete the interface created previously
    os.system('iw dev physta1-mp0 del')

    info("*** Stopping network\n")
    net.stop()
Esempio n. 17
0
def topology():
    "Create a network."
    net = Mininet_wifi(link=wmediumd, wmediumd_mode=interference)

    info("*** Creating nodes\n")
    net.addStation('sta1',
                   ip='192.168.0.1',
                   radius_passwd='sdnteam',
                   encrypt='wpa2',
                   radius_identity='joe',
                   position='110,120,0')
    net.addStation('sta2',
                   ip='192.168.0.2',
                   radius_passwd='hello',
                   encrypt='wpa2',
                   radius_identity='bob',
                   position='200,100,0')
    ap1 = net.addStation('ap1', ip='192.168.0.100', position='150,100,0')
    h1 = net.addHost('h1', ip='10.0.0.100/8')
    s1 = net.addSwitch('s1')
    c0 = net.addController('c0',
                           controller=RemoteController,
                           ip='127.0.0.1',
                           port=6653)

    info("*** Configuring Propagation Model\n")
    net.setPropagationModel(model="logDistance", exp=3.5)

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

    ap1.setMasterMode(intf='ap1-wlan0',
                      ssid='ap1-ssid',
                      channel='1',
                      mode='n',
                      authmode='8021x',
                      encrypt='wpa2',
                      radius_server='10.0.0.100')

    info("*** Associating Stations\n")
    net.addLink(ap1, s1)
    net.addLink(s1, h1)

    info("*** Starting network\n")
    net.build()
    c0.start()
    s1.start([c0])

    ap1.cmd('ifconfig ap1-eth2 10.0.0.200')
    ap1.cmd('ifconfig ap1-wlan0 0')

    h1.cmdPrint('rc.radiusd start')
    ap1.cmd('echo 1 > /proc/sys/net/ipv4/ip_forward')
    s1.cmd('ovs-ofctl add-flow s1 in_port=1,priority=65535,'
           'dl_type=0x800,nw_proto=17,tp_dst=1812,actions=2,controller')

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

    os.system('pkill radiusd')

    info("*** Stopping network\n")
    net.stop()
Esempio n. 18
0
def topology():
    "Create a network."
    net = Mininet_wifi(controller=Controller)

    info("*** Creating nodes\n")
    sta1 = net.addStation('sta1', sixlowpan=1, wpan_ip='2001::1/64')
    sta2 = net.addStation('sta2', sixlowpan=1, wpan_ip='2001::2/64')
    ap1 = net.addAccessPoint('ap1', ssid="simplewifi",
                             mode="g", channel="5", failMode='standalone')

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

    info("*** Associating Stations\n")
    net.addLink(sta1, cls=sixLoWPANLink, panid='0xbeef')
    net.addLink(sta2, cls=sixLoWPANLink, panid='0xbeef')
    net.addLink(sta1, ap1)
    net.addLink(sta2, ap1)

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

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

    info("*** Stopping network\n")
    net.stop()
Esempio n. 19
0
def topology():
    "Create a network."
    net = Mininet_wifi(controller=Controller)

    info("*** Creating nodes\n")
    sta1 = net.addStation('sta1', mac='00:00:00:00:00:02', ip='10.0.0.2/8',
                          range=20)
    sta2 = net.addStation('sta2', mac='00:00:00:00:00:03', ip='10.0.0.3/8',
                          range=20)
    ap1 = net.addAccessPoint('ap1', ssid='ssid-ap1', mode='g', channel='1',
                             position='15,30,0', range=30)
    ap2 = net.addAccessPoint('ap2', ssid='ssid-ap2', mode='g', channel='6',
                             position='55,30,0', range=30)
    c1 = net.addController('c1')

    net.setPropagationModel(model="logDistance", exp=5)

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

    info("*** Creating links\n")
    net.addLink(ap1, ap2)

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

    net.startMobility(time=0)
    net.mobility(sta1, 'start', time=1, position='10,30,0')
    net.mobility(sta2, 'start', time=2, position='10,40,0')
    net.mobility(sta1, 'stop', time=10, position='60,30,0')
    net.mobility(sta2, 'stop', time=10, position='25,40,0')
    net.stopMobility(time=11)

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

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

    info("*** Stopping network\n")
    net.stop()
Esempio n. 20
0
def topology():
    "Create a network."
    net = Mininet_wifi()

    info("*** Creating nodes\n")
    node1 = net.add6LoWPAN('node1', ip='2001::1/64')
    node2 = net.add6LoWPAN('node2', ip='2001::2/64')
    node3 = net.add6LoWPAN('node3', ip='2001::3/64')

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

    info("*** Associating Nodes\n")
    net.addLink(node1, cls=sixLoWPANLink, panid='0xbeef')
    net.addLink(node2, cls=sixLoWPANLink, panid='0xbeef')
    net.addLink(node3, cls=sixLoWPANLink, panid='0xbeef')

    info("*** Starting network\n")
    net.build()

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

    info("*** Stopping network\n")
    net.stop()
def topology():
    "Create a network."
    net = Mininet_wifi()

    info("*** Creating nodes\n")
    sta1 = net.addStation('sta1', passwd='123456789a', encrypt='wpa2')
    sta2 = net.addStation('sta2', passwd='123456789a', encrypt='wpa2')
    ap1 = net.addAccessPoint('ap1', ssid="simplewifi", mode="g", channel="1",
                             passwd='123456789a', encrypt='wpa2',
                             failMode="standalone", datapath='user')

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

    info("*** Associating Stations\n")
    net.addLink(sta1, ap1)
    net.addLink(sta2, ap1)

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

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

    info("*** Stopping network\n")
    net.stop()
def topology():
    "Create a network."
    net = Mininet_wifi(controller=Controller, link=wmediumd,
                       wmediumd_mode=interference,
                       noise_threshold=-91, fading_coefficient=0)

    info("*** Creating nodes\n")
    ap1 = net.addAccessPoint('ap1', ssid='new-ssid', mode='a', channel='36',
                             position='15,30,0')
    net.addStation('sta1', mac='00:00:00:00:00:02', ip='10.0.0.1/8',
                   position='10,20,0')
    net.addStation('sta2', mac='00:00:00:00:00:03', ip='10.0.0.2/8',
                   position='20,50,0')
    net.addStation('sta3', mac='00:00:00:00:00:04', ip='10.0.0.3/8',
                   position='20,60,10')
    c1 = net.addController('c1')

    info("*** Configuring Propagation Model\n")
    net.setPropagationModel(model="logDistance", exp=4)

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

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

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

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

    info("*** Stopping network\n")
    net.stop()
Esempio n. 23
0
def topology():
    "Create a network."
    net = Mininet_wifi(link=wmediumd, wmediumd_mode=interference,
                       configureWiFiDirect=True, autoAssociation=False)

    info("*** Creating nodes\n")
    sta1 = net.addStation('sta1', ip='10.0.0.1/8', position='10,10,0')
    sta2 = net.addStation('sta2', ip='10.0.0.2/8', position='20,20,0')

    info("*** Configuring Propagation Model\n")
    net.propagationModel(model="logDistance", exp=3.5)

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

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

    info("*** Starting WiFi Direct\n")
    net.addLink(sta1, cls=wifiDirectLink)
    net.addLink(sta2, cls=wifiDirectLink)

    info("*** Starting network\n")
    net.build()

    sta1.cmd('wpa_cli -ista1-wlan0 p2p_find')
    sta2.cmd('wpa_cli -ista2-wlan0 p2p_find')
    sta2.cmd('wpa_cli -ista2-wlan0 p2p_peers')
    sleep(3)
    sta1.cmd('wpa_cli -ista1-wlan0 p2p_peers')
    sleep(3)
    pin = sta1.cmd('wpa_cli -ista1-wlan0 p2p_connect %s pin auth'
                   % sta2.params['mac'][0])
    sleep(3)
    sta2.cmd('wpa_cli -ista2-wlan0 p2p_connect %s %s'
             % (sta1.params['mac'][0], pin))

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

    info("*** Stopping network\n")
    net.stop()
def topology():

    "Create a network."
    net = Mininet_wifi( controller=Controller )

    print("*** Creating nodes")
    sta1 = net.addStation( 'sta1', mac='00:00:00:00:00:01',
                           ip='192.168.0.1/24',
                           position='47.28,50,0' )
    sta2 = net.addStation( 'sta2', mac='00:00:00:00:00:02',
                           ip='192.168.0.2/24',
                           position='54.08,50,0' )
    ap3 = net.addAccessPoint( 'ap3', ssid='ap-ssid3', mode='g',
                              channel='1', position='50,50,0' )
    c0 = net.addController('c0', controller=Controller, port=6653)

    print("*** Configuring wifi nodes")
    net.configureWifiNodes()

    print("*** Starting network")
    net.build()
    c0.start()
    ap3.start( [c0] )

    sta1.cmd('iw dev sta1-wlan0 interface add mon0 type monitor')
    sta1.cmd('ip link set mon0 up')
    sta2.cmd('iw dev sta2-wlan0 interface add mon0 type monitor')
    sta2.cmd('ip link set mon0 up')
    if py_version_info < (3, 0):
        sta2.cmd('pushd /home/alpha/Downloads; '
                 'python -m SimpleHTTPServer 80 &')
    else:
        sta2.cmd('pushd /home/alpha/Downloads; '
                 'python -m http.server 80 &')

    path = os.path.dirname(os.path.abspath(__file__))
    getTrace(sta1, '%s/replayingNetworkConditions/'
                   'clientTrace.txt' % path)
    getTrace(sta2, '%s/replayingNetworkConditions/'
                   'serverTrace.txt' % path)

    replayingNetworkConditions.addNode(sta1)
    replayingNetworkConditions.addNode(sta2)
    replayingNetworkConditions(net)

    #sta1.cmd('tcpdump -i mon0 -s 0 -vvv -w client.pcap &&')
    #sta2.cmd('tcpdump -i mon0 -s 0 -vvv -w server.pcap &&')
    #sta1 tcpdump -i mon0 -s 0 -vvv -w client.pcap && sta1 wget http://192.168.0.2/virtualbox-5.0_5.0.20-106931~Ubuntu~xenial_amd64.deb
    #sta1.cmd('wget http://'+sta2.IP()+'/virtualbox-5.0_5.0.20-106931~Ubuntu~xenial_amd64.deb')

    #sta1.cmd('nohup ping ' + sta2.IP() + ' -c 180 > ping1.log &')
    #sta2.cmd('nohup ping ' + sta1.IP() + ' -c 180 > ping2.log &')
    #sta2.cmd('iperf -s &')
    #sta1.cmd('iperf -c ' + sta2.IP() + ' -i 0.5 -t 60 | awk \'t=120{if(NR>=7 && NR<=25) print $8; else if(NR>=26 && NR<=t+6) print $7}\' > replay1.dat')
    #sta2.cmd('iperf -c ' + sta1.IP() + ' -i 0.5 -t 60 | awk \'t=120{if(NR>=7 && NR<=25) print $8; else if(NR>=26 && NR<=t+6) print $7}\' > replay2.dat &')

    print("*** Running CLI")
    CLI_wifi( net )

    print("*** Stopping network")
    net.stop()
Esempio n. 25
0
def topology(args):
    "Create a network."
    net = Mininet_wifi()

    info("*** Creating nodes\n")
    if '-s' in args:
        sta1 = net.addStation('sta1',
                              mac='00:00:00:00:00:02',
                              ip='10.0.0.2/8',
                              position='20,30,0')
        sta2 = net.addStation('sta2',
                              mac='00:00:00:00:00:03',
                              ip='10.0.0.3/8',
                              position='60,30,0')
    else:
        sta1 = net.addStation('sta1',
                              mac='00:00:00:00:00:02',
                              ip='10.0.0.2/8',
                              range=20)
        sta2 = net.addStation('sta2',
                              mac='00:00:00:00:00:03',
                              ip='10.0.0.3/8',
                              range=20)
    ap1 = net.addAccessPoint('ap1',
                             ssid='ssid-ap1',
                             mode='g',
                             channel='1',
                             position='15,30,0',
                             range=30)
    ap2 = net.addAccessPoint('ap2',
                             ssid='ssid-ap2',
                             mode='g',
                             channel='6',
                             position='55,30,0',
                             range=30)
    c1 = net.addController('c1')

    net.setPropagationModel(model="logDistance", exp=5)

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

    info("*** Creating links\n")
    net.addLink(ap1, ap2)

    if '-p' not in args:
        net.plotGraph(max_x=100, max_y=100)

    if '-s' not in args:
        net.startMobility(time=0)
        net.mobility(sta1, 'start', time=1, position='10,30,0')
        net.mobility(sta2, 'start', time=2, position='10,40,0')
        net.mobility(sta1, 'stop', time=10, position='60,30,0')
        net.mobility(sta2, 'stop', time=10, position='25,40,0')
        net.stopMobility(time=11)

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

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

    info("*** Stopping network\n")
    net.stop()
Esempio n. 26
0
def topology():

    "Create a network."
    net = Mininet_wifi(controller=Controller, accessPoint=UserAP,
                       link=wmediumd, wmediumd_mode=interference)

    info("*** Creating nodes\n")
    cars = []
    for id in range(0, 10):
        cars.append(net.addCar('car%s' % (id+1), wlans=2))

    e1 = net.addAccessPoint('e1', ssid='vanet-ssid', mac='00:00:00:11:00:01',
                            mode='g', channel='1', passwd='123456789a',
                            encrypt='wpa2', position='3279.02,3736.27,0')
    e2 = net.addAccessPoint('e2', ssid='vanet-ssid', mac='00:00:00:11:00:02',
                            mode='g', channel='6', passwd='123456789a',
                            encrypt='wpa2', position='2320.82,3565.75,0')
    e3 = net.addAccessPoint('e3', ssid='vanet-ssid', mac='00:00:00:11:00:03',
                            mode='g', channel='11', passwd='123456789a',
                            encrypt='wpa2', position='2806.42,3395.22,0')
    e4 = net.addAccessPoint('e4', ssid='vanet-ssid', mac='00:00:00:11:00:04',
                            mode='g', channel='1', passwd='123456789a',
                            encrypt='wpa2', position='3332.62,3253.92,0')
    e5 = net.addAccessPoint('e5', ssid='vanet-ssid', mac='00:00:00:11:00:05',
                            mode='g', channel='6', passwd='123456789a',
                            encrypt='wpa2', position='2887.62,2935.61,0')
    e6 = net.addAccessPoint('e6', ssid='vanet-ssid', mac='00:00:00:11:00:06',
                            mode='g', channel='11', passwd='123456789a',
                            encrypt='wpa2', position='2351.68,3083.40,0')
    c1 = net.addController('c1')

    info("*** Setting bgscan\n")
    net.setBgscan(signal=-45, s_inverval=5, l_interval=10)

    info("*** Configuring Propagation Model\n")
    net.setPropagationModel(model="logDistance", exp=2)

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

    net.addLink(e1, e2)
    net.addLink(e2, e3)
    net.addLink(e3, e4)
    net.addLink(e4, e5)
    net.addLink(e5, e6)
    for car in cars:
        net.addLink(car, intf=car.params['wlan'][1],
                    cls=mesh, ssid='mesh-ssid', channel=5)

    net.useExternalProgram(program=sumo, port=8813,
                           config_file='map.sumocfg')

    info("*** Starting network\n")
    net.build()
    c1.start()
    e1.start([c1])
    e2.start([c1])
    e3.start([c1])
    e4.start([c1])
    e5.start([c1])
    e6.start([c1])

    for car in cars:
        car.setIP('192.168.0.%s/24' % (int(cars.index(car))+1),
                  intf='%s-wlan0' % car)
        car.setIP('192.168.1.%s/24' % (int(cars.index(car))+1),
                  intf='%s-mp1' % car)

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

    info("*** Stopping network\n")
    net.stop()
def topology(isVirtual):
    "Create a network."
    net = Mininet_wifi()

    info("*** Creating nodes\n")
    if isVirtual:
        sta1 = net.addStation('sta1', nvif=2)
        ap1 = net.addAccessPoint('ap1', ssid="simpletopo",
                                 mode="g", channel="5")
    else:
        sta1 = net.addStation('sta1')
        # isolate_clientes: Client isolation can be used to prevent low-level
        # bridging of frames between associated stations in the BSS.
        # By default, this bridging is allowed.
        # OpenFlow rules are required to allow communication among nodes
        ap1 = net.addAccessPoint('ap1', ssid="simpletopo",
                                 client_isolation=True, mode="g", channel="5")
    sta2 = net.addStation('sta2')
    c0 = net.addController('c0')

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

    info("*** Associating Stations\n")
    net.addLink(sta1, ap1)
    net.addLink(sta2, ap1)

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

    if not isVirtual:
        ap1.cmd('ovs-ofctl add-flow ap1 "priority=0,arp,in_port=1,'
                'actions=output:in_port,normal"')
        ap1.cmd('ovs-ofctl add-flow ap1 "priority=0,icmp,in_port=1,'
                'actions=output:in_port,normal"')
        ap1.cmd('ovs-ofctl add-flow ap1 "priority=0,udp,in_port=1,'
                'actions=output:in_port,normal"')
        ap1.cmd('ovs-ofctl add-flow ap1 "priority=0,tcp,in_port=1,'
                'actions=output:in_port,normal"')

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

    info("*** Stopping network\n")
    net.stop()
Esempio n. 28
0
def topology():
    "Create a network."
    net = Mininet_wifi()

    info("*** Creating nodes\n")
    net.addStation('sta1', mac='00:00:00:00:00:02', ip='10.0.0.2/8',
                   min_x=10, max_x=30, min_y=50, max_y=70, min_v=5, max_v=10)
    net.addStation('sta2', mac='00:00:00:00:00:03', ip='10.0.0.3/8',
                   min_x=60, max_x=70, min_y=10, max_y=20, min_v=1, max_v=5)
    ap1 = net.addAccessPoint('ap1', ssid='new-ssid', mode='g', channel='1',
                             failMode="standalone", position='50,50,0')

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

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

    net.setMobilityModel(time=0, model='RandomDirection', max_x=100, max_y=100,
                         seed=20)

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

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

    info("*** Stopping network\n")
    net.stop()
def topology():

    "Create a network."
    net = Mininet_wifi(controller=Controller, link=wmediumd,
                       wmediumd_mode=interference)

    info("*** Creating nodes\n")
    ap1 = net.addAccessPoint('ap1', ssid='new-ssid', mode='a', channel='36',
                             position='150,150,0')
    net.addStation('sta1', mac='00:00:00:00:00:02', ip='10.0.0.2/8')
    net.addStation('sta2', mac='00:00:00:00:00:03', ip='10.0.0.3/8')
    c1 = net.addController('c1')

    info("*** Configuring Propagation Model\n")
    net.setPropagationModel(model="logDistance", exp=3)

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

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

    net.setMobilityModel(time=0, model='RandomDirection', max_x=300, max_y=300,
                         min_v=0.5, max_v=0.8, seed=20)

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

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

    info("*** Stopping network\n")
    net.stop()
Esempio n. 30
0
def topology():
    "Create a network."
    net = Mininet_wifi(controller=Controller, link=wmediumd,
                       wmediumd_mode=interference, configure4addr=True)

    info("*** Creating nodes\n")
    ap1 = net.addAccessPoint('ap1', ssid="ap1-ssid", mode="g",
                             channel="1", position='30,30,0')
    ap2 = net.addAccessPoint('ap2', ssid="ap2-ssid", mode="g",
                             channel="1", position='40,60,0')
    ap3 = net.addAccessPoint('ap3', ssid="ap3-ssid", mode="g",
                             channel="1", position='50,30,0')
    sta1 = net.addStation('sta1', ip="192.168.0.1/24", position='31,32,0')
    sta2 = net.addStation('sta2', ip="192.168.0.2/24", position='32,34,0')
    sta3 = net.addStation('sta3', ip="192.168.0.3/24", position='41,62,0')
    sta4 = net.addStation('sta4', ip="192.168.0.4/24", position='42,64,0')
    sta5 = net.addStation('sta5', ip="192.168.0.5/24", position='51,32,0')
    sta6 = net.addStation('sta6', ip="192.168.0.6/24", position='52,34,0')
    c0 = net.addController('c0')

    info("*** Configuring Propagation Model\n")
    net.setPropagationModel(model="logDistance", exp=4.5)

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

    info("*** Adding Link\n")
    net.addLink(ap1, ap2, cls=_4address) # ap1=ap, ap2=client
    net.addLink(ap1, ap3, cls=_4address) # ap1=ap, ap3=client
    net.addLink(sta1, ap1)
    net.addLink(sta2, ap1)
    net.addLink(sta3, ap2)
    net.addLink(sta4, ap2)
    net.addLink(sta5, ap3)
    net.addLink(sta6, ap3)

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

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

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

    info("*** Stopping network\n")
    net.stop()
Esempio n. 31
0
def topology():
    "Create a network."
    net = Mininet_wifi(link=wmediumd, wmediumd_mode=interference)

    info("*** Creating nodes\n")
    sta1 = net.addStation('sta1', ip='10.0.0.1/8',
                          position='10,10,0', channel='161')
    sta2 = net.addStation('sta2', ip='10.0.0.2/8',
                          position='20,20,0', channel='161')

    info("*** Configuring Propagation Model\n")
    net.setPropagationModel(model="logDistance", exp=3.5)

    net.setModule('./mac80211_hwsim.ko')

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

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

    info("*** Starting WiFi Direct\n")
    net.addLink(sta1, cls=ITSLink)
    net.addLink(sta2, cls=ITSLink)

    info("*** Starting network\n")
    net.build()

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

    info("*** Stopping network\n")
    net.stop()
Esempio n. 32
0
def topology(coord):
    "Create a network."
    net = Mininet_wifi(controller=Controller)

    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')

    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()
def topology():

    "Create a network."
    net = Mininet_wifi(controller=Controller, link=wmediumd,
                       wmediumd_mode=error_prob)

    info("*** Creating nodes\n")
    ap1 = net.addAccessPoint('ap1', ssid='new-ssid', mode='a', channel='36',
                             position='15,30,0')
    sta1 = net.addStation('sta1', mac='00:00:00:00:00:02', ip='10.0.0.1/8',
                          position='10,20,0')
    sta2 = net.addStation('sta2', mac='00:00:00:00:00:03', ip='10.0.0.2/8',
                          position='20,50,0')
    sta3 = net.addStation('sta3', mac='00:00:00:00:00:04', ip='10.0.0.3/8',
                          position='20,60,10')
    c1 = net.addController('c1')

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

    net.addLink(sta1, ap1, error_prob=0.01)
    net.addLink(sta2, ap1, error_prob=0.02)
    net.addLink(sta3, ap1, error_prob=1)

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

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

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

    info("*** Stopping network\n")
    net.stop()
def topology():
    "Create a network."
    net = Mininet_wifi(controller=Controller)

    info("*** Creating nodes\n")
    net.addStation('sta1', mac='00:00:00:00:00:02', ip='10.0.0.2/8')
    net.addStation('sta2', mac='00:00:00:00:00:03', ip='10.0.0.3/8')
    net.addStation('sta3', mac='00:00:00:00:00:04', ip='10.0.0.4/8')
    net.addStation('sta4', mac='00:00:00:00:00:05', ip='10.0.0.5/8')
    net.addStation('sta5', mac='00:00:00:00:00:06', ip='10.0.0.6/8')
    net.addStation('sta6', mac='00:00:00:00:00:07', ip='10.0.0.7/8')
    net.addStation('sta7', mac='00:00:00:00:00:08', ip='10.0.0.8/8')
    net.addStation('sta8', mac='00:00:00:00:00:09', ip='10.0.0.9/8')
    net.addStation('sta9', mac='00:00:00:00:00:10', ip='10.0.0.10/8')
    net.addStation('sta10', mac='00:00:00:00:00:11', ip='10.0.0.11/8')
    ap1 = net.addAccessPoint('ap1', ssid='ssid-ap1', mode='g', channel='1',
                             position='50,50,0')
    ap2 = net.addAccessPoint('ap2', ssid='ssid-ap2', mode='g', channel='6',
                             position='70,50,0', range=30)
    ap3 = net.addAccessPoint('ap3', ssid='ssid-ap3', mode='g', channel='11',
                             position='90,50,0')
    c1 = net.addController('c1')

    net.setPropagationModel(model="logDistance", exp=5)

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

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

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

    net.setMobilityModel(time=0, model='RandomWayPoint', max_x=120, max_y=120,
                         min_v=0.3, max_v=0.5, seed=1, ac_method='ssf')

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

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

    info("*** Stopping network\n")
    net.stop()
Esempio n. 35
0
def topology(autoTxPower):
    "Create a network."
    net = Mininet_wifi(link=wmediumd, wmediumd_mode=interference)

    info("*** Creating nodes\n")
    if autoTxPower:
        sta1 = net.addStation('sta1', position='10,10,0', range=100)
        sta2 = net.addStation('sta2', position='50,10,0', range=100)
        sta3 = net.addStation('sta3', position='90,10,0', range=100)
    else:
        sta1 = net.addStation('sta1', position='10,10,0')
        sta2 = net.addStation('sta2', position='50,10,0')
        sta3 = net.addStation('sta3', position='90,10,0')

    net.setPropagationModel(model="logDistance", exp=4)

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

    info("*** Creating links\n")
    net.addLink(sta1, cls=adhoc, ssid='adhocNet',
                mode='g', channel=5, ht_cap='HT40+')
    net.addLink(sta2, cls=adhoc, ssid='adhocNet',
                mode='g', channel=5)
    net.addLink(sta3, cls=adhoc, ssid='adhocNet',
                mode='g', channel=5, ht_cap='HT40+')

    info("*** Starting network\n")
    net.build()

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

    info("*** Stopping network\n")
    net.stop()
def topology():
    "Create a network."
    net = Mininet_wifi(controller=Controller, accessPoint=UserAP,
                       link=wmediumd, wmediumd_mode=interference)

    info("*** Creating nodes\n")
    net.addStation('sta1', position='15,20,0')
    ap1 = net.addAccessPoint('ap1', mac='00:00:00:00:00:01', ssid="handover",
                             mode="g", channel="1", passwd='123456789a',
                             encrypt='wpa2', position='10,30,0')
    ap2 = net.addAccessPoint('ap2', mac='00:00:00:00:00:02', ssid="handover",
                             mode="g", channel="6", passwd='123456789a',
                             encrypt='wpa2', position='60,30,0')
    ap3 = net.addAccessPoint('ap3', mac='00:00:00:00:00:03', ssid="handover",
                             mode="g", channel="1", passwd='123456789a',
                             encrypt='wpa2', position='120,100,0')
    c1 = net.addController('c1')

    info("*** Configuring Propagation Model\n")
    net.setPropagationModel(model="logDistance", exp=3.5)

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

    info("*** Creating links\n")
    net.addLink(ap1, ap2)
    net.addLink(ap2, ap3)

    info("*** Setting bgscan\n")
    net.setBgscan(signal=-60, s_inverval=5, l_interval=10)

    net.plotGraph(min_x=-100, min_y=-100, max_x=200, max_y=200)

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

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

    info("*** Stopping network\n")
    net.stop()
Esempio n. 37
0
def topology():
    "Create a network."
    net = Mininet_wifi(link=wmediumd,
                       wmediumd_mode=interference,
                       noise_th=-91,
                       fading_cof=3)

    info("*** Creating nodes\n")
    ap1 = net.addAccessPoint('ap1',
                             ssid='new-ssid',
                             mode='a',
                             channel='36',
                             position='15,30,0')
    net.addStation('sta1',
                   mac='00:00:00:00:00:02',
                   ip='10.0.0.1/8',
                   position='10,20,0')
    net.addStation('sta2',
                   mac='00:00:00:00:00:03',
                   ip='10.0.0.2/8',
                   position='20,50,0')
    c1 = net.addController('c1')

    info("*** Configuring wifi nodes\n")
    net.configureWifiNodes()
    net.plotGraph(max_x=100, max_y=100)

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

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

    info("*** Stopping network\n")
    net.stop()
def topology():
    "Create a network."
    net = Mininet_wifi(controller=Controller, link=wmediumd,
                       wmediumd_mode=interference)

    info("*** Creating nodes\n")
    sta1 = net.addStation('sta1', mac='00:00:00:00:00:02',
                          ip='10.0.0.1/8', speed=4)
    sta2 = net.addStation('sta2', mac='00:00:00:00:00:03',
                          ip='10.0.0.2/8', speed=6)
    sta3 = net.addStation('sta3', mac='00:00:00:00:00:04',
                          ip='10.0.0.3/8', speed=3)
    sta4 = net.addStation('sta4', mac='00:00:00:00:00:05',
                          ip='10.0.0.4/8', speed=3)
    ap1 = net.addAccessPoint('ap1', ssid='new-ssid',
                             mode='g', channel='1',
                             position='45,45,0')
    c1 = net.addController('c1', controller=Controller)

    info("*** Configuring Propagation Model\n")
    net.setPropagationModel(model="logDistance", exp=4.5)

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

    info("*** Creating links\n")
    net.addLink(sta3, cls=adhoc, ssid='adhocNet')
    net.addLink(sta4, cls=adhoc, ssid='adhocNet')

    path = os.path.dirname(os.path.abspath(__file__))
    getTrace(sta1, '%s/replayingMobility/node1.dat' % path, net)
    getTrace(sta2, '%s/replayingMobility/node2.dat' % path, net)
    getTrace(sta3, '%s/replayingMobility/node3.dat' % path, net)
    getTrace(sta4, '%s/replayingMobility/node4.dat' % path, net)

    'ploting graph'
    net.plotGraph(max_x=200, max_y=200)

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

    replayingMobility(net)

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

    info("*** Stopping network\n")
    net.stop()
Esempio n. 39
0
def topology(D2D, AP):
    "Create a network."
    net = Mininet_wifi(link=wmediumd, wmediumd_mode=interference)

    info("*** Creating nodes\n")
    sta1 = net.addStation('sta1',
                          wlans=2,
                          position='5,5,0',
                          ip='10.0.0.1/8,10.0.0.2/8',
                          mac='00:00:00:00:00:01,00:00:00:00:00:02')
    sta2 = net.addStation('sta2',
                          wlans=2,
                          position='15,5,0',
                          ip='10.0.0.3/8,10.0.0.4/8',
                          mac='00:00:00:00:00:03,00:00:00:00:00:04')
    if AP:
        ap1 = net.addAccessPoint('ap1',
                                 ssid='ssid-ap1',
                                 mode='g',
                                 channel='1',
                                 position='10,10,0',
                                 ip='10.0.0.5/8')
    c1 = net.addController('c1')

    net.setPropagationModel(model="logDistance", exp=5)

    info("*** Configuring wifi nodes\n")
    net.configureWifiNodes()
    net.plotGraph(max_x=20, max_y=20)

    # sta1.cmd('ifconfig %s up' % sta1.params['wlan'][0])
    # sta1.cmd('wireshark -i sta1-wlan0 &')
    #
    # sta1.cmd('ifconfig %s up' % sta1.params['wlan'][1])
    # sta1.cmd('wireshark -i sta1-wlan1 &')

    # sta1.cmd('iw dev %s interface add mon0 type monitor' % sta1.params['wlan'][0])
    # sta1.cmd('ifconfig mon0 up')
    # sta1.cmd('wireshark -i mon0 &')
    #
    # sta1.cmd('iw dev %s interface add mon1 type monitor' % sta1.params['wlan'][1])
    # sta1.cmd('ifconfig mon1 up')
    # sta1.cmd('wireshark -i mon1 &')

    info("*** Creating links\n")
    if AP:
        net.addLink(ap1, sta1)
        net.addLink(ap1, sta2)
    if D2D:
        net.addLink(sta1,
                    cls=adhoc,
                    ssid='adhocNet',
                    mode='g',
                    channel=5,
                    ht_cap='HT40+')
        net.addLink(sta2, cls=adhoc, ssid='adhocNet', mode='g', channel=5)

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

    info("*** Print network status messages\n")
    info("\nsta1 status:\n")
    info('%s\n' % sta1.cmd('iwconfig'))
    info("sta2 status:\n")
    info('%s\n' % sta2.cmd('iwconfig'))

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

    info("*** Stopping network\n")
    net.stop()
Esempio n. 40
0
def topology():
    "creating the scenarios and capturing the latency values for each scenario."

    os.system("sudo mn -c 2>> /dev/null")

    ip = sys.argv[1]
    port = int(sys.argv[2])
    controllerName = sys.argv[3]
    nodesQuantity = int(sys.argv[4])
    flag = sys.argv[5]
    repeat_number = int(sys.argv[6])

    number_of_samples = ['0']
    subscribers = []
    publishers = []
    #broker_ip = "mqtt.eclipse.org"
    broker_ip = "2001::101"
    broker_port = 1883

    stations = []
    experimentName = 'latencia_'
    ipv6_extension = 0

    light_topic = ""
    door_topic = ""

    house_light_topics = []
    house_door_topics = []
    index = -1

    net = Mininet_wifi(controller=None)
    c0 = net.addController('c0', controller=RemoteController, ip=ip, port=port)

    info("*** Creating nodes\n")

    for i in range(nodesQuantity + 1):
        nodeName = 'node{}'.format(i + 1)
        nodeIp = '2001::{}/64'.format(i + 1)
        stations.append({
            nodeName:
            net.add6LoWPAN(nodeName,
                           ip=nodeIp,
                           position='{},{},0'.format(random.randint(0, 1000),
                                                     random.randint(0, 1000)))
        })

    # Add MQTT broker server
    #broker = net.add6LoWPAN( 'node{}'.format(101), ip='2001::101/64', position='{},{},0'.format(random.randint( 0, 1000 ), random.randint( 0, 1000 ) ) )

    ap1 = net.addAccessPoint('ap1',
                             ssid="simplewifi",
                             mode="g",
                             channel="5",
                             failMode='standalone',
                             position='875.0,476.0,0')
    net.setPropagationModel(model="logDistance", exp=3)

    info("*** Configuring wifi nodes\n")
    rsul = net.configureWifiNodes()
    print "o resultado {}".format(rsul)

    info("*** Associating Stations\n")
    for i in range(nodesQuantity + 1):
        net.addLink(stations[i]['node{}'.format(i + 1)],
                    cls=sixLoWPANLink,
                    panid='0xbeef')
        net.addLink(stations[i]['node{}'.format(i + 1)], ap1)

    #net.addLink( broker, cls=sixLoWPANLink, panid='0xbeef')
    #net.addLink( broker, ap1 )

    info("*** Starting network\n")
    net.build()

    ap1.start([c0])
    net.start()

    #station1 = net.get('sta1')
    #result = station1.cmd('ping6 -c10000 -i 0.0 -s {} {} >> ~/TCC/Experimento/resultados_experimento/{}_Nos_{}/{}{}_Numero_de_Nos_{}.txt'.format(random.randint(599, 999), '2001::2', controllerName, nodesQuantity, experimentName, controllerName, nodesQuantity))
    #info(result)
    #info("IP sta1 {}".format(station1.IP()))

    # configurnado o broker MQTT
    server = nodesQuantity + 1  #random.randint( 1, nodesQuantity )
    broker_node = net.get('node{}'.format(str(server)))
    broker_node.cmd('mosquitto &')
    os.system('sleep 10')

    # configurando os assinantes e a qual topicos estao assinando
    subscribers = random.sample(range(1, nodesQuantity + 1),
                                (nodesQuantity / 2))
    random.shuffle(subscribers)

    #if server in subscribers:
    #subscribers.remove(server)

    for node in range(1, nodesQuantity + 1):
        if node not in subscribers:
            publishers.append(node)

    random.shuffle(publishers)

    #if server in publishers:
    #publishers.remove(server)

    for subscriber in subscribers:
        subscriber_node = net.get("node{}".format(str(subscriber)))

        light_topic = "houseqxdlightnode{}".format(str(subscriber))
        door_topic = "houseqxddoornode{}".format(str(subscriber))

        subscriber_node.cmd(
            'mosquitto_sub -h {} -t {} >> ~/TCC/Experimento/resultados_experimento/{}_Nos_{}/mqtt/node{}_light.txt &'
            .format('2001::{}'.format(str(server)), light_topic,
                    controllerName, nodesQuantity, str(subscriber)))
        subscriber_node.cmd(
            'mosquitto_sub -h {} -t {} >> ~/TCC/Experimento/resultados_experimento/{}_Nos_{}/mqtt/node{}_door.txt &'
            .format('2001::{}'.format(str(server)), door_topic, controllerName,
                    nodesQuantity, str(subscriber)))

        house_light_topics.append(light_topic)
        house_door_topics.append(door_topic)

    print house_light_topics
    print house_door_topics

    # configurando os publicadores
    # mudar configuração para ip porta e topic rever entradas do código mqtt_publisher
    for publisher in publishers:
        index += 1
        publisher_node = net.get("node{}".format(str(publisher)))

        #publisher_node.cmd("echo {} >> {}".format(house_light_topics[index], "~/log_light_mqtt{}_{}_{}.txt".format(controllerName, nodesQuantity, index)))
        #publisher_node.cmd("echo {} >> {}".format(house_door_topics[index], "~/log_door_mqtt{}_{}_{}.txt".format(controllerName, nodesQuantity, index)))

        publisher_node.cmd(
            'sudo ~/TCC/Experimento/./mqtt_publisher.sh 2001::{} {} &'.format(
                str(server), house_light_topics[index]))
        publisher_node.cmd(
            'sudo ~/TCC/Experimento/./mqtt_publisher.sh 2001::{} {} &'.format(
                str(server), house_door_topics[index]))

        #publisher_node.cmd('mosquitto_pub -h {} -t {} -m `date`'.format('2001::{}'.format(str(server)), house_light_topics[ index ] ) )
        #publisher_node.cmd('mosquitto_pub -h {} -t {} -m `date`'.format('2001::{}'.format(str(server)), house_door_topics[ index ] ) )

        # Percorre para cada station
    for sta in range(nodesQuantity):
        station = net.get("node{}".format(str(sta + 1)))
        ipv6_extension = sta + 2

        if ipv6_extension > nodesQuantity:
            ipv6_extension = 1

        station.cmd(
            'ping6 -c500 -i 0.0 -s {} {} >> ~/TCC/Experimento/resultados_experimento/{}_Nos_{}/{}{}_Numero_de_Nos_{}.txt'
            .format(9999, '2001::{}'.format(ipv6_extension), controllerName,
                    nodesQuantity, experimentName, controllerName,
                    nodesQuantity))

    #while True:


#	number_of_samples = os.popen("cat ~/TCC/Experimento/resultados_experimento/{}_Nos_{}/{}{}_Numero_de_Nos_{}.txt | grep rtt | wc -l".format(controllerName, nodesQuantity, experimentName, controllerName, nodesQuantity)).read().splitlines()
#	print int(number_of_samples[0])

#	if repeat_number * nodesQuantity == int(number_of_samples[0]):
#	    break

    if controllerName == "Floodlight":
        if flag == "run":
            info("{}.\n".format("runing"))
        else:
            # result = os.popen("ps -ef | grep \"java -jar target/floodlight.jar\" | head -n1").read()
            # info(result)

            #result = filter(None, result.split(" "))
            #info(result[1])

            cmd = "sudo pkill {} 2>> /dev/null > /dev/null".format("java")
            os.system(cmd)
            os.system("sudo kill $(ps aux | awk '/mosquitto/ {print $2}')")
            os.system("sudo kill $(ps aux | awk '/floodlight/ {print $2}')")

    if controllerName == "POX":
        if flag == "run":
            info("{}.\n".format("runing"))
        else:
            os.system("echo {} >> ~/pox/log".format("stopping"))

            result = os.popen(
                "ps -ef | grep \"pox.py pox.forwarding.hub openflow.of_01\" | grep -v color=auto | head -n1"
            ).read()
            result = filter(None, result.split(" "))
            process1 = result[1]

            result = os.popen(
                "ps -ef | grep \"pox.py pox.forwarding.hub openflow.of_01\"| head -n2 | grep -v color=auto | tail -n1"
            ).read()
            result = filter(None, result.split(" "))
            process2 = result[1]

            cmd = "sudo kill -9 {} 2>> /dev/null > /dev/null".format(process1)
            os.system(cmd)
            #os.system("echo Matando o Primeiro Proceso {} >> ~/pox/log".format(process1))

            cmd = "sudo kill -9 {} 2>> /dev/null > /dev/null".format(process2)
            os.system(cmd)
            #os.system("echo Matando o Segundo Proceso {} >> ~/pox/log".format(process2))
            os.system("sudo kill $(ps aux | awk '/mosquitto/ {print $2}')")
            os.system("sudo kill $(ps aux | awk '/pox/ {print $2}')")

    if controllerName == "Ryu":
        if flag == "run":
            info("{}.\n".format("runing"))
        else:

            result = os.popen(
                "ps -ef | grep \"sudo PYTHONPATH=. ./bin/ryu run --observe-links ryu/app/gui_topology/gui_topology.py --ofp-tcp-listen-port=6636\" | grep -v color=auto | head -n1"
            ).read()
            result = filter(None, result.split(" "))
            process1 = result[1]

            result = os.popen(
                "ps -ef | grep \"python ./bin/ryu run --observe-links ryu/app/gui_topology/gui_topology.py --ofp-tcp-listen-port=6636\" | grep -v color=auto | head -n1"
            ).read()
            result = filter(None, result.split(" "))
            process2 = result[1]

            cmd = "sudo kill -9 {} 2>> /dev/null > /dev/null".format(process1)
            os.system(cmd)
            #info("Matando o Primeiro Proceso {}.\n".format(process1))

            cmd = "sudo kill -9 {} 2>> /dev/null > /dev/null".format(process2)
            os.system(cmd)
            #	    info("Matando o Segundo Proceso {}.\n".format(process2))
            os.system("sudo kill $(ps aux | awk '/mosquitto/ {print $2}')")
            os.system("sudo kill $(ps aux | awk '/ryu/ {print $2}')")

    info("*** Stopping network\n")
    net.stop()
Esempio n. 41
0
def topology():
    "Create a network."
    net = Mininet_wifi(controller=Controller,
                       link=wmediumd,
                       wmediumd_mode=interference)

    info("*** Creating nodes\n")
    sta1 = net.addAccessPoint('sta1',
                              ip='192.168.0.1/24',
                              position='10,10,0',
                              cls=UserAP,
                              inNamespace=True)
    sta2 = net.addAccessPoint('sta2',
                              ip='192.168.0.2/24',
                              position='10,20,0',
                              cls=UserAP,
                              inNamespace=True)
    c0 = net.addController('c0')

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

    info("*** Associating Stations\n")
    net.addLink(sta1, intf='sta1-wlan1', cls=mesh, ssid='mesh-ssid', channel=5)
    net.addLink(sta2, intf='sta2-wlan1', cls=mesh, ssid='mesh-ssid', channel=5)

    info("*** Starting network\n")
    net.build()
    c0.start()
    sta1.start([c0])
    sta2.start([c0])

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

    info("*** Stopping network\n")
    net.stop()
Esempio n. 42
0
def topology():
    "Create a network."
    net = Mininet_wifi(controller=Controller,
                       link=wmediumd,
                       wmediumd_mode=interference)

    info("*** Creating nodes\n")
    sta1 = net.addStation('sta1',
                          mac='00:00:00:00:00:02',
                          ip='10.0.0.1/8',
                          speed=4)
    sta2 = net.addStation('sta2',
                          mac='00:00:00:00:00:03',
                          ip='10.0.0.2/8',
                          speed=6)
    sta3 = net.addStation('sta3',
                          mac='00:00:00:00:00:04',
                          ip='10.0.0.3/8',
                          speed=3)
    sta4 = net.addStation('sta4',
                          mac='00:00:00:00:00:05',
                          ip='10.0.0.4/8',
                          speed=3)
    ap1 = net.addAccessPoint('ap1',
                             ssid='new-ssid',
                             mode='g',
                             channel='1',
                             position='45,45,0')
    c1 = net.addController('c1', controller=Controller)

    info("*** Configuring Propagation Model\n")
    net.setPropagationModel(model="logDistance", exp=4.5)

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

    info("*** Creating links\n")
    net.addLink(sta3, cls=adhoc, intf='sta3-wlan0', ssid='adhocNet')
    net.addLink(sta4, cls=adhoc, intf='sta4-wlan0', ssid='adhocNet')

    path = os.path.dirname(os.path.abspath(__file__))
    getTrace(sta1, '%s/replayingMobility/node1.dat' % path, net)
    getTrace(sta2, '%s/replayingMobility/node2.dat' % path, net)
    getTrace(sta3, '%s/replayingMobility/node3.dat' % path, net)
    getTrace(sta4, '%s/replayingMobility/node4.dat' % path, net)

    'ploting graph'
    net.plotGraph(max_x=200, max_y=200)

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

    replayingMobility(net)

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

    info("*** Stopping network\n")
    net.stop()
Esempio n. 43
0
def topology():
    "Create a network."
    net = Mininet_wifi(controller=RemoteController,
                       accessPoint=UserAP,
                       switch=UserSwitch,
                       link=wmediumd,
                       wmediumd_mode=interference)

    info("*** Creating nodes\n")
    sta1 = net.addStation('sta1', position='15,20,0')
    sta2 = net.addStation('sta2', position='35,20,0')
    ap1 = net.addAccessPoint('ap1',
                             mac='00:00:00:00:00:01',
                             ssid="handover",
                             mode="g",
                             channel="1",
                             passwd='123456789a',
                             encrypt='wpa2',
                             position='10,30,0')
    ap2 = net.addAccessPoint('ap2',
                             mac='00:00:00:00:00:02',
                             ssid="handover",
                             mode="g",
                             channel="6",
                             passwd='123456789a',
                             encrypt='wpa2',
                             position='60,30,0')
    ap3 = net.addAccessPoint('ap3',
                             mac='00:00:00:00:00:03',
                             ssid="handover",
                             mode="g",
                             channel="1",
                             passwd='123456789a',
                             encrypt='wpa2',
                             position='120,100,0')
    s4 = net.addSwitch('s4')
    h1 = net.addHost('h1')
    controller_ = net.addHost('con', ip='10.0.0.100/8', inNamespace=False)
    c1 = net.addController('c1', controller=RemoteController, ip='127.0.0.1')

    info("*** Configuring Propagation Model\n")
    net.setPropagationModel(model="logDistance", exp=3.5)

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

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

    info("*** Creating links\n")
    net.addLink(h1, ap1)
    net.addLink(s4, ap1)
    net.addLink(s4, ap2)
    net.addLink(s4, ap3)
    net.addLink(s4, controller_)

    info("*** Starting network\n")
    net.build()
    net.addNAT().configDefault()
    c1.start()
    ap1.start([c1])
    ap2.start([c1])
    ap3.start([c1])
    s4.start([c1])

    sta1.cmd('iw dev sta1-wlan0 interface add mon0 type monitor')
    sta1.cmd('ifconfig mon0 up')
    sta2.cmd('iw dev sta2-wlan0 interface add mon0 type monitor')
    sta2.cmd('ifconfig mon0 up')
    sta1.cmd('wpa_cli -i sta1-wlan0 roam 00:00:00:00:00:01')
    sta2.cmd('wpa_cli -i sta2-wlan0 roam 00:00:00:00:00:01')
    sta1.cmd('./sta1_1.py &')
    sta2.cmd('./sta2_1.py &')

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

    info("*** Stopping network\n")
    net.stop()
Esempio n. 44
0
def topology(args):
    "Create a network."
    net = Mininet_wifi()

    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')

    info("*** Configuring propagation model\n")
    net.setPropagationModel(model="logDistance", exp=4.5)

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

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

    if '-p' not in args:
        net.plotGraph(max_x=200, max_y=200)

    if '-c' in args:
        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, mob_rep=1, reverse=False)

    p1, p2, p3, p4 = dict(), dict(), dict(), dict()
    if '-c' not in args:
        p1 = {'position': '40.0,30.0,0.0'}
        p2 = {'position': '40.0,40.0,0.0'}
        p3 = {'position': '31.0,10.0,0.0'}
        p4 = {'position': '55.0,31.0,0.0'}

    net.mobility(sta1, 'start', time=1, **p1)
    net.mobility(sta2, 'start', time=2, **p2)
    net.mobility(sta1, 'stop', time=12, **p3)
    net.mobility(sta2, 'stop', time=22, **p4)
    net.stopMobility(time=23)

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

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

    info("*** Stopping network\n")
    net.stop()
Esempio n. 45
0
def topology():
    'Create a network.'
    net = Mininet_wifi(controller=RemoteController,
                       link=wmediumd,
                       wmediumd_mode=interference)

    info("*** Creating nodes\n")
    sta1 = net.addStation('sta1', mac='00:00:00:00:00:01', ip='192.168.0.1/24')
    sta2 = net.addStation('sta2', mac='00:00:00:00:00:02', ip='192.168.1.1/24')

    ap1 = net.addStation('ap1', mac='02:00:00:00:01:00', ip='192.168.0.10/24')
    ap2 = net.addStation('ap2', mac='02:00:00:00:02:00', ip='192.168.1.10/24')

    c1 = net.addController(name='c1',
                           controller=InbandController,
                           ip='192.168.0.10',
                           protocol='tcp',
                           port=6653)

    net.setPropagationModel(model="logDistance", exp=4.5)

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

    ap1.setMasterMode(intf='ap1-wlan0', ssid='ap1-ssid', channel='1', mode='n')
    ap2.setMasterMode(intf='ap2-wlan0', ssid='ap2-ssid', channel='6', mode='n')

    info("*** Adding Link\n")
    net.addLink(ap1, ap2)  # wired connection

    info("*** Plotting Graph\n")
    net.plotGraph(max_x=120, max_y=120)

    net.setMobilityModel(time=0,
                         model='RandomWayPoint',
                         max_x=100,
                         max_y=100,
                         min_v=0.5,
                         max_v=2,
                         seed=10)

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

    # ap1.cmd('echo 1 > /proc/sys/net/ipv4/ip_forward')
    # ap2.cmd('echo 1 > /proc/sys/net/ipv4/ip_forward')

    ap1.setIP('192.168.0.10/24', intf='ap1-wlan0')
    ap1.setIP('192.168.2.1/24', intf='ap1-eth2')
    ap2.setIP('192.168.1.10/24', intf='ap2-wlan0')
    ap2.setIP('192.168.2.2/24', intf='ap2-eth2')
    # ap1.cmd('route add -net 192.168.1.0/24 gw 192.168.2.2')
    # ap2.cmd('route add -net 192.168.0.0/24 gw 192.168.2.1')
    # sta1.cmd('route add -net 192.168.1.0/24 gw 192.168.0.10')
    # sta1.cmd('route add -net 192.168.2.0/24 gw 192.168.0.10')
    # sta2.cmd('route add -net 192.168.0.0/24 gw 192.168.1.10')
    # sta2.cmd('route add -net 192.168.2.0/24 gw 192.168.1.10')

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

    info("*** Stopping network\n")
    net.stop()
Esempio n. 46
0
def topology():

    net = Mininet_wifi()

    info("*** Creating nodes\n")
    net.addStation('sta1',
                   mac='00:00:00:00:00:02',
                   ip='10.0.0.1/8',
                   position='30,60,0')
    net.addStation('sta2',
                   mac='00:00:00:00:00:03',
                   ip='10.0.0.2/8',
                   position='70,30,0')
    ap1 = net.addAccessPoint('ap1',
                             ssid='new-ssid',
                             mode='g',
                             channel='1',
                             failMode="standalone",
                             position='50,50,0')
    h1 = net.addHost('h1', ip='10.0.0.3/8', position='10,30,0')

    net.setPropagationModel(model="logDistance", exp=4.5)

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

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

    net.plotGraph(min_x=10,
                  min_y=10,
                  min_z=10,
                  max_x=100,
                  max_y=100,
                  max_z=100)

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

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

    info("*** Stopping network\n")
    net.stop()
Esempio n. 47
0
def topology():
    "Create a network."
    net = Mininet_wifi()

    info("*** Creating nodes\n")
    net.addStation('sta1',
                   mac='00:00:00:00:00:02',
                   ip='10.0.0.2/8',
                   min_x=10,
                   max_x=30,
                   min_y=50,
                   max_y=70,
                   min_v=5,
                   max_v=10)
    net.addStation('sta2',
                   mac='00:00:00:00:00:03',
                   ip='10.0.0.3/8',
                   min_x=60,
                   max_x=70,
                   min_y=10,
                   max_y=20,
                   min_v=1,
                   max_v=5)
    ap1 = net.addAccessPoint('ap1',
                             ssid='new-ssid',
                             mode='g',
                             channel='1',
                             failMode="standalone",
                             position='50,50,0')

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

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

    net.setMobilityModel(time=0,
                         model='RandomDirection',
                         max_x=100,
                         max_y=100,
                         seed=20)

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

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

    info("*** Stopping network\n")
    net.stop()
def topology():
    "Create a network."
    net = Mininet_wifi( controller=Controller, accessPoint=UserAP,
                        autoAssociation=False )

    info("*** Creating nodes\n")
    sta1 = net.addStation( 'sta1', position='10,60,0' )
    sta2 = net.addStation( 'sta2', position='20,15,0' )
    sta3 = net.addStation( 'sta3', position='10,25,0' )
    sta4 = net.addStation( 'sta4', position='50,30,0' )
    sta5 = net.addStation( 'sta5', position='45,65,0' )
    ap1 = net.addAccessPoint( 'ap1', vssids=4, ssid="ssid,ssid1,ssid2,ssid3,ssid4",
                              mode="g", channel="1", position='30,40,0' )
    c0 = net.addController('c0' )

    net.setPropagationModel(model='logDistance', exp=5)

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

    "plotting graph"
    net.plotGraph(max_x=100, max_y=100)

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

    sta1.setRange(15)
    sta2.setRange(15)
    sta3.setRange(15)
    sta4.setRange(15)
    sta5.setRange(15)

    sta1.cmd('iwconfig sta1-wlan0 essid %s ap %s' % (ap1.params['ssid'][1], ap1.params['mac'][1]))
    sta2.cmd('iwconfig sta2-wlan0 essid %s ap %s' % (ap1.params['ssid'][2], ap1.params['mac'][2]))
    sta3.cmd('iwconfig sta3-wlan0 essid %s ap %s' % (ap1.params['ssid'][2], ap1.params['mac'][2]))
    sta4.cmd('iwconfig sta4-wlan0 essid %s ap %s' % (ap1.params['ssid'][3], ap1.params['mac'][3]))
    sta5.cmd('iwconfig sta5-wlan0 essid %s ap %s' % (ap1.params['ssid'][4], ap1.params['mac'][4]))

    ap1.cmd('dpctl unix:/tmp/ap1 meter-mod cmd=add,flags=1,meter=1 drop:rate=100')
    ap1.cmd('dpctl unix:/tmp/ap1 meter-mod cmd=add,flags=1,meter=2 drop:rate=200')
    ap1.cmd('dpctl unix:/tmp/ap1 meter-mod cmd=add,flags=1,meter=3 drop:rate=300')
    ap1.cmd('dpctl unix:/tmp/ap1 meter-mod cmd=add,flags=1,meter=4 drop:rate=400')
    ap1.cmd('dpctl unix:/tmp/ap1 flow-mod table=0,cmd=add in_port=2 meter:1 apply:output=flood')
    ap1.cmd('dpctl unix:/tmp/ap1 flow-mod table=0,cmd=add in_port=3 meter:2 apply:output=flood')
    ap1.cmd('dpctl unix:/tmp/ap1 flow-mod table=0,cmd=add in_port=4 meter:3 apply:output=flood')
    ap1.cmd('dpctl unix:/tmp/ap1 flow-mod table=0,cmd=add in_port=5 meter:4 apply:output=flood')

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

    info("*** Stopping network\n")
    net.stop()
Esempio n. 49
0
def topology():

    "Create a network."
    net = Mininet_wifi()

    info("*** Creating nodes\n")
    sta1 = net.addStation('sta1',
                          mac='00:00:00:00:00:01',
                          ip='192.168.0.1/24',
                          position='47.28,50,0')
    sta2 = net.addStation('sta2',
                          mac='00:00:00:00:00:02',
                          ip='192.168.0.2/24',
                          position='54.08,50,0')
    ap1 = net.addAccessPoint('ap1',
                             ssid='ap-ssid1',
                             mode='g',
                             channel='1',
                             position='50,50,0')
    c0 = net.addController('c0', port=6653)

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

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

    sta1.cmd('iw dev sta1-wlan0 interface add mon0 type monitor')
    sta1.cmd('ip link set mon0 up')
    sta2.cmd('iw dev sta2-wlan0 interface add mon0 type monitor')
    sta2.cmd('ip link set mon0 up')
    if py_version_info < (3, 0):
        sta2.cmd('pushd ~/; python -m SimpleHTTPServer 80 &')
    else:
        sta2.cmd('pushd ~/; python -m http.server 80 &')

    path = os.path.dirname(
        os.path.abspath(__file__)) + '/replayingNetworkConditions/'
    get_trace(sta1, '{}clientTrace.txt'.format(path))
    get_trace(sta2, '{}serverTrace.txt'.format(path))

    info("*** Replaying Network Conditions\n")
    ReplayingNetworkConditions(net)

    #sta1.cmd('tcpdump -i mon0 -s 0 -vvv -w client.pcap &&')
    #sta2.cmd('tcpdump -i mon0 -s 0 -vvv -w server.pcap &&')
    #sta1 tcpdump -i mon0 -s 0 -vvv -w client.pcap && sta1 wget http://192.168.0.2/virtualbox-5.0_5.0.20-106931~Ubuntu~xenial_amd64.deb
    #sta1.cmd('wget http://'+sta2.IP()+'/virtualbox-5.0_5.0.20-106931~Ubuntu~xenial_amd64.deb')

    #sta1.cmd('nohup ping ' + sta2.IP() + ' -c 180 > ping1.log &')
    #sta2.cmd('nohup ping ' + sta1.IP() + ' -c 180 > ping2.log &')
    #sta2.cmd('iperf -s &')
    #sta1.cmd('iperf -c ' + sta2.IP() + ' -i 0.5 -t 60 | awk \'t=120{if(NR>=7 && NR<=25) print $8; else if(NR>=26 && NR<=t+6) print $7}\' > replay1.dat')
    #sta2.cmd('iperf -c ' + sta1.IP() + ' -i 0.5 -t 60 | awk \'t=120{if(NR>=7 && NR<=25) print $8; else if(NR>=26 && NR<=t+6) print $7}\' > replay2.dat &')

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

    info("*** Stopping network\n")
    net.stop()
Esempio n. 50
0
def topology():

    net = Mininet_wifi()

    info("*** Creating nodes\n")
    net.addStation('sta1', mac='00:00:00:00:00:02', ip='10.0.0.1/8',
                   position='30,60,0')
    net.addStation('sta2', mac='00:00:00:00:00:03', ip='10.0.0.2/8',
                   position='70,30,0')
    ap1 = net.addAccessPoint('ap1', ssid='new-ssid', mode='g', channel='1',
                             failMode="standalone", position='50,50,0')
    h1 = net.addHost('h1', ip='10.0.0.3/8')

    net.setPropagationModel(model="logDistance", exp=4.5)

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

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

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

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

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

    info("*** Stopping network\n")
    net.stop()
Esempio n. 51
0
def topology():
    "Create a network."
    net = Mininet_wifi(controller=Controller)

    info("*** Creating nodes\n")
    ap1 = net.addAccessPoint('ap1',
                             ssid='new-ssid',
                             mode='g',
                             channel='1',
                             position='10,10,0',
                             failMode="standalone")
    net.addStation('sta1', position='10,20,0')
    net.addStation('sta2', position='10,30,0')

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

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

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

    info("*** Stopping network\n")
    net.stop()
def topology():
    "Create a network."
    net = Mininet_wifi(controller=Controller, accessPoint=UserAP,
                       autoAssociation=False)

    info("*** Creating nodes\n")
    sta1 = net.addStation('sta1', position='10,60,0')
    sta2 = net.addStation('sta2', position='20,15,0')
    sta3 = net.addStation('sta3', position='10,25,0')
    sta4 = net.addStation('sta4', position='50,30,0')
    sta5 = net.addStation('sta5', position='45,65,0')
    ap1 = net.addAccessPoint('ap1', vssids=4,
                             ssid='ssid,ssid1,ssid2,ssid3,ssid4',
                             mode="g", channel="1", position='30,40,0')
    c0 = net.addController('c0')

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

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

    sta1.setRange(15, intf=sta1.params['wlan'][0])
    sta2.setRange(15, intf=sta2.params['wlan'][0])
    sta3.setRange(15, intf=sta3.params['wlan'][0])
    sta4.setRange(15, intf=sta4.params['wlan'][0])
    sta5.setRange(15, intf=sta5.params['wlan'][0])

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

    sleep(2)
    sta1.cmd('iw dev %s connect %s %s'
             % (sta1.params['wlan'][0], ap1.params['ssid'][1],
                ap1.params['mac'][1]))
    sta2.cmd('iw dev %s connect %s %s'
             % (sta2.params['wlan'][0], ap1.params['ssid'][2],
                ap1.params['mac'][2]))
    sta3.cmd('iw dev %s connect %s %s'
             % (sta3.params['wlan'][0], ap1.params['ssid'][2],
                ap1.params['mac'][2]))
    sta4.cmd('iw dev %s connect %s %s'
             % (sta4.params['wlan'][0], ap1.params['ssid'][3],
                ap1.params['mac'][3]))
    sta5.cmd('iw dev %s connect %s %s'
             % (sta5.params['wlan'][0], ap1.params['ssid'][4],
                ap1.params['mac'][4]))

    ap1.cmd('dpctl unix:/tmp/ap1 meter-mod cmd=add,flags=1,meter=1 '
            'drop:rate=100')
    ap1.cmd('dpctl unix:/tmp/ap1 meter-mod cmd=add,flags=1,meter=2 '
            'drop:rate=200')
    ap1.cmd('dpctl unix:/tmp/ap1 meter-mod cmd=add,flags=1,meter=3 '
            'drop:rate=300')
    ap1.cmd('dpctl unix:/tmp/ap1 meter-mod cmd=add,flags=1,meter=4 '
            'drop:rate=400')
    ap1.cmd('dpctl unix:/tmp/ap1 flow-mod table=0,cmd=add in_port=2 '
            'meter:1 apply:output=flood')
    ap1.cmd('dpctl unix:/tmp/ap1 flow-mod table=0,cmd=add in_port=3 '
            'meter:2 apply:output=flood')
    ap1.cmd('dpctl unix:/tmp/ap1 flow-mod table=0,cmd=add in_port=4 '
            'meter:3 apply:output=flood')
    ap1.cmd('dpctl unix:/tmp/ap1 flow-mod table=0,cmd=add in_port=5 '
            'meter:4 apply:output=flood')

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

    info("*** Stopping network\n")
    net.stop()
Esempio n. 53
0
def topology():
    "Create a network."
    net = Mininet_wifi(controller=Controller,
                       link=wmediumd,
                       wmediumd_mode=interference)

    info("*** Creating nodes\n")
    #AP1 = net.addAccessPoint('AP1', ssid="ap-ssid", mode="g", channel="1", position='5,10,0', range=100)
    AP = net.addStation('AP',
                        position='5,10,0',
                        ip='10.0.0.1',
                        mac='00:00:00:00:00:01')

    RU = net.addStation('RU',
                        position='30,5,0',
                        ip='10.0.0.2',
                        mac='00:00:00:00:00:02')

    DU = net.addStation('DU',
                        position='15,15,0',
                        ip='10.0.0.3',
                        mac='00:00:00:00:00:03')

    c1 = net.addController('c1')

    net.setPropagationModel(model="logDistance", exp=5)

    info("*** Configuring wifi nodes\n")
    net.configureWifiNodes()
    net.plotGraph(max_x=40, max_y=40)
    #AP1.setIP('10.0.0.10', intf='AP1-wlan1')

    info("*** Creating links\n")
    net.addLink(AP,
                cls=adhoc,
                ssid='adhocNet',
                mode='g',
                channel=5,
                ht_cap='HT40+')
    net.addLink(RU,
                cls=adhoc,
                ssid='adhocNet',
                mode='g',
                channel=5,
                ht_cap='HT40+')
    net.addLink(DU,
                cls=adhoc,
                ssid='adhocNet',
                mode='g',
                channel=5,
                ht_cap='HT40+')

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

    info("*** Starting Send information\n")
    #获得总包的个数
    for index in range(15):
        file = '/media/psf/Home/Documents/GitHub/mininet-project/D2D+NC/Log'
        filename1 = '%s/msg.txt' % file
        results = FToMatrix(filename1)
        nums = len(results)
        for i in range(nums):
            info("round ", i, "\n")
            info("AP to DU and RU\n")
            t1 = MyThread(command,
                          args=(DU, "python DU_receive.py 10.0.0.3 DU-wlan0"))
            t2 = MyThread(command,
                          args=(RU,
                                "python RU_receive_AP.py 10.0.0.2 RU-wlan0"))
            t3 = MyThread(
                command,
                args=
                (AP,
                 "python APSend.py 10.0.0.1 AP-wlan0 10.0.0.2 10.0.0.3 %s False"
                 % i))
            t1.start()
            t2.start()
            t3.start()
            t1.join()
            t2.join()
            t3.join()
            info("DU send encoded packets to RU\n")
            t4 = MyThread(
                command,
                args=(DU, "python DU_send.py 10.0.0.3 DU-wlan0 10.0.0.2"))
            t5 = MyThread(command,
                          args=(RU,
                                "python RU_receive_DU.py 10.0.0.2 RU-wlan0"))
            t4.start()
            t5.start()
            t4.join()
            t5.join()
            info("AP reSend to RU\n")
            t6 = MyThread(
                command,
                args=
                (DU,
                 "python APSend.py 10.0.0.1 AP-wlan0 10.0.0.2 10.0.0.3 %s True"
                 % i))
            t7 = MyThread(
                command,
                args=(RU, "python RU_receive_AP.py 10.0.0.2 RU-wlan0 True"))
            t6.start()
            t7.start()
            t6.join()
            t7.join()
            info("ACK %d\n" % i)

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

    info("*** Stopping network\n")
    net.stop()
def topology():
    "Create a network."
    net = Mininet_wifi( controller=Controller, link=TCLink, switch=OVSKernelSwitch )

    info("*** Creating nodes\n")
    sta1 = net.addStation( 'sta1', mac='00:00:00:00:00:02', ip='10.0.0.2/8' )
    ap1 = net.addAccessPoint( 'ap1', ssid='new-ssid', mode='g', channel='1',
                              position='50,50,0' )
    c1 = net.addController( 'c1', controller=Controller )

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

    info("*** adding Link\n")
    net.addLink(sta1, ap1)

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

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

    path = os.path.dirname(os.path.abspath(__file__))
    getTrace(sta1, '%s/replayingBandwidth/throughputData.dat' % path)

    replayingBandwidth(net)

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

    info("*** Stopping network\n")
    net.stop()
Esempio n. 55
0
def topology(args):
    "Create a network."
    net = Mininet_wifi(controller=Controller,
                       link=wmediumd,
                       wmediumd_mode=interference,
                       config4addr=True)

    info("*** Creating nodes\n")
    ap1 = net.addAccessPoint('ap1',
                             ssid="ap1-ssid",
                             mode="g",
                             channel="1",
                             position='30,30,0')
    ap2 = net.addAccessPoint('ap2',
                             ssid="ap2-ssid",
                             mode="g",
                             channel="1",
                             position='40,60,0')
    ap3 = net.addAccessPoint('ap3',
                             ssid="ap3-ssid",
                             mode="g",
                             channel="1",
                             position='50,30,0')
    sta1 = net.addStation('sta1', ip="192.168.0.1/24", position='31,32,0')
    sta2 = net.addStation('sta2', ip="192.168.0.2/24", position='32,34,0')
    sta3 = net.addStation('sta3', ip="192.168.0.3/24", position='41,62,0')
    sta4 = net.addStation('sta4', ip="192.168.0.4/24", position='42,64,0')
    sta5 = net.addStation('sta5', ip="192.168.0.5/24", position='51,32,0')
    sta6 = net.addStation('sta6', ip="192.168.0.6/24", position='52,34,0')
    c0 = net.addController('c0')

    info("*** Configuring Propagation Model\n")
    net.setPropagationModel(model="logDistance", exp=4.5)

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

    info("*** Adding Link\n")
    net.addLink(ap1, ap2, cls=_4address)  # ap1=ap, ap2=client
    net.addLink(ap1, ap3, cls=_4address)  # ap1=ap, ap3=client
    net.addLink(sta1, ap1)
    net.addLink(sta2, ap1)
    net.addLink(sta3, ap2)
    net.addLink(sta4, ap2)
    net.addLink(sta5, ap3)
    net.addLink(sta6, ap3)

    if '-p' not in args:
        net.plotGraph(max_x=100, max_y=100)

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

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

    info("*** Stopping network\n")
    net.stop()
def topology():

    "Create a network."
    net = Mininet_wifi(controller=Controller)

    info("*** Creating nodes\n")
    net.addStation('sta1', antennaHeight='1', antennaGain='5')
    net.addStation('sta2', antennaHeight='1', antennaGain='5')
    ap1 = net.addAccessPoint('ap1', ssid='new-ssid', model='DI524',
                             mode='g', channel='1', position='50,50,0')
    c1 = net.addController('c1')

    net.setPropagationModel(model="logDistance", exp=4)

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

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

    net.setMobilityModel(time=0, model='RandomWayPoint', max_x=100, max_y=100,
                         min_v=0.5, max_v=0.5, seed=20)

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

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

    info("*** Stopping network\n")
    net.stop()
Esempio n. 57
0
def topology():

    "Create a network."
    net = Mininet_wifi(controller=Controller,
                       link=wmediumd,
                       wmediumd_mode=interference)

    info("*** Creating nodes\n")
    cars = []
    for id in range(0, 10):
        min_ = randint(1, 4)
        max_ = randint(11, 30)
        cars.append(net.addCar('car%s' % (id+1), wlans=2,
                               min_speed=min_,
                               max_speed=max_))

    rsu11 = net.addAccessPoint('RSU11', ssid='RSU11', mode='g',
                               channel='1')
    rsu12 = net.addAccessPoint('RSU12', ssid='RSU12', mode='g',
                               channel='6')
    rsu13 = net.addAccessPoint('RSU13', ssid='RSU13', mode='g',
                               channel='11')
    rsu14 = net.addAccessPoint('RSU14', ssid='RSU14', mode='g',
                               channel='11')
    c1 = net.addController('c1')

    info("*** Configuring Propagation Model\n")
    net.setPropagationModel(model="logDistance", exp=4.5)

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

    info("*** Associating and Creating links\n")
    net.addLink(rsu11, rsu12)
    net.addLink(rsu11, rsu13)
    net.addLink(rsu11, rsu14)
    for car in cars:
        net.addLink(car, intf=car.params['wlan'][1],
                    cls=mesh, ssid='mesh-ssid', channel=5)

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

    net.roads(10)

    net.startMobility(time=0)

    info("*** Starting network\n")
    net.build()
    c1.start()
    rsu11.start([c1])
    rsu12.start([c1])
    rsu13.start([c1])
    rsu14.start([c1])

    for car in cars:
        car.setIP('192.168.0.%s/24' % (int(cars.index(car))+1),
                  intf='%s-wlan0' % car)
        car.setIP('192.168.1.%s/24' % (int(cars.index(car))+1),
                  intf='%s-mp1' % car)

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

    info("*** Stopping network\n")
    net.stop()
def topology():
    "Create a network."
    net = Mininet_wifi(controller=Controller, link=wmediumd,
                       wmediumd_mode=interference)

    info("*** Creating nodes\n")
    sta1 = net.addAccessPoint('sta1', ip='192.168.0.1/24',
                              position='10,10,0',
                              cls=UserAP, inNamespace=True)
    sta2 = net.addAccessPoint('sta2', ip='192.168.0.2/24',
                              position='10,20,0',
                              cls=UserAP, inNamespace=True)
    c0 = net.addController('c0')

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

    info("*** Associating Stations\n")
    net.addLink(sta1, intf='sta1-wlan1', cls=mesh,
                ssid='mesh-ssid', channel=5)
    net.addLink(sta2, intf='sta2-wlan1', cls=mesh,
                ssid='mesh-ssid', channel=5)

    info("*** Starting network\n")
    net.build()
    c0.start()
    sta1.start([c0])
    sta2.start([c0])

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

    info("*** Stopping network\n")
    net.stop()
Esempio n. 59
0
def topology():

    net = Mininet_wifi(controller=Controller,
                       link=TCLink,
                       switch=OVSKernelSwitch)

    print "*** Creating nodes"
    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',
                          range='20')
    ap1 = net.addAccessPoint('ap1',
                             ssid='ap1-ssid',
                             mode='g',
                             channel='1',
                             position='30,50,0',
                             range='30')
    ap2 = net.addAccessPoint('ap2',
                             ssid='ap2-ssid',
                             mode='g',
                             channel='1',
                             position='90,50,0',
                             range='30')
    ap3 = net.addAccessPoint('ap3',
                             ssid='ap3-ssid',
                             mode='g',
                             channel='1',
                             position='130,50,0',
                             range='30')
    c1 = net.addController('c1', controller=Controller)

    print "*** Associating and Creating links"
    net.addLink(ap1, h1)
    net.addLink(ap1, ap2)
    net.addLink(ap2, ap3)

    print "*** Starting network"
    net.build()
    c1.start()
    ap1.start([c1])
    ap2.start([c1])
    ap3.start([c1])

    net.startMobility(startTime=0, AC='ssf')
    net.mobility(sta1, 'start', time=20, position='1,50,0')
    net.mobility(sta1, 'stop', time=79, position='159,50,0')
    net.stopMobility(stopTime=80)

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

    print "*** Running CLI"
    CLI(net)

    print "*** Stopping network"
    net.stop()
Esempio n. 60
0
def topology(mobility):
    'Create a network.'
    net = Mininet_wifi(link=wmediumd, wmediumd_mode=interference)

    info("*** Creating nodes\n")
    if mobility:
        sta1 = net.addStation('sta1', mac='00:00:00:00:00:01',
                              ip='192.168.0.1/24')
    else:
        sta1 = net.addStation('sta1', mac='00:00:00:00:00:01',
                              ip='192.168.0.1/24', position='20,60,0')
    sta2 = net.addStation('sta2', mac='00:00:00:00:00:02', ip='192.168.1.1/24',
                          position='90,60,0')
    ap1 = net.addStation('ap1', mac='02:00:00:00:01:00',
                         ip='192.168.0.10/24', position='40,60,0')
    ap2 = net.addStation('ap2', mac='02:00:00:00:02:00',
                         ip='192.168.1.10/24', position='70,60,0')

    net.setPropagationModel(model="logDistance", exp=4.5)

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

    ap1.setMasterMode(intf='ap1-wlan0', ssid='ap1-ssid', channel='1', mode='n')
    ap2.setMasterMode(intf='ap2-wlan0', ssid='ap2-ssid', channel='6', mode='n')

    info("*** Adding Link\n")
    net.addLink(ap1, ap2)  # wired connection

    info("*** Plotting Graph\n")
    net.plotGraph(max_x=120, max_y=120)

    if mobility:
        net.startMobility(time=1)
        net.mobility(sta1, 'start', time=2, position='20.0,60.0,0.0')
        net.mobility(sta1, 'stop', time=6, position='100.0,60.0,0.0')
        net.stopMobility(time=7)

    info("*** Starting network\n")
    net.build()

    ap1.cmd('echo 1 > /proc/sys/net/ipv4/ip_forward')
    ap2.cmd('echo 1 > /proc/sys/net/ipv4/ip_forward')

    ap1.setIP('192.168.0.10/24', intf='ap1-wlan0')
    ap1.setIP('192.168.2.1/24', intf='ap1-eth2')
    ap2.setIP('192.168.1.10/24', intf='ap2-wlan0')
    ap2.setIP('192.168.2.2/24', intf='ap2-eth2')
    ap1.cmd('route add -net 192.168.1.0/24 gw 192.168.2.2')
    ap2.cmd('route add -net 192.168.0.0/24 gw 192.168.2.1')
    sta1.cmd('route add -net 192.168.1.0/24 gw 192.168.0.10')
    sta1.cmd('route add -net 192.168.2.0/24 gw 192.168.0.10')
    sta2.cmd('route add -net 192.168.0.0/24 gw 192.168.1.10')
    sta2.cmd('route add -net 192.168.2.0/24 gw 192.168.1.10')

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

    info("*** Stopping network\n")
    net.stop()