28 pvt = platform.python_version_tuple()
29 if (int(pvt[0]) == 2)
and (int(pvt[1]) < 6):
30 print "This program requires Python 2.6 or later." 50 Read the configuration information from a named Mini Maxwell. 53 The parts of the structure are these: 54 jdata[0] - Data Version 56 jdata[2] - Full Configuration dictionary 58 The parts of the full configuration dictionary are: 59 full_config["general"] 60 full_config["upstream_impairments"] 61 full_config["downstream_impairments"] 62 full_config["upstream-filters"] 63 full_config["downstream-filters"] 64 full_config["filters"] 66 conn = httplib.HTTPConnection(mm2name)
67 conn.request(
"GET",
"/mm2/mpc/mm2.py/get_config_json")
68 resp = conn.getresponse()
70 if (resp.status/100) != 2:
71 raise Exception,resp.reason
87 MM_MAXRATE = 100000000
89 MM_DELAY_DISTRIBUTIONS = (
"none",
"normal",
"pareto",
"paretonormal",
95 "delay_amount":
"SetDelayAmount",
96 "delay_variation":
"SetDelayVariation",
97 "delay_distribution":
"SetDelayDistribution",
98 "delay_correlation":
"SetDelayCorrelation",
99 "delay_reorder":
"SetDelayReorder",
100 "drop_amount":
"SetDropAmount",
101 "drop_correlation":
"SetDropCorrelation",
102 "duplication_amount":
"SetDupAmount",
103 "duplication_correlation":
"SetDupCorrelation",
104 "reorder_gap":
"SetReorderGap",
105 "reorder_correlation":
"SetReorderCorrelation",
106 "reorder_amount":
"SetReorderAmount",
107 "bitrate_limit":
"SetRateLimit",
108 "corruption_amount":
"SetCorruptionAmount",
109 "corruption_correlation":
"SetCorruptionCorrelation" 114 @param bandnumber: Band number, an integer in range 1..5 115 @type bandnumber: int or long 116 @param leftflag: True if LAN-A to LAN-B, false if LAN-B to LAN-A 119 if (
not isinstance(bandnumber, (types.IntType, types.LongType)))
or \
120 (bandnumber < 1)
or (bandnumber > 5):
121 raise MiniMaxClientException,
"Band number not integer in range 1..5" 123 if not isinstance(leftflag, types.BooleanType):
124 raise MiniMaxClientException,
"Left/right flag not a boolean" 207 raise MiniMaxClientException,
"Delay Variation not in range 0 .. Delay Amount" 232 if (val < 0)
or (val > 60000):
233 raise MiniMaxClientException,
"Delay Amount not in range 0 .. 60000" 237 if (val < 0)
or (val > 60000):
238 raise MiniMaxClientException,
"Delay Amount not in range 0 .. 60000" 242 if (val < 0.0)
or (val > 100.0):
243 raise MiniMaxClientException,
"Delay Correlation not in range 0 .. 100" 248 if val
not in self.__class__.MM_DELAY_DISTRIBUTIONS:
249 raise MiniMaxClientException,
"Delay distribution must be one of %s" % \
250 str(self.__class__.MM_DELAY_DISTRIBUTIONS)
257 if (val < 0.0)
or (val > 100.0):
258 raise MiniMaxClientException,
"Drop Amount not in range 0 .. 100" 262 if (val < 0.0)
or (val > 100.0):
263 raise MiniMaxClientException,
"Drop Correlation not in range 0 .. 100" 267 if (val < 0.0)
or (val > 100.0):
268 raise MiniMaxClientException,
"Duplication Amount not in range 0 .. 100" 272 if (val < 0.0)
or (val > 100.0):
273 raise MiniMaxClientException,
"Duplication Correlation not in range 0 .. 100" 277 if (val < 0)
or (val > 1024):
278 raise MiniMaxClientException,
"Reorder Gap not in range 0 .. 1024" 282 if (val < 0.0)
or (val > 100.0):
283 raise MiniMaxClientException,
"Reorder Amount not in range 0 .. 100" 287 if (val < 0.0)
or (val > 100.0):
288 raise MiniMaxClientException,
"Reorder Correlation not in range 0 .. 100" 292 if (val < 0.0)
or (val > 100.0):
293 raise MiniMaxClientException,
"Corruption Amount not in range 0 .. 100" 297 if (val < 0.0)
or (val > 100.0):
298 raise MiniMaxClientException,
"Corruption Correlation not in range 0 .. 100" 302 if (val < 128)
or (val > self.__class__.MM_MAXRATE):
303 raise MiniMaxClientException,
"Rate Limit not in range 128 .. %u" % \
304 self.__class__.MM_MAXRATE
309 Set an item using the name used in the Mini Maxwell configuration file. 312 (self.__class__.__dict__[self.__class__.SetProcs[name]])(self, val)
326 "DELAY_CURVE_" + snumstr: self.__DelayDistribution.lower(),
328 "REORDER_AMOUNT_" + snumstr: format(self.
__ReorderAmount, self.__class__.PCNTFMT),
330 "DROP_AMOUNT_" + snumstr: format(self.
__DropAmount, self.__class__.PCNTFMT),
332 "DUP_AMOUNT_" + snumstr: format(self.
__DupAmount, self.__class__.PCNTFMT),
333 "DUP_CORR_" + snumstr: format(self.
__DupCorrelation, self.__class__.PCNTFMT),
334 "CORRUPTION_AMOUNT_" + snumstr: format(self.
__CorruptionAmount, self.__class__.PCNTFMT),
357 if (bnum < 1)
or (bnum > 5):
358 raise MiniMaxClientException,
"Band number must be in in range 1..5" 362 if (bnum < 1)
or (bnum > 5):
363 raise MiniMaxClientException,
"Band number must be in in range 1..5" 367 if (bnum < 1)
or (bnum > 5):
368 raise MiniMaxClientException,
"Band number must be in in range 1..5" 375 if not bnd.Validate():
378 if not bnd.Validate():
448 Construct a Bands object using the current configuration on 454 full_config = current[2]
456 downstream_impairs = full_config[
"downstream_impairments"]
458 upstream_impairs = full_config[
"upstream_impairments"]
461 for itm
in downstream_impairs:
462 bnd = bnds.GetLeftBand(bnum)
463 for imp
in itm.items():
464 bnd.SetByCnfigName(imp[0], imp[1])
468 for itm
in upstream_impairs:
469 bnd = bnds.GetRightBand(bnum)
470 for imp
in itm.items():
471 bnd.SetByCnfigName(imp[0], imp[1])
481 @param bandsobj: A Bands object containing the desired impairment settings. 482 @type bandsobj: Bands 483 @param mm2host: The hostname or IP address of the Mini Maxwell. 484 @type mm2host: string 489 conn = httplib.HTTPConnection(mm2host)
490 bdict = bandsobj.AsDict()
491 bdict[
"SUBMIT_FLOWIMPAIR_BUTTON"] =
"Submit" 492 params = urllib.urlencode(bdict)
493 headers = {
"Content-type":
"application/x-www-form-urlencoded",
494 "Accept":
"text/plain"}
495 conn.request(
"POST",
"/mm2/mpc/mm2.py/process_flows", params, headers)
496 resp = conn.getresponse()
498 if (resp.status/100) != 2:
499 raise Exception,resp.reason
507 if __name__ ==
"__main__":
509 if len(sys.argv) != 2:
510 print "Usage: %s <minimaxwell-hostname-or-ip-address>" % sys.argv[0]
514 mm2name = sys.argv[1]
601 bnds.SetDelayAmount(5,
True, 100)
602 bnds.SetDelayVariation(5,
True, 10)
603 bnds.SetDelayReorder(5,
True,
True)
604 bnds.SetDelayReorder(5,
False,
False)
def GetRightBand(self, bnum)
def SetByCnfigName(self, name, val)
def SetDropAmount(self, val)
def SetCorruptionCorrelation(self, val)
def SetRateLimit(self, val)
def SetDupAmount(self, val)
def DropCorrelation(self)
def DelayDistribution(self)
def SetDelayCorrelation(self, bnum, leftflag, val)
def CorruptionAmount(self)
def SetReorderCorrelation(self, val)
def SetDupCorrelation(self, bnum, leftflag, val)
def SetCorruptionAmount(self, val)
def SetDelayAmount(self, bnum, leftflag, val)
def GetMM2Config(mm2name)
def GetLeftBand(self, bnum)
def ReorderCorrelation(self)
def SetDropAmount(self, bnum, leftflag, val)
def CorruptionCorrelation(self)
def GetBand(self, bnum, leftflag)
def SetDelayDistribution(self, val)
def SetDupAmount(self, bnum, leftflag, val)
def SetDelayReorder(self, bnum, leftflag, val)
def GetMM2ConfigInJson(mm2name)
def SetReorderGap(self, bnum, leftflag, val)
def __init__(self, bandnumber, leftflag)
def SetDelayVariation(self, bnum, leftflag, val)
def SetDropCorrelation(self, val)
def SetDelayCorrelation(self, val)
def SetReorderAmount(self, val)
def SetReorderAmount(self, bnum, leftflag, val)
def ChangeBandsOnMM(bandsobj, mm2host)
def SetDropCorrelation(self, bnum, leftflag, val)
def SetCorruptionCorrelation(self, bnum, leftflag, val)
def SetCorruptionAmount(self, bnum, leftflag, val)
def SetDelayDistribution(self, bnum, leftflag, val)
def SetBandToDefaults(self, bnum, leftflag)
def SetDelayReorder(self, val)
def DelayCorrelation(self)
def SetDelayAmount(self, val)
def SetDelayVariation(self, val)
def SetReorderCorrelation(self, bnum, leftflag, val)
def GetCurrentBands(mm2name)
def SetDupCorrelation(self, val)
def SetRateLimit(self, bnum, leftflag, val)
def SetReorderGap(self, val)