research/fraginternals: Test: adding enforce_pre_delay

Adding a delay before actually executing the test. This can be useful in
all the cases the network stack of the victim is still not ready to
receive packets leading to a timed out test result.

Suggested-by: Michael Trimarchi <michael@amarulasolutions.com>
Signed-off-by: Angelo Compagnucci <angelo@amarulasolutions.com>
This commit is contained in:
Angelo Compagnucci 2021-10-07 10:57:27 +02:00 committed by Mathy Vanhoef
parent 33b49cbad3
commit 4c59cdfffd

View File

@ -261,7 +261,7 @@ class Test(metaclass=abc.ABCMeta):
def generate(self, station): def generate(self, station):
self.prepare(station) self.prepare(station)
self.enforce_delay() self.enforce_delays()
self.enforce_inc_pn() self.enforce_inc_pn()
def check(self, p): def check(self, p):
@ -274,13 +274,19 @@ class Test(metaclass=abc.ABCMeta):
self.delay = delay self.delay = delay
self.inc_pn = inc_pn self.inc_pn = inc_pn
def enforce_delay(self): def enforce_delays(self):
if self.delay == None or self.delay <= 0: inject_frags = self.get_actions(Action.Inject)
return
# Add a delay between injected fragments if requested # Add a delay before executing the first Inject action. This means a delay is added after
for frag in self.get_actions(Action.Inject)[1:]: # possibly getting an IP via DHCP but before injecting the first test fragment/frame.
frag.delay = self.delay if self.pre_delay is not None and self.pre_delay > 0:
assert len(inject_frags) > 0
inject_frags[0].delay = self.pre_delay
# Add a delay between every next injected fragments if requested
if self.delay is not None and self.delay > 0:
for frag in inject_frags[1:]:
frag.delay = self.delay
def enforce_inc_pn(self): def enforce_inc_pn(self):
if self.inc_pn == None: if self.inc_pn == None: