2015-01-07 13:44:44 +00:00
|
|
|
class MpConfig:
|
2015-01-07 15:00:15 +00:00
|
|
|
|
|
|
|
PING_OUTPUT = "ping.log"
|
|
|
|
|
2015-01-07 13:44:44 +00:00
|
|
|
def __init__(self, topo, param):
|
|
|
|
self.topo = topo
|
|
|
|
self.param = param
|
|
|
|
|
2015-01-08 18:52:45 +00:00
|
|
|
def getClientInterfaceCount(self):
|
|
|
|
raise Exception("To be implemented")
|
|
|
|
|
2015-01-07 13:44:44 +00:00
|
|
|
def interfaceUpCommand(self, interfaceName, ip, subnet):
|
|
|
|
s = "ifconfig " + interfaceName + " " + ip + " netmask " + \
|
|
|
|
subnet
|
|
|
|
print(s)
|
|
|
|
return s
|
|
|
|
|
|
|
|
def addRouteTableCommand(self, fromIP, id):
|
|
|
|
s = "ip rule add from " + fromIP + " table " + str(id + 1)
|
|
|
|
print(s)
|
|
|
|
return s
|
|
|
|
|
|
|
|
def addRouteScopeLinkCommand(self, network, interfaceName, id):
|
|
|
|
s = "ip route add " + network + " dev " + interfaceName + \
|
|
|
|
" scope link table " + str(id + 1)
|
|
|
|
print(s)
|
|
|
|
return s
|
|
|
|
|
|
|
|
def addRouteDefaultCommand(self, via, id):
|
|
|
|
s = "ip route add default via " + via + " table " + str(id + 1)
|
|
|
|
print(s)
|
|
|
|
return s
|
|
|
|
|
|
|
|
def addRouteDefaultGlobalCommand(self, via, interfaceName):
|
|
|
|
s = "ip route add default scope global nexthop via " + via + \
|
|
|
|
" dev " + interfaceName
|
|
|
|
print(s)
|
|
|
|
return s
|
|
|
|
|
|
|
|
def addRouteDefaultSimple(self, via):
|
|
|
|
s = "ip route add default via " + via
|
|
|
|
print(s)
|
|
|
|
return s
|
2015-01-07 15:00:15 +00:00
|
|
|
|
|
|
|
def pingCommand(self, fromIP, toIP, n=5):
|
|
|
|
s = "ping -c " + str(n) + " -I " + fromIP + " " + toIP + \
|
|
|
|
" >> " + MpConfig.PING_OUTPUT
|
|
|
|
print(s)
|
|
|
|
return s
|