diff --git a/src/conf/xp/0_iperf_1 b/src/conf/xp/0_iperf_1 new file mode 100644 index 0000000..291e197 --- /dev/null +++ b/src/conf/xp/0_iperf_1 @@ -0,0 +1,9 @@ +#option to dvlp are commented but already there. +#kCommit:aaaa +#pmCommit:bbb +#sysctl:mem,x y z +#sysctl:rmem,x y z +#sysctl:wmem,x y z +xpType:iperf +size:10M + diff --git a/src/mpPerf.py b/src/mpPerf.py index 7e24353..2241a49 100755 --- a/src/mpPerf.py +++ b/src/mpPerf.py @@ -1,21 +1,21 @@ #!/usr/bin/python import sys, getopt -from mpParamTopo import MpParamTopo -from mpMultiInterfaceTopo import MpMultiInterfaceTopo -from mpMultiInterfaceConfig import MpMultiInterfaceConfig -from mpMininetBuilder import MpMininetBuilder +from mpXpRunner import MpXpRunner +from mpTopo import MpTopo topoParamFile = None -topoType = "mininet" +xpParamFile = None +topoBuilder = "mininet" def printHelp(): print("Help Menu") def parseArgs(argv): global topoParamFile + global xpParamFile try: - opts, args = getopt.getopt(argv, "hf:", ["topoParam="]) + opts, args = getopt.getopt(argv, "ht:x:", ["topoParam=","xp="]) except getopt.GetoptError: printHelp() sys.exit(1) @@ -23,28 +23,16 @@ def parseArgs(argv): if opt == "-h": printHelp() sys.exit(1) - elif opt in ("-f","--topoParam"): - print("hllo", arg); + elif opt in ("-x","--xp"): + xpParamFile = arg + elif opt in ("-t","--topoParam"): + print("hey") topoParamFile = arg - - + if topoParamFile is None: + print("Missing the topo...") + printHelp() + sys.exit(1) if __name__ == '__main__': parseArgs(sys.argv[1:]) - if topoParamFile is None: - print("Use command line param") - else: - param = MpParamTopo(topoParamFile) - - if topoType == "mininet": - if param.getParam('topoType') == "MultiIf": - mpTopo = MpMultiInterfaceTopo(MpMininetBuilder(), param) - mpConfig = MpMultiInterfaceConfig(mpTopo, param) - mpTopo.startNetwork() - mpConfig.configureNetwork() - mpConfig.pingAllFromClient() - mpTopo.getCLI() - mpTopo.stopNetwork() - else: - print("Unrecognized topo type") - print(mpTopo) + MpXpRunner(MpTopo.mininetBuilder, topoParamFile, xpParamFile) diff --git a/src/mpTopo.py b/src/mpTopo.py index 0e454e9..3581ff3 100644 --- a/src/mpTopo.py +++ b/src/mpTopo.py @@ -1,4 +1,7 @@ class MpTopo: + mininetBuilder = "mininet" + multiIfTopo = "MultiIf" + topoAttr = "topoType" switchNamePrefix = "s" clientName = "Client" serverName = "Server" diff --git a/src/mpXpRunner.py b/src/mpXpRunner.py new file mode 100644 index 0000000..c3f0423 --- /dev/null +++ b/src/mpXpRunner.py @@ -0,0 +1,48 @@ +from mpTopo import MpTopo +from mpParamTopo import MpParamTopo +from mpMultiInterfaceTopo import MpMultiInterfaceTopo +from mpMultiInterfaceConfig import MpMultiInterfaceConfig +from mpMininetBuilder import MpMininetBuilder + +class MpXpRunner: + def __init__(self, builderType, topoParamFile, xpParamFile): + self.topoParam = MpParamTopo(topoParamFile) + self.defBuilder(builderType) + self.defTopo() + self.defConfig() + self.startTopo() + self.runXp(xpParamFile) + self.stopTopo() + + def defBuilder(self, builderType): + if builderType == MpTopo.mininetBuilder: + self.topoBuilder = MpMininetBuilder() + else: + raise Exception("I can not find the builder " + + builderType) + def defTopo(self): + t = self.topoParam.getParam(MpTopo.topoAttr) + if t == MpTopo.multiIfTopo: + self.mpTopo = MpMultiInterfaceTopo(self.topoBuilder, + self.topoParam) + else: + raise Exception("Unfound Topo" + t) + print(self.mpTopo) + + def defConfig(self): + self.mpTopoConfig = MpMultiInterfaceConfig(self.mpTopo, + self.topoParam) + + def startTopo(self): + self.mpTopo.startNetwork() + self.mpTopoConfig.configureNetwork() + + def runXp(self, xpParamFile): + if xpParamFile is None: + self.mpTopoConfig.pingAllFromClient() + self.mpTopo.getCLI() + else: + raise Exception("TODO") + + def stopTopo(self): + self.mpTopo.stopNetwork()