|
@@ -7,7 +7,7 @@ import re
|
|
|
import tempfile
|
|
|
from abc import abstractmethod, ABCMeta
|
|
|
from scapy.layers.inet import Ether
|
|
|
-import numpy as np
|
|
|
+import numpy as np, math
|
|
|
|
|
|
import ID2TLib.libpcapreader as pr
|
|
|
from scapy.utils import PcapWriter
|
|
@@ -16,7 +16,6 @@ from Attack import AttackParameters
|
|
|
from Attack.AttackParameters import Parameter
|
|
|
from Attack.AttackParameters import ParameterTypes
|
|
|
|
|
|
-
|
|
|
class BaseAttack(metaclass=ABCMeta):
|
|
|
"""
|
|
|
Abstract base class for all attack classes. Provides basic functionalities, like parameter validation.
|
|
@@ -459,10 +458,11 @@ class BaseAttack(metaclass=ABCMeta):
|
|
|
"""
|
|
|
pass
|
|
|
|
|
|
- def get_reply_delay(self, ip_dst):
|
|
|
+ def get_reply_delay(self, ip_dst, default = 2000):
|
|
|
"""
|
|
|
Gets the minimum and the maximum reply delay for all the connections of a specific IP.
|
|
|
:param ip_dst: The IP to reterive its reply delay.
|
|
|
+ :param default: The default value to return if no delay could be fount. If < 0 raise an exception instead
|
|
|
:return minDelay: minimum delay
|
|
|
:return maxDelay: maximum delay
|
|
|
|
|
@@ -477,6 +477,14 @@ class BaseAttack(metaclass=ABCMeta):
|
|
|
minDelay = np.median(allMinDelays)
|
|
|
allMaxDelays = self.statistics.process_db_query("SELECT maxDelay FROM conv_statistics LIMIT 500;")
|
|
|
maxDelay = np.median(allMaxDelays)
|
|
|
+
|
|
|
+ if math.isnan(minDelay): # maxDelay is nan too then
|
|
|
+ if default < 0:
|
|
|
+ raise ValueError("Could not calculate min/maxDelay")
|
|
|
+
|
|
|
+ minDelay = default
|
|
|
+ maxDelay = default
|
|
|
+
|
|
|
minDelay = int(minDelay) * 10 ** -6 # convert from micro to seconds
|
|
|
maxDelay = int(maxDelay) * 10 ** -6
|
|
|
return minDelay, maxDelay
|