@@ -76,7 +76,7 @@ def get_timewindow(self, flowtime, profileid):
76
76
belong to that tw
77
77
if it is == the end of a tw, it will belong to the next one
78
78
for example,
79
- a flow with ts = 2 belongs to tw1
79
+ a flow with ts = 2 belongs to tw2
80
80
a flow with ts = 4 belongs to tw3
81
81
82
82
tw1 tw2 tw3 tw4
@@ -1178,6 +1178,7 @@ def get_modified_profiles_since(
1178
1178
time_of_last_modified_tw : float = modified_tws [- 1 ][- 1 ]
1179
1179
1180
1180
# this list will store modified profiles without tws
1181
+ # this is a list of ips. not profileids
1181
1182
profiles = []
1182
1183
profiles .extend (
1183
1184
modified_tw [0 ].split ("_" )[1 ] for modified_tw in modified_tws
@@ -1472,32 +1473,35 @@ def add_profile(self, profileid, starttime):
1472
1473
self .print (type (inst ), 0 , 1 )
1473
1474
self .print (inst , 0 , 1 )
1474
1475
1475
- def set_profile_module_label (self , profileid , module , label ):
1476
+ def set_module_label_for_profile (self , profileid , module , label ):
1476
1477
"""
1477
1478
Set a module label for a profile.
1478
1479
A module label is a label set by a module, and not
1479
1480
a groundtruth label
1480
1481
"""
1481
- data = self .get_profile_modules_labels (profileid )
1482
+ data = self .get_modules_labels_of_a_profile (profileid )
1482
1483
data [module ] = label
1483
1484
data = json .dumps (data )
1484
1485
self .r .hset (profileid , "modules_labels" , data )
1485
1486
1486
1487
def check_tw_to_close (self , close_all = False ):
1487
1488
"""
1488
- Check if we should close some TW
1489
- Search in the modifed tw list and compare when they
1489
+ Check if we should close a TW
1490
+ Search in the modified tw list and compare when they
1490
1491
were modified with the slips internal time
1491
1492
"""
1492
1493
1493
1494
sit = self .get_slips_internal_time ()
1494
1495
1495
- # for each modified profile
1496
+ # sit is the ts of the last tw modification detected by slips
1497
+ # so this line means if 1h(width) passed since the last
1498
+ # modification detected, then it's time to close the tw
1496
1499
modification_time = float (sit ) - self .width
1497
1500
if close_all :
1498
1501
# close all tws no matter when they were last modified
1499
1502
modification_time = float ("inf" )
1500
1503
1504
+ # these are the tws that havent been modified in the last 1h
1501
1505
profiles_tws_to_close = self .r .zrangebyscore (
1502
1506
self .constants .MODIFIED_TIMEWINDOWS ,
1503
1507
0 ,
@@ -1675,15 +1679,7 @@ def add_tuple(
1675
1679
)
1676
1680
self .print (traceback .format_exc (), 0 , 1 )
1677
1681
1678
- def get_tws_to_search (self , go_back ):
1679
- tws_to_search = float ("inf" )
1680
-
1681
- if go_back :
1682
- hrs_to_search = float (go_back )
1683
- tws_to_search = self .get_equivalent_tws (hrs_to_search )
1684
- return tws_to_search
1685
-
1686
- def get_profile_modules_labels (self , profileid ):
1682
+ def get_modules_labels_of_a_profile (self , profileid ):
1687
1683
"""
1688
1684
Get labels set by modules in the profile.
1689
1685
"""
@@ -1710,7 +1706,7 @@ def get_timeline_last_lines(
1710
1706
key = str (
1711
1707
profileid + self .separator + twid + self .separator + "timeline"
1712
1708
)
1713
- # The the amount of lines in this list
1709
+ # The amount of lines in this list
1714
1710
last_index = self .r .zcard (key )
1715
1711
# Get the data in the list from the index asked (first_index) until the last
1716
1712
data = self .r .zrange (key , first_index , last_index - 1 )
0 commit comments