-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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