How to disable ipv6 in Mininet
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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