Skip to content

Instantly share code, notes, and snippets.

Created November 16, 2016 13:00
Show Gist options
  • Save tudang/87da66215116e2ba5afd250a9fb8a9c8 to your computer and use it in GitHub Desktop.
Save tudang/87da66215116e2ba5afd250a9fb8a9c8 to your computer and use it in GitHub Desktop.
How to disable ipv6 in Mininet
from mininet.topo import Topo
from import Mininet
from mininet.node import CPULimitedHost, Controller, RemoteController, OVSSwitch, Ryu
from import TCLink
from mininet.util import dumpNodeConnections
from mininet.log import setLogLevel
from mininet.cli import CLI
from functools import partial
from parse_topology import CustomTopo
class CustomMininetTopo(Topo):
"Single switch connected to n hosts."
def build(self):
topo_dict = CustomTopo('topo.txt')
routers = topo_dict.get_routers()
links = topo_dict.get_links()
self.host_id = 1
print routers
for name, router in routers.items():
switch = self.addSwitch(router['dpid'])
# Each host gets 50%/n of system CPU
# host = self.addHost('h%d' % self.host_id , cpu=.5/n)
host = self.addHost('h%d' % self.host_id)
self.host_id += 1
# 10 Mbps, 5ms delay, 10% loss, 1000 packet queue
self.addLink(host, switch, bw=100 )
# bw=10, delay='5ms', loss=10, max_queue_size=1000, use_htb=True)
for link in links:
# print link['x'], link['y'], link['kbps'], link['OSPF']
self.addLink(link['x'], link['y'], bw=link['kbps']/10000)
def perfTest():
"Create network and run simple performance test"
topo = CustomMininetTopo()
OVSSwitch13 = partial( OVSSwitch, protocols='OpenFlow13' )
# ryu_controller = Ryu('ryu_c1', '')
net = Mininet(topo=topo,switch=OVSSwitch13,
## Run controller manually
controller=RemoteController('c0', ip=''),
## Run controller Automatically
# controller=ryu_controller,
autoSetMacs = True,
autoStaticArp = True,
host=CPULimitedHost, link=TCLink)
for h in net.hosts:
print "disable ipv6"
h.cmd("sysctl -w net.ipv6.conf.all.disable_ipv6=1")
h.cmd("sysctl -w net.ipv6.conf.default.disable_ipv6=1")
h.cmd("sysctl -w net.ipv6.conf.lo.disable_ipv6=1")
for sw in net.switches:
print "disable ipv6"
sw.cmd("sysctl -w net.ipv6.conf.all.disable_ipv6=1")
sw.cmd("sysctl -w net.ipv6.conf.default.disable_ipv6=1")
sw.cmd("sysctl -w net.ipv6.conf.lo.disable_ipv6=1")
print "Dumping host connections"
if __name__ == '__main__':
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment