1

I am trying to write my own python script to enable me to monitor traffic and perform basic attacks and prevent those attacks using a basic firewall. I have never used mininet before so might be doing something obviously wrong to a more experienced user.

So far, I have managed to create a topology which works, but I wanted to run the iperf command within the script, meaning I need to call the iperf() method which requires me to create a new Mininet object.

I have utilised a block of code from mininet's SimplePerf.py example and have tried to adapt it to what I have written so far. To my understanding, that method creates a topology that gradually reduces the processing power of new hosts, causing a drop off. I do not want CPU limited hosts, so I have tried to adapt the way the Mininet is invoked.

This is currently my code:

from mininet.topo import Topo
from mininet.net import Mininet

from sys import argv
from mininet.node import OVSController
from mininet.link import TCLink


class Project( Topo ):
    def __init__( self ):
        # Initialize topology
        Topo.__init__( self )
        # Add hosts
        h1 = self.addHost('h1')
        h2 = self.addHost('h2')
        h3 = self.addHost('h3')
        # Add switches
        s1 = self.addSwitch('s1')
        # Add links
        self.addLink(h1,s1)
        self.addLink(h2,s1)
        self.addLink(h3,s1)

topos = { 'project': ( lambda: Project() )} 

net = Mininet( topo=topos,
               link=TCLink,
               controller=OVSController,
               autoStaticArp=True )
net.start()
#dumpNodeConnections(net.hosts)
h1, h3 = net.getNodeByName('h1', 'h3')
net.iperf( ( h1, h3 ), l4Type='UDP' )
net.stop()

When executing this, I get an error saying Attribute error: 'dict' object has no attribute 'hosts'. As you can see, I have commented out 'dumpNodeConnections(net.hosts)' as I thought that could be the root of the problem, although I believe it could also be related to the imports.

The reason I use OVSController here is because I saw it was a fix to an error I got saying 'Exception: Could not find a default OpenFlow controller' so I have a feeling it might be related to that too.

Any advice on how I could fix this error, or how I could bypass it entirely would be very much appreciated.

[EDIT] Since posting this question I have tried CPULimitedHost as the controller type, as well as a standard controller object and both gave the same error. Interestingly, when running the simpleperf.py the file runs but still, my file gives the same error.

0 Answers0