1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91
| from mininet.topo import Topo from mininet.net import Mininet from mininet.util import dumpNodeConnections from mininet.node import RemoteController, OVSKernelSwitch, OVSSwitch, DefaultController from mininet.log import setLogLevel from mininet.cli import CLI from mininet.log import setLogLevel, info from functools import partial import time from mininet.link import Link, TCLink from flows_generator import generate_flows
experiment_duration = 180 n_mice_flows = 45 n_elephant_flows = 5
log_dir = "."
def Mininet_Init(): net = Mininet() c0 = net.addController() h1 = net.addHost('h1') h2 = net.addHost('h2') h11 = net.addHost('h11') h22 = net.addHost('h22') s1 = net.addSwitch('s1') s2 = net.addSwitch('s2') s3 = net.addSwitch('s3') s4 = net.addSwitch('s4') s5 = net.addSwitch('s5') net.addLink(h1, s1) net.addLink(h11, s1) net.addLink(h2, s2) net.addLink(h22, s2)
net.addLink(s1, s3) net.addLink(s2, s3) h1.setIP('10.0.0.1', 8) h2.setIP('10.0.0.2', 8) h11.setIP('10.0.0.3', 8) h22.setIP('10.0.0.4', 8) return net
def Test(): net = Mininet_Init() net.start()
while True: try: user_input = raw_input("GEN/CLI/QUIT: ") except EOFError as error: user_input = "QUIT"
if user_input.upper() == "GEN": experiment_duration = int(raw_input("Experiment duration: ")) n_elephant_flows = int(raw_input("Numb of elephant flows: ")) n_mice_flows = int(raw_input("Numb of mice flows: "))
generate_flows(n_elephant_flows, n_mice_flows, experiment_duration, net, log_dir)
elif user_input.upper() == "CLI": info("Running CLI...\n") CLI(net)
elif user_input.upper() == "QUIT": info("Terminating...\n") info("Dumping host connections")
dumpNodeConnections(net.hosts) print "Testing network connectivity" net.stop() break
else: print("Command not found")
if __name__ == '__main__': setLogLevel('info') Test()
|