faucetsdn / ryu

Ryu component-based software defined networking framework
https://ryu-sdn.org
Apache License 2.0
1.5k stars 1.16k forks source link

Ryu not picking up "addLink" event after topology startup #175

Open Peachmann opened 1 year ago

Peachmann commented 1 year ago

I'm trying to modify the topology during runtime, adding new switches and links on the fly. I use the guitopology.py app to monitor the current topology (with --observe-links). If I add and connect switches before net.start()_ it shows correctly.

If I add a switch and start it up it shows correctly. If I try to link it, the event is not caught by EventLinkAdd, and not shown. If I query the current links (nodes, links etc.) in mininet CLI, everything seems to be correct and working (I can ping the new switch, works).

Tried: Link status up/down, adding links from mininet CLI, removing/readding, adding flows to working links etc.

Simple demonstration below:

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

class TwoSwitchTopo(Topo):

    def build(self):
        s1 = self.addSwitch('s1')
        s2 = self.addSwitch('s2')

        h1 = self.addHost('h1', mac="00:00:00:00:11:11", ip="192.168.1.1/24")
        h2 = self.addHost('h2', mac="00:00:00:00:11:12", ip="192.168.1.2/24")

        self.addLink(h1, s1)
        self.addLink(h2, s1)
        self.addLink(s1, s2)

if __name__ == '__main__':
    setLogLevel('info')
    topo = TwoSwitchTopo()
    c1 = RemoteController('c1')
    net = Mininet(topo=topo, controller=c1)
    net.start()

    #sleep(5)
    print("Topology is up, adding new switch and link")

    s3 = net.addSwitch('s3')
    net.addLink(net.getNodeByName('s1'), s3)
    s3.start([c1])

    CLI(net)
    net.stop()

Result: image

JimCSuen commented 7 months ago

Hi, I just come up with the same problem.

I solve it by adding the parameter "--observe-links" when I launch my RYU-controller python file, just like what you do when you want to show links on the RYU_GUI_Topology. Finally the EventLinkAdd could be caught.