Browse Source

Merge branch 'develop' of https://git.tk.informatik.tu-darmstadt.de/leon.boeck/ID2T-toolkit-BotnetTraffic into develop

christof 7 years ago
parent
commit
e8167d323f
3 changed files with 8 additions and 11 deletions
  1. 2 8
      code/Attack/MembersMgmtCommAttack.py
  2. 2 0
      code/CLI.py
  3. 4 3
      code/ID2TLib/CommunicationProcessor.py

+ 2 - 8
code/Attack/MembersMgmtCommAttack.py

@@ -118,7 +118,8 @@ class MembersMgmtCommAttack(BaseAttack.BaseAttack):
         # PARAMETERS: initialize with default values
         # (values are overwritten if user specifies them)
         # print(self.statistics.get_packet_count())
-        self.add_param_value(Param.INJECT_AFTER_PACKET, randint(0, self.statistics.get_packet_count()))
+        self.add_param_value(Param.INJECT_AFTER_PACKET, randint(0, int(self.statistics.get_packet_count()/4)))
+
         # print(self.get_param_value(Param.INJECT_AT_TIMESTAMP))
         self.add_param_value(Param.PACKETS_PER_SECOND, 0)
         self.add_param_value(Param.FILE_XML, self.DEFAULT_XML_PATH)
@@ -367,13 +368,6 @@ class MembersMgmtCommAttack(BaseAttack.BaseAttack):
             new_external_ips = sorted([ipgen.random_ip() for _ in range(remaining)])
             add_ids_to_config(sorted(external_ids), existing_external_ips, new_external_ips, bot_configs, idtype="external", router_mac=router_mac)
 
-        # for msg in messages:
-        #     print(msg)
-        # print(sorted(list(init_ids)+list(both_ids)))
-        # print(sorted(local_ids))
-        # print(sorted(external_ids))
-
-
         #### Set realistic timestamps for messages ####
         #### ... ####
         

+ 2 - 0
code/CLI.py

@@ -2,6 +2,7 @@
 import argparse
 import sys
 import random
+import numpy
 
 from ID2TLib.Controller import Controller
 
@@ -94,6 +95,7 @@ class CLI(object):
         except: pass # otherwise use the strings hash, random.seed does this automatically
         
         random.seed(seed)
+        numpy.random.seed(seed)
 
     def process_attack_listing(self):
         import pkgutil

+ 4 - 3
code/ID2TLib/CommunicationProcessor.py

@@ -13,7 +13,7 @@ class CommunicationProcessor():
     def __init__(self, packets):
         self.packets = packets
 
-    def set_mapping(self, packets, mapped_ids, id_comms):
+    def set_mapping(self, packets: list, mapped_ids: dict, id_comms:dict):
         """
         Set the selected mapping for this communication processor.
 
@@ -301,7 +301,7 @@ class CommunicationProcessor():
                 msg_id += 1
 
         # store the retrieved information in this object for later use
-        self.init_ids, self.respnd_ids, self.both_ids = init_ids, respnd_ids, both_ids
+        self.init_ids, self.respnd_ids, self.both_ids = sorted(init_ids), sorted(respnd_ids), sorted(both_ids)
         self.messages = msgs
 
         # return the retrieved information
@@ -317,7 +317,7 @@ class CommunicationProcessor():
         :param prob_rspnd_local: the probabilty that a responder is local
         """
         init_ids, respnd_ids, both_ids = self.init_ids, self.respnd_ids, self.both_ids
-        id_comms = self.id_comms
+        id_comms = sorted(self.id_comms)
         external_ids = set()
         local_ids = set()
         ids = self.ids
@@ -327,6 +327,7 @@ class CommunicationProcessor():
             Map the given ID as local and handle its communication partners' locality
             """
             # loop over all communication entries
+
             for id_comm in id_comms:
                 ids = id_comm.split("-")
                 other = ids[0] if id_ == ids[1] else ids[1]