Ejemplo n.º 1
0
 def polling_round_end(self):
     # This function is called when polling round ends
     self.current_slot = None
     RAW_slots = []
     for each_RAW in self.polling_round.RAWs:
         for each_slot in each_RAW.slot_list:
             RAW_slots.append(each_slot)
     print([x.status for x in RAW_slots])
     next_STAs_to_check, next_STAs_to_collect, next_blocks_to_check = self.polling_round.polling_round_analyse(
     )
     if not (next_STAs_to_collect or next_STAs_to_check
             or next_blocks_to_check):
         # sys.stdout=open('test.txt','a')
         print("Polling Phase finished ")
         print(self.status)
         print(self.channel_state)
         self.mode = "Open access"
         self.detector.reset()
         self.detector.turn_on()
         for each_block in self.block_list.blocks:
             each_block.STA_received = []
         self.block_list.STA_received = []
         return
     self.polling_round = restricted_access_window.PollingRound(
         self.timer, self.max_data_size, self, self.STA_list)
     self.polling_round.set_polling_target(next_STAs_to_check,
                                           next_STAs_to_collect,
                                           next_blocks_to_check)
     self.queue = self.polling_round.generate_beacon(
         self.timer.current_time,  #+self.timer.SIFS,
         self.channel_state,
         self.max_data_size)
     statistics_collection.collector.register_beacons(
         self.timer.current_time, self.queue[-1])
     self.transmit_packet(self.queue[0])
     for each_RAW in self.polling_round.RAWs:
         for each_slot in each_RAW.slot_list:  # register when the RAW slot start event
             new_event = event.Event("Raw slot start", each_slot.start_time)
             new_event.register_device(self)
             self.timer.register_event(new_event)
     new_event = event.Event("Polling round end",
                             self.polling_round.end_time
                             )  # register when the polling round will end
     new_event.register_device(self)
     self.timer.register_event(new_event)
     # time.sleep(5)
     print(
         "\n##############################next polling round##########################################"
     )
Ejemplo n.º 2
0
    def __transit_to_polling_phase__(self):
        # This function is called when channel is cleard by consecutive beacons
        # and need to transit into polling phase to resolve the alarm reports
        print(
            "\n #####################Transit into the pollling phase######################"
        )
        # time.sleep(2)
        self.current_slot = None

        STAs_to_poll = []
        # temp,blocks_to_check=self.block_list.get_blocks_at_certain_level(0),[]
        for each_STA in self.STA_list:
            if not each_STA in self.block_list.STA_received:  # allocate a trigger slot to this STA
                STAs_to_poll.append(each_STA)
        self.polling_round = restricted_access_window.PollingRound(
            self.timer, self.max_data_size, self, self.STA_list)
        self.polling_round.set_polling_target([], STAs_to_poll, [])
        assert self.channel_state == "Idle"
        self.queue = self.polling_round.generate_beacon(
            self.timer.current_time + self.timer.SIFS, self.channel_state,
            self.max_data_size)
        statistics_collection.collector.register_beacons(
            self.timer.current_time + self.timer.SIFS, self.queue[-1])
        ######### send the beacon frame after an SIFS ############
        new_event = event.Event("IFS expire",
                                self.timer.current_time + self.timer.SIFS)
        new_event.register_device(
            self)  # register to send the beacon after an SIFS
        self.timer.register_event(new_event)
        self.IFS_expire_event = new_event
        self.packet_to_send = self.queue[0]
        ######### record when the RAW slots will start ################
        for each_RAW in self.polling_round.RAWs:
            for each_slot in each_RAW.slot_list:  # register when the RAW slot start event
                new_event = event.Event("Raw slot start", each_slot.start_time)
                new_event.register_device(self)
                self.timer.register_event(new_event)
        ######## record when the polling round will end ###############
        new_event = event.Event("Polling round end",
                                self.polling_round.end_time +
                                1)  # register when the polling round will end
        new_event.register_device(self)
        self.timer.register_event(new_event)
        self.mode = "Alarm resolution--Polling phase"