mininet-sample/mpXpRunner.py

106 lines
3.4 KiB
Python
Raw Normal View History

2020-06-24 08:36:26 +00:00
from core.experience import Experience, ExperienceParameter, ExperienceParameter
from core.topo import Topo, TopoParameter
2020-06-24 09:26:56 +00:00
from mininet_builder import MininetBuilder
2020-06-24 14:11:54 +00:00
from topos import TOPO_CONFIGS, TOPOS
from experiences import EXPERIENCES
2020-06-24 10:28:44 +00:00
2020-06-24 08:36:26 +00:00
from mpExperienceNCPV import ExperienceNCPV
from mpExperienceNC import ExperienceNC
from mpExperienceSendFile import ExperienceSendFile
from mpExperienceEpload import ExperienceEpload
from mpExperienceNetperf import ExperienceNetperf
from mpExperienceSiri import ExperienceSiri
from mpExperienceVLC import ExperienceVLC
from mpExperienceIperf import ExperienceIperf
from mpExperienceMsg import ExperienceMsg
from mpExperienceSiriHTTP import ExperienceSiriHTTP
from mpExperienceSiriMsg import ExperienceSiriMsg
from mpExperienceQUIC import ExperienceQUIC
from mpExperienceQUICSiri import ExperienceQUICSiri
2020-06-24 14:11:54 +00:00
class MpXpRunner:
def __init__(self, builderType, topoParamFile, xpParamFile):
self.defParamXp(xpParamFile)
2020-06-24 08:36:26 +00:00
self.topoParam = TopoParameter(topoParamFile)
self.defBuilder(builderType)
self.defTopo()
self.defConfig()
self.startTopo()
self.runXp()
self.stopTopo()
def defParamXp(self, xpParamFile):
2020-06-24 08:36:26 +00:00
self.xpParam = ExperienceParameter(xpParamFile)
def defBuilder(self, builderType):
2020-06-24 08:36:26 +00:00
if builderType == Topo.mininetBuilder:
2020-06-24 09:26:56 +00:00
self.topoBuilder = MininetBuilder()
else:
raise Exception("I can not find the builder " +
builderType)
def defTopo(self):
2020-06-24 08:36:26 +00:00
t = self.topoParam.getParam(Topo.topoAttr)
2020-06-24 14:11:54 +00:00
if t in TOPOS:
self.Topo = TOPOS[t](self.topoBuilder, self.topoParam)
else:
2020-06-24 10:28:44 +00:00
raise Exception("Unknown topo: {}".format(t))
2020-06-24 08:36:26 +00:00
print(self.Topo)
def defConfig(self):
2020-06-24 08:36:26 +00:00
t = self.topoParam.getParam(Topo.topoAttr)
2020-06-24 14:11:54 +00:00
if t in TOPO_CONFIGS:
self.TopoConfig = TOPO_CONFIGS[t](self.Topo, self.topoParam)
else:
2020-06-24 10:28:44 +00:00
raise Exception("Unknown topo config: {}".format(t))
def startTopo(self):
2020-06-24 08:36:26 +00:00
self.Topo.startNetwork()
self.TopoConfig.configureNetwork()
def runXp(self):
2020-06-24 08:36:26 +00:00
xp = self.xpParam.getParam(ExperienceParameter.XPTYPE)
2020-06-24 14:11:54 +00:00
if xp in EXPERIENCES:
EXPERIENCES[xp](self.xpParam, self.Topo, self.TopoConfig)
2020-06-24 08:36:26 +00:00
elif xp ==Experience.NCPV:
ExperienceNCPV(self.xpParam, self.Topo,
self.TopoConfig)
elif xp ==Experience.NC:
ExperienceNC(self.xpParam, self.Topo,
self.TopoConfig)
elif xp ==Experience.EPLOAD:
ExperienceEpload(self.xpParam, self.Topo,
self.TopoConfig)
elif xp ==Experience.NETPERF:
ExperienceNetperf(self.xpParam, self.Topo,
self.TopoConfig)
elif xp ==Experience.SIRI:
ExperienceSiri(self.xpParam, self.Topo,
self.TopoConfig)
elif xp ==Experience.SENDFILE:
ExperienceSendFile(self.xpParam, self.Topo,
self.TopoConfig)
elif xp ==Experience.VLC:
ExperienceVLC(self.xpParam, self.Topo,
self.TopoConfig)
elif xp ==Experience.IPERF:
ExperienceIperf(self.xpParam, self.Topo,
self.TopoConfig)
elif xp ==Experience.MSG:
ExperienceMsg(self.xpParam, self.Topo, self.TopoConfig)
elif xp ==Experience.SIRIHTTP:
ExperienceSiriHTTP(self.xpParam, self.Topo, self.TopoConfig)
elif xp ==Experience.SIRIMSG:
ExperienceSiriMsg(self.xpParam, self.Topo, self.TopoConfig)
elif xp ==Experience.QUIC:
ExperienceQUIC(self.xpParam, self.Topo, self.TopoConfig)
elif xp ==Experience.QUICSIRI:
ExperienceQUICSiri(self.xpParam, self.Topo, self.TopoConfig)
else:
2020-06-24 14:11:54 +00:00
raise Exception("Unknown experience {}".format(xp))
def stopTopo(self):
2020-06-24 08:36:26 +00:00
self.Topo.stopNetwork()