def __init__(self): """ Setup and build the bunny model and starts the read_packet_thread() """ self.inandout = SendRec() self.cryptor = AEScrypt() self.model = TrafficModel() # each item should be an full bunny message that can be passed to the .decrypt() method # TODO: put a upper bound of number of messages or a cleanup thread to clear out old messages # if not consumed. self.msg_queue = Queue.LifoQueue() # The out queue is a FiFo Queue because it maintaines the ordering of the bunny data # format: [data, Bool (relay or not)] self.out_queue = Queue.Queue() # The Deque is used because it is a thread safe iterable that can be filled with 'seen' # messages between the send and recv threads. self.msg_deque = [] # init the threads and name them self.workers = [BunnyReadThread(self.msg_queue, self.out_queue, self.inandout, self.model, self.cryptor), \ BroadCaster(self.out_queue, self.inandout, self.model)] self.workers[0].name = "BunnyReadThread" self.workers[1].name = "BroadCasterThread" # spin up the threads for worker in self.workers: worker.daemon = True worker.start()
def __init__(self): """ Starts up the model, collects data and inserts it into its respective lists """ # clear any old data self.mac_addresses = [] self.type_ranges = [] self.data = [] # spin up and build the model self.interface = SendRec() self.collectData() self.stripRadioTap() self.extractModel() self.insertTemplates()