Skip to content

Instantly share code, notes, and snippets.

@tudang
Created November 16, 2016 13:00
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • 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
#!/usr/bin/python
from mininet.topo import Topo
from mininet.net import Mininet
from mininet.node import CPULimitedHost, Controller, RemoteController, OVSSwitch, Ryu
from mininet.link 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', 'my_controller.py')
net = Mininet(topo=topo,switch=OVSSwitch13,
## Run controller manually
controller=RemoteController('c0', ip='127.0.0.1'),
## 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")
net.start()
print "Dumping host connections"
dumpNodeConnections(net.hosts)
CLI(net)
net.stop()
if __name__ == '__main__':
setLogLevel('info')
perfTest()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment