Repository navigation
Open
Description
I had written a simple mininet code to make a topology that was working well with my controller logic. The topology I had was
h refers to host, of refers to openflow switch
h1 <-> of1
h2 <-> of2
h3 <-> of2
h4 <-> of3
of1 <-> of2
of2 <-> of3
After that I did the following changes to the topology, Below is Image and code for the mininet network that is not working now with same controller
https://i.sstatic.net/JrqxFj2C.png
import os
from mininet.log import info
from mininet.cli import CLI
from mininet.link import TCLink
from mininet.net import Mininet
from mininet.node import RemoteController, OVSSwitch
def setup_network():
net = Mininet(controller=RemoteController, switch=OVSSwitch, link=TCLink)
# Add Ryu controller
info('[+] Adding Ryu controller\n')
c0 = net.addController('c0', controller=RemoteController)
# Add switches, hosts, and links as before
info('[+] Adding OpenFlow switches\n')
of1 = net.addSwitch('of1')
of2 = net.addSwitch('of2')
of3 = net.addSwitch('of3')
of4 = net.addSwitch('of4')
of5 = net.addSwitch('of5')
# Adding hosts
info('[+] Adding hosts\n')
h1 = net.addHost('h1', ip='10.0.0.1')
h2 = net.addHost('h2', ip='10.0.0.2')
h3 = net.addHost('h3', ip='10.0.0.3')
h4 = net.addHost('h4', ip='10.0.0.4')
h5 = net.addHost('h5')
h6 = net.addHost('h6')
# Adding links based on the diagram (switches connected to each other and hosts)
info('[+] Adding links between switches, hosts, and edge servers\n')
# Links between Switches
net.addLink(of1, of2) # horizontal connection
net.addLink(of2, of3)
net.addLink(of4, of5)
net.addLink(of1, of4) # Vertical connection
net.addLink(of2, of4)
net.addLink(of3, of5)
# Link between Host & Switched
net.addLink(of1, h1)
net.addLink(of1, h2)
net.addLink(of2, h3)
net.addLink(of2, h4)
net.addLink(of3, h5)
net.addLink(of3, h6)
# Start the network
net.build()
c0.start() # Start the controller
net.start()
# Discover the topology
topology = topology_discovery(net)
CLI(net)
net.stop()
return net, topology
# --------------------------------------- TOPOLOGY DISCOVERY ------------------------------------------
def topology_discovery(net):
info('[*] Discovering topology\n')
topology = {
'switches': {},
'hosts': {},
'links': []
}
for switch in net.switches:
topology['switches'][switch.name] = switch
for host in net.hosts:
topology['hosts'][host.name] = host
for link in net.links:
topology['links'].append((link.intf1.node.name, link.intf2.node.name))
print("\n===================================================================================================")
print("[!] Discovered Topology:")
print("Switches:", topology['switches'].keys())
print("Hosts:", topology['hosts'].keys())
print("Links:", topology['links'])
print("===================================================================================================")
return topology
if __name__ == '__main__':
# os.system("mn -c")
setup_network()
Can anyone tell why the Controller is not sending packets, what is wrong with my mininet network
Metadata
Metadata
Assignees
Labels
No labels
Activity
Luke5080 commentedon Jun 9, 2025
Hello Farhan,
I am assuming that this does not seem to be a Mininet issue itself, but is an issue in how you are assuming that your hosts will have connectivity within Mininet using the Ryu controller. I have not run your code, but from I can see you are creating the topology using the Mininet API, and attempting to discover the topology and recording hosts and switches within a dictionary. In order to use the Ryu controller with this topology, you must create a Ryu application which can forward packets to the correct ports on the switches, either proactively (once the Ryu controller discovers the hosts, implement flows to allow connectivity to the hosts based on the topology) or reactively (as the controller learns about ports on switches and what is connected to them, forward the respective packet out of the port). I cannot seem to access the link you posted, but it would be helpful to provide the code you are using for the Ryu controller (if any). If you have not created a Ryu application, I recommend starting and understanding how the simple switch provided by Ryu works, and then making the appropriate adjustments for your use case.
If this does not help, please provide your Ryu code, and it can be determined if this is a Mininet or Ryu problem which you are facing.