Signed-off-by: Benjamin Hesmans <benjamin.hesmans@uclouvain.be>
This commit is contained in:
Benjamin Hesmans 2015-01-08 19:52:45 +01:00
parent 7e373bbad5
commit e1e26d3817
12 changed files with 166 additions and 46 deletions

View File

@ -1,6 +1,6 @@
desc:Simple configuration with two para link desc:Simple configuration with two para link
leftSubnet:xxx leftSubnet:10.0.
rightSubnet:yyy rightSubnet:10.1.
midSubnet:zzz midSubnet:zzz
#path_x:delay,queueSize(may be calc),bw #path_x:delay,queueSize(may be calc),bw
error error

2
src/conf/xp/1_ping Normal file
View File

@ -0,0 +1,2 @@
xpType:ping
pingCount:10

View File

@ -6,6 +6,9 @@ class MpConfig:
self.topo = topo self.topo = topo
self.param = param self.param = param
def getClientInterfaceCount(self):
raise Exception("To be implemented")
def interfaceUpCommand(self, interfaceName, ip, subnet): def interfaceUpCommand(self, interfaceName, ip, subnet):
s = "ifconfig " + interfaceName + " " + ip + " netmask " + \ s = "ifconfig " + interfaceName + " " + ip + " netmask " + \
subnet subnet

30
src/mpExperience.py Normal file
View File

@ -0,0 +1,30 @@
from mpParamXp import MpParamXp
class MpExperience:
PING = "ping"
def __init__(self, xpParam, mpTopo, mpConfig):
self.xpParam = xpParam
self.mpTopo = mpTopo
self.mpConfig = mpConfig
print(self.xpParam)
def classicRun(self):
self.prepare()
self.run()
self.clean()
def prepare(self):
self.runTcpDump()
pass
def run(self):
pass
def clean(self):
pass
def runTcpDump(self):
if self.xpParam.getParam(MpParamXp.CLIENTPCAP) == "yes":
print("todo : run client dump")
if self.xpParam.getParam(MpParamXp.SERVERPCAP) == "yes":
print("todo : run server dump")

30
src/mpExperiencePing.py Normal file
View File

@ -0,0 +1,30 @@
from mpExperience import MpExperience
from mpParamXp import MpParamXp
class MpExperiencePing(MpExperience):
PING_OUTPUT = "ping.log"
def __init__(self, xpParamFile, mpTopo, mpConfig):
MpExperience.__init__(self, xpParamFile, mpTopo, mpConfig)
MpExperience.classicRun(self)
def prepapre(self):
MpExperience.prepare(self)
def clean(self):
MpExperience.clean(self)
def run(self):
self.mpTopo.commandTo(self.mpConfig.client, "rm " + \
MpExperiencePing.PING_OUTPUT )
count = self.xpParam.getParam(MpParamXp.PINGCOUNT)
for i in range(0, self.mpConfig.getClientInterfaceCount()):
cmd = self.pingCommand(self.mpConfig.getClientIP(i),
self.mpConfig.getServerIP(), n = count)
self.mpTopo.commandTo(self.mpConfig.client, cmd)
def pingCommand(self, fromIP, toIP, n=5):
s = "ping -c " + str(n) + " -I " + fromIP + " " + toIP + \
" >> " + MpExperiencePing.PING_OUTPUT
print(s)
return s

View File

@ -86,6 +86,9 @@ class MpMultiInterfaceConfig(MpConfig):
serverIP = rSubnet + "0.1" serverIP = rSubnet + "0.1"
return serverIP return serverIP
def getClientInterfaceCount(self):
return len(self.topo.switch)
def getRouterInterfaceServer(self): def getRouterInterfaceServer(self):
return self.getRouterInterfaceSwitch(len(self.topo.switch)) return self.getRouterInterfaceSwitch(len(self.topo.switch))
@ -98,11 +101,3 @@ class MpMultiInterfaceConfig(MpConfig):
def getServerInterface(self): def getServerInterface(self):
return MpTopo.serverName + "-eth0" return MpTopo.serverName + "-eth0"
def pingAllFromClient(self, n = 5):
i = 0
self.topo.commandTo(self.client, "rm " + MpConfig.PING_OUTPUT)
for l in self.topo.switch:
cmd = self.pingCommand(self.getClientIP(i),
self.getServerIP(), n)
self.topo.commandTo(self.client, cmd)
i = i + 1

35
src/mpParam.py Normal file
View File

@ -0,0 +1,35 @@
class MpParam:
def __init__(self, paramFile):
self.paramDic = {}
print("Create the param Object")
if paramFile is None:
print("default param...")
else:
self.loadParamFile(paramFile)
def loadParamFile(self, paramFile):
f = open(paramFile)
i = 0
for l in f:
i = i + 1
if l.startswith("#"):
continue
tab = l.split(":")
if len(tab) == 2:
self.paramDic[tab[0]] = tab[1][:-1]
else:
print("Ignored Line " + str(i))
print(l),
print("In file " + paramFile)
f.close()
def getParam(self, key):
if key in self.paramDic:
return self.paramDic[key]
return None
def __str__(self):
s = self.paramDic.__str__()
return s

View File

