I am new to Python and Mininet. I have been trying to emulate a network topology using mininet. I am trying to assign IP addresses to each of the hosts in the network but I'm getting an attribute error. Below is my code
import sys
from mininet.topo import Topo
from mininet.node import Node
class MyTopo(Topo):
"customized topology example"
def __init__(self):
"custom topo creation"
#initialize topology
Topo.__init__(self)
H1=self.addHost('H1')
H3=self.addHost('H3')
H2=self.addHost('H2')
H4=self.addHost('H4')
S1=self.addSwitch('S1')
S2=self.addSwitch('S2')
self.addLink(H1,S1, bw=10, delay='2ms')
self.addLink(H2,S1, bw=20, delay='10ms')
self.addLink(H3,S2, bw=10, delay='2ms')
self.addLink(H4,S2, bw=20, delay='10ms')
self.addLink(S1,S2, bw=20, delay='2ms', losspct=10)
H1.setIP(self,None,'10.0.0.1',8)
topos={'mytopo':(lambda:MyTopo())}
I get the following error
Caught exception. Cleaning up...
AttributeError: 'str' object has no attribute 'setIp'
----------------------------------------------------------------------- ---------
*** Removing excess controllers/ofprotocols/ofdatapaths/pings/noxes
killall controller ofprotocol ofdatapath ping nox_core lt-nox_core ovs- openflowd ovs-controller udpbwtest mnexec ivs 2> /dev/null
killall -9 controller ofprotocol ofdatapath ping nox_core lt-nox_core ovs openflowd ovs-controller udpbwtest mnexec ivs 2> /dev/null
pkill -9 -f "sudo mnexec"
*** Removing junk from /tmp
rm -f /tmp/vconn* /tmp/vlogs* /tmp/*.out /tmp/*.log
*** Removing old X11 tunnels
*** Removing excess kernel datapaths
ps ax | egrep -o 'dp[0-9]+' | sed 's/dp/nl:/'
*** Removing OVS datapathsovs-vsctl --timeout=1 list-br
*** Removing all links of the pattern foo-ethX
ip link show | egrep -o '(\w+-eth\w+)'
*** Cleanup complete.
Thanks