Babak Memar
Babak Memar

Reputation: 47

Exception Error in mininet

I have used Mininet to create a simple custom topology. It worked correctly When I was running it for the first time, but after that I received following error message:

Exception: Error creating interface pair (s1-eth1,h1-eth0): RTNETLINK answers: File exists

what is it and how can I solve it?

here is my topology:

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


class CustomTopo (Topo):

    def build(self):

        S1 = self.addSwitch('s1')

        H1 = self.addHost('h1')
        H2 = self.addHost('h2')

        self.addLink(S1, H1)
        self.addLink(S1, H2)


topo = CustomTopo()
net = Mininet(topo)
net.start()

topos = {'mytopo': CustomTopo}

and for more information I use Mininet 2.3.0d1

I run it by following command without remote controller and received another error: sudo mn --custom /home/bob/Desktop/Mtopo.py --topo=mytopo --mac

the error is: Exception: Please shut down the controller which is running on port 6653

I checked netstat -nl | grep 6653 but there is no active session on port 6653 and there is no other controller to shutdown.

Upvotes: 0

Views: 5918

Answers (2)

Daniel
Daniel

Reputation: 440

You actually start Mininet twice. Once in your script and the other with the command line. Either change your script to:

from mininet.topo import Topo
from mininet.net import Mininet
from mininet.cli import CLI
from mininet.node import RemoteController

class CustomTopo (Topo):

    def build(self):

        S1 = self.addSwitch('s1')

        H1 = self.addHost('h1')
        H2 = self.addHost('h2')

        self.addLink(S1, H1)
        self.addLink(S1, H2)


topo = CustomTopo()
net = Mininet(topo, controller=lambda name: RemoteController(name, ip='127.0.0.1', protocol='tcp', port = 6633), autoSetMacs=True)
net.start()
CLI(net)
net.stop()

save to start_topology.py and run as

sudo python start_topology.run

or change your script to

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


class CustomTopo (Topo):

    def build(self):

        S1 = self.addSwitch('s1')

        H1 = self.addHost('h1')
        H2 = self.addHost('h2')

        self.addLink(S1, H1)
        self.addLink(S1, H2)


topo = CustomTopo()
topos = {'mytopo': CustomTopo}

save to mytopo.py and run as

sudo mn --custom mytopo.py --topo=mytopo --mac --controller=remote,ip=127.0.0.1,port=6633

(change the IP and PORT for your controller accordingly)

Upvotes: 0

dside
dside

Reputation: 110

use this library:

from mininet.link import TCLink, Intf

and this when you add a link:

self.addLink(s1, h1, cls=TCLink)

Upvotes: 0

Related Questions