added number of packets ration validator

This commit is contained in:
Raphael Bauduin 2015-05-26 12:19:16 -07:00
parent ac1e857f79
commit 20f1288603
2 changed files with 48 additions and 5 deletions

View File

@ -16,6 +16,9 @@ class Validation:
return self.__class__.__name__
def validate(self,value):
raise Exception("Method not implemented")
def setup(self):
raise Exception("Method not implemented")
# checks a value passed is greater or equal (generic)
class MinValueValidation(Validation):
@ -56,13 +59,39 @@ class MinDelayBetweenValidation(Validation):
self.value = val
return self.compared<=val
class AttributeMinimumDifferenceValidation(Validation):
def validate(self, flow_spec):
class AttributeValidation(Validation):
def setup(self, flow_spec):
(yml ,trace) = flow_spec
[index0, index1] = yml["index"]
val = trace.get(index1, yml["attribute"]) - trace.get(index0, yml["attribute"])
self.value = val
return self.compared<=val
self.val0 = trace.get(index0, yml["attribute"])
self.val1 = trace.get(index1, yml["attribute"])
class AttributeMinimumDifferenceValidation(AttributeValidation):
def validate(self, flow_spec):
self.setup(flow_spec)
self.value = self.val1 - self.val0
return self.compared<=self.value
class AttributeMaximumDifferenceValidation(AttributeValidation):
def validate(self, flow_spec):
self.setup(flow_spec)
self.value = self.val1 - self.val0
return self.compared>=self.value
class AttributeMinimumRatioValidation(AttributeValidation):
def validate(self, flow_spec):
self.setup(flow_spec)
self.value = float(self.val1)/+float(self.val1)
return self.compared<=self.value
class AttributeMaximumRatioValidation(AttributeValidation):
def validate(self, flow_spec):
self.setup(flow_spec)
self.value = float(self.val1)/float(self.val0)
return self.compared>=self.value
# Base class testing tcptrace results

View File

@ -20,6 +20,8 @@ tcptrace:
desc: "Minimum 2 seconds delay between opening of first and second flow"
# validates time between first packets of streams for which the index is passed.
# index is now a compound value, handled by the validate method of the class MinDelayBetweenValidation
# first index value is the base flow we compare to
# second index is the flow we want to validate
- name: "min_delay_between"
index:
- 1
@ -28,8 +30,20 @@ tcptrace:
desc: "Minimum 1 second delay between opening of second and third flow"
- name: "attribute_minimum_difference"
attribute: "first_packet"
# first index value is the base flow we compare to
# second index is the flow we want to validate
index:
- 0
- 1
target: 2
desc: "first packet delay 2nd flow"
- name: "attribute_maximum_ratio"
attribute: "total_packets_a2b"
# first index value is the base flow we compare to
# second index is the flow we want to validate
index:
- 0
- 1
# 5%
target: 0.05
desc: "a->b packet ration flow 2 compard to flow1"