Example #1
0
   def main():
       topo = SimpleTopo() # design topology
       info( '*** Creating network\n' )
       net = Mininet(topo=topo) #Passing Topology to Mininet Class
       net.start() # starting the networ

       # Print the elements of the network
       for item in net.items():
           print item

       print "Encoded log file at %s" % LOG_FILE_PATH
       print "Decoded log file at %s" % DECODED_LOG_FILE_PATH
       h1, h2, attacker, s1 = net.get('h1', 'h2', 'h3', 's1')
           # Start a ssh server on host 2
           start_sshd(h2)
           # Giving H3 rights to read and write Log Files of H2
           create_attack_log(attacker)
           #Console Logging the network
           CLI(net)
           #Stop sshd server
           stop_sshd()
           #delete all attack logs
           delete_attack_log(attacker)
           #stop network
           net.stop()
Example #2
0
def run():
    """Test linux router"""
    topology = Topology()
    net = Mininet(topo=topology, controller=None)
    net.start()

    for node, type in net.items():
        if isinstance(type, Router):
            info('*** Routing Table on Router %s:\n' % node)
            info(net[node].cmd('route'))

    CLI(net)
    net.stop()
def main():
    topo = AttackTopo()
    info( '*** Creating network\n' )
    net = Mininet(topo=topo)
    net.start()

    # Print the elements of the network
    for item in net.items():
        print item

    h1, h2, attacker, s1 = net.get('h1', 'h2', 'h3', 's1')
    # Start a ssh server on host 2
    start_telnet(h2)
    CLI(net)
    stop_telnet(h2)
    net.stop()
Example #4
0
def main():
    topo = AttackTopo()
    info('*** Creating network\n')
    net = Mininet(topo=topo)
    net.start()

    # Print the elements of the network
    for item in net.items():
        print item

    h1, h2, attacker, s1 = net.get('h1', 'h2', 'h3', 's1')
    # Start a ssh server on host 2
    start_telnet(h2)
    CLI(net)
    stop_telnet(h2)
    net.stop()
Example #5
0
def main():
    topo = AttackTopo()
    info( '*** Creating network\n' )
    net = Mininet(topo=topo)
    net.start()

    # Print the elements of the network
    for item in net.items():
        print item

    print "Encoded log file at %s" % LOG_FILE_PATH 
    print "Decoded log file at %s" % DECODED_LOG_FILE_PATH 
    h1, h2, attacker, s1 = net.get('h1', 'h2', 'h3', 's1')
    # Start a ssh server on host 2
    start_sshd(h2)
    create_attack_log(attacker)
    CLI(net)
    stop_sshd()
    delete_attack_log(attacker)
    net.stop()
Example #6
0
def main():
    topo = AttackTopo()
    info('*** Creating network\n')
    net = Mininet(topo=topo)
    net.start()

    # Print the elements of the network
    for item in net.items():
        print item

    print "Encoded log file at %s" % LOG_FILE_PATH
    print "Decoded log file at %s" % DECODED_LOG_FILE_PATH
    h1, h2, attacker, s1 = net.get('h1', 'h2', 'h3', 's1')
    # Start a ssh server on host 2
    start_sshd(h2)
    create_attack_log(attacker)
    CLI(net)
    stop_sshd()
    delete_attack_log(attacker)
    net.stop()
Example #7
0
    def test_verifying_mininet_hosts_in_onos_controller(self,switches=4):
        try:
	    topo = LinearTopo(switches)
            net = Mininet( topo=topo)
	    net.start()
	    ctrl = net.addController( 'onos', controller=RemoteController, ip=self.controller, port=6653)
            for switch in net.switches:
                switch.start( [ctrl] )
            log.info('mininet all the devices IDs %s'%net.keys())
            log.info('mininet all the devices details %s'%net.values())
            log.info('mininet all the devices information %s'%net.items())
            response = net.pingAll()
            log.info('pingAll response is %s'%response)
            assert_equal(response, 0.0)
            self.cliEnter()
            hosts = json.loads(self.cli.hosts(jsonFormat = True))
            log.info('Discovered hosts: %s' %hosts)
            assert_equal(len(hosts),switches)
            self.cliExit()
        except Exception as Error:
            log.info('Got unexpected error %s while creating topology'%Error)
            Cleanup.cleanup()
            raise
        Cleanup.cleanup()
Example #8
0
setLogLevel('info')
"""

# ENSAYO CON RYU --> ok

net = Mininet( topo=TreeTopo( depth=2, fanout=2 ),
               controller=RYU('c0') )


"""
# ENSAYO CON POX --> ok
c0 = POX('c0')
net = Mininet(topo=TreeTopo(depth=2, fanout=2), controller=c0)

net_sw = {}
for k, v in net.items():
    if 's' in k:
        sw_int = []
        for i in range(1, len(v.ports)):
            sw_int.append(k + '-eth' + str(i))
        net_sw[k] = sw_int
        sw_int = []

filename = "monitoreo.csv"
list_interfaces = ''
for k in net_sw:
    for int_sw in net_sw[k]:
        list_interfaces += int_sw + ','
list_interfaces = list_interfaces.rstrip(',')

Example #9
0
        policy = drop
        for i in range(1, n + 1):
            partial_policy = ((match(switch=i) >> fwd(2)) +
                              (match(switch=left_con_num) >> fwd(i)) +
                              (match(switch=right_con_num) >> fwd(m + 1)) +
                              ((~match(switch=i) & ~match(switch=left_con_num)
                                & ~match(switch=right_con_num)) >> fwd(1)))
            policy += match(dstip=ip_prefix + str(i)) >> partial_policy

        for k in range(1, m + 1):
            i = k + n
            partial_policy = ((match(switch=i) >> fwd(2)) +
                              (match(switch=left_con_num) >> fwd(n + 1)) +
                              (match(switch=right_con_num) >> fwd(k)) +
                              ((~match(switch=i) & ~match(switch=left_con_num)
                                & ~match(switch=right_con_num)) >> fwd(1)))
            policy += match(dstip=ip_prefix + str(i)) >> partial_policy

        return policy


if __name__ == "__main__":
    topo = TestTopo(2, 3)
    net = Mininet(topo=topo,
                  host=CPULimitedHost,
                  controller=RemoteController,
                  listenPort=6634)
    net.start()
    print net.items()
    net.stop()
Example #10
0
            partial_policy = (
                            (match(switch = i) >> fwd(2)) 
                            + (match(switch = left_con_num) >> fwd(i)) 
                            + (match(switch = right_con_num) >> fwd(m + 1))
                            + ( (~match(switch = i) & ~match(switch = left_con_num) & ~match(switch = right_con_num)) >> fwd(1) )
                            )
            policy += match(dstip = ip_prefix+str(i)) >> partial_policy
       
        for k in range(1, m + 1):
            i = k + n
            partial_policy = (
                            (match(switch = i) >> fwd(2)) 
                            + (match(switch = left_con_num) >> fwd(n + 1)) 
                            + (match(switch = right_con_num) >> fwd(k))
                            + ( (~match(switch = i) & ~match(switch = left_con_num) & ~match(switch = right_con_num)) >> fwd(1) )
                            )
            policy += match(dstip = ip_prefix+str(i)) >> partial_policy

        return policy




if __name__ == "__main__":
    topo = TestTopo(2,3)
    net = Mininet(topo=topo, host=CPULimitedHost, controller=RemoteController,
                  listenPort=6634)
    net.start()
    print net.items()
    net.stop()