mininet-sample/src/mpMininetBuilder.py
Benjamin Hesmans 6576eb330f add changePvAt to control application rate
During an experiment, you can change the application rate with the
param changePvAt:when,-L XX(unit)

Signed-off-by: Benjamin Hesmans <benjamin.hesmans@uclouvain.be>
2015-02-10 11:03:21 +01:00

45 lines
971 B
Python

from mininet.topo import Topo
from mininet.net import Mininet
from mininet.link import TCLink
from mininet.cli import CLI
from subprocess import Popen, PIPE
class MpMininetBuilder(Topo):
def __init__(self):
Topo.__init__( self )
self.net = None
def commandTo(self, who, cmd):
return who.cmd(cmd)
def notNSCommand(self, cmd):
p = Popen(cmd, shell=True, stdout=PIPE, stderr=PIPE)
stdout, stderr = p.communicate()
if stderr:
return "Error"
return stdout
def startNetwork(self):
self.net = Mininet(topo=self,link=TCLink)
self.net.start()
def getCLI(self):
if self.net is None:
print("Can not get the CLI")
else:
CLI(self.net)
def getHost(self, who):
if self.net is None:
print("Network not available....")
raise Exception("Network not ready");
else:
return self.net.getNodeByName(who)
def stopNetwork(self):
if self.net is None:
print("Could not stop network... Nothing to stop)")
else:
self.net.stop()