@ -1,7 +1,7 @@
from mpLinkCharacteristics import MpLinkCharacteristics from mpLinkCharacteristics import MpLinkCharacteristics
from mpParam import MpParam
class MpParamTopo(MpParam):
class MpParamTopo:
LSUBNET = "leftSubnet" LSUBNET = "leftSubnet"
RSUBNET = "rightSubnet" RSUBNET = "rightSubnet"
defaultValue = {} defaultValue = {}
@ -9,29 +9,10 @@ class MpParamTopo:
defaultValue[RSUBNET] = "10.2." defaultValue[RSUBNET] = "10.2."
def __init__(self, paramFile): def __init__(self, paramFile):
self.paramDic = {} MpParam.__init__(self, paramFile)
self.linkCharacteristics = [] self.linkCharacteristics = []
print("Create the param Object")
self.loadParamFile(paramFile)
self.loadLinkCharacteristics() self.loadLinkCharacteristics()
def loadParamFile(self, paramFile):
f = open(paramFile)
i = 0
for l in f:
i = i + 1
if l.startswith("#"):
continue
tab = l.split(":")
if len(tab) == 2:
self.paramDic[tab[0]] = tab[1][:-1]
else:
print("Ignored Line " + str(i))
print(l),
print("In file " + paramFile)
f.close()
def loadLinkCharacteristics(self): def loadLinkCharacteristics(self):
i = 0 i = 0
for k in sorted(self.paramDic): for k in sorted(self.paramDic):
@ -47,15 +28,17 @@ class MpParamTopo:
print(self.paramDic[k]) print(self.paramDic[k])
def getParam(self, key): def getParam(self, key):
if key in self.paramDic: val = MpParam.getParam(self, key)
return self.paramDic[key] if val is None:
elif key in MpParamTopo.defaultValue: if key in MpParamTopo.defaultValue:
return MpParamTopo[key] return MpParamTopo[key]
else: else:
raise Exception("Param not found " + key) raise Exception("Param not found " + key)
else:
return val
def __str__(self): def __str__(self):
s = self.paramDic.__str__() s = MpParam.__str__(self)
s = s + "\n" s = s + "\n"
for p in self.linkCharacteristics[:-1]: for p in self.linkCharacteristics[:-1]:
s = s + p.__str__() + "\n" s = s + p.__str__() + "\n"

34
src/mpParamXp.py Normal file
View File

@ -0,0 +1,34 @@
from mpParam import MpParam
class MpParamXp(MpParam):
RMEM = "rmem"
CLIENTPCAP = "clientPcap"
SERVERPCAP = "serverPcap"
XPTYPE = "xpType"
PINGCOUNT = "pingCount"
defaultValue = {}
defaultValue[RMEM] = "x y z"
defaultValue[CLIENTPCAP] = "no"
defaultValue[SERVERPCAP] = "no"
defaultValue[XPTYPE] = "ping"
defaultValue[PINGCOUNT] = "5"
def __init__(self, paramFile):
MpParam.__init__(self, paramFile)
def getParam(self, key):
val = MpParam.getParam(self, key)
if val is None:
if key in MpParamXp.defaultValue:
return MpParamXp.defaultValue[key]
else:
raise Exception("Param not found " + key)
else:
return val
def __str__(self):
s = MpParam.__str__(self)
return s

View File

@ -1,19 +1,26 @@
from mpTopo import MpTopo from mpTopo import MpTopo
from mpParamTopo import MpParamTopo from mpParamTopo import MpParamTopo
from mpParamXp import MpParamXp
from mpMultiInterfaceTopo import MpMultiInterfaceTopo from mpMultiInterfaceTopo import MpMultiInterfaceTopo
from mpMultiInterfaceConfig import MpMultiInterfaceConfig from mpMultiInterfaceConfig import MpMultiInterfaceConfig
from mpMininetBuilder import MpMininetBuilder from mpMininetBuilder import MpMininetBuilder
from mpExperiencePing import MpExperiencePing
from mpExperience import MpExperience
class MpXpRunner: class MpXpRunner:
def __init__(self, builderType, topoParamFile, xpParamFile): def __init__(self, builderType, topoParamFile, xpParamFile):
self.defParamXp(xpParamFile)
self.topoParam = MpParamTopo(topoParamFile) self.topoParam = MpParamTopo(topoParamFile)
self.defBuilder(builderType) self.defBuilder(builderType)
self.defTopo() self.defTopo()
self.defConfig() self.defConfig()
self.startTopo() self.startTopo()
self.runXp(xpParamFile) self.runXp()
self.stopTopo() self.stopTopo()
def defParamXp(self, xpParamFile):
self.xpParam = MpParamXp(xpParamFile)
def defBuilder(self, builderType): def defBuilder(self, builderType):
if builderType == MpTopo.mininetBuilder: if builderType == MpTopo.mininetBuilder:
self.topoBuilder = MpMininetBuilder() self.topoBuilder = MpMininetBuilder()
@ -37,12 +44,13 @@ class MpXpRunner:
self.mpTopo.startNetwork() self.mpTopo.startNetwork()
self.mpTopoConfig.configureNetwork() self.mpTopoConfig.configureNetwork()
def runXp(self, xpParamFile): def runXp(self):
if xpParamFile is None: xp = self.xpParam.getParam(MpParamXp.XPTYPE)
self.mpTopoConfig.pingAllFromClient() if xp == MpExperience.PING:
self.mpTopo.getCLI() MpExperiencePing(self.xpParam, self.mpTopo,
self.mpTopoConfig)
else: else:
raise Exception("TODO") print("Unfound xp type..." + xp)
def stopTopo(self): def stopTopo(self):
self.mpTopo.stopNetwork() self.mpTopo.stopNetwork()