예제 #1
0
 def ack_timeout(self, *args):
     print("ACK timeout")
     assert len(args) == 2
     assert isinstance(args[0], schcmsg.frag_sender_tx)
     assert isinstance(args[1], int)
     schc_frag = args[0]
     win = args[1]
     self.ack_requests_counter += 1
     if self.ack_requests_counter > max_ack_requests:
         # sending sender abort.
         schc_frag = schcmsg.frag_sender_tx_abort(self.rule, self.dtag, win)
         args = (schc_frag.packet.get_content(),
                 self.protocol.layer2.mac_id, None, None, False)
         print("Sent Sender-Abort.", schc_frag.__dict__)
         self.protocol.scheduler.add_event(0,
                                           self.protocol.layer2.send_packet,
                                           args)
         return
     # set ack waiting timer
     self.event_id_ack_wait_timer = self.protocol.scheduler.add_event(
         self.ack_wait_timer, self.ack_timeout, args)
     # retransmit MIC.
     args = (schc_frag.packet.get_content(), self.protocol.layer2.mac_id,
             None, self.event_sent_frag, True)
     print("Retransmitted frag:", schc_frag.__dict__)
     self.protocol.scheduler.add_event(0, self.protocol.layer2.send_packet,
                                       args)
예제 #2
0
    def ack_timeout(self, *args):
        self.cancel_ack_wait_timer()
        print("----------------------- ACK timeout -----------------------  ")
        self.state = self.ACK_TIMEOUT
        assert len(args) == 2
        assert isinstance(args[0], schcmsg.frag_sender_tx)
        assert isinstance(args[1], int)
        schc_frag = args[0]
        win = args[1]
        self.ack_requests_counter += 1
        print("ack_requests_counter -> {}".format(self.ack_requests_counter))
        if self.ack_requests_counter > max_ack_requests:
            # sending sender abort.
            schc_frag = schcmsg.frag_sender_tx_abort(self.rule, self.dtag, win)
            """ Changement à corriger
            args = (schc_frag.packet.get_content(), self.context["devL2Addr"])
            """
            args = (schc_frag.packet.get_content(), "*")
            print("MESSSAGE TYPE ----> Sent Sender-Abort.", schc_frag.__dict__)
            if enable_statsct:
                Statsct.set_msg_type("SCHC_SENDER_ABORT")
                Statsct.set_header_size(
                    schcmsg.get_sender_header_size(self.rule))

            self.protocol.scheduler.add_event(0,
                                              self.protocol.layer2.send_packet,
                                              args)
            return
        # set ack waiting timer
        self.event_id_ack_wait_timer = self.protocol.scheduler.add_event(
            self.ack_wait_timer, self.ack_timeout, args)
        print("*******event id {}".format(self.event_id_ack_wait_timer))
        schc_frag = schcmsg.frag_sender_ack_req(self.rule, self.dtag, win)
        if enable_statsct:
            Statsct.set_msg_type("SCHC_ACK_REQ")
        # # retransmit MIC.
        """Changement à corriger 
        args = (schc_frag.packet.get_content(), self.context["devL2Addr"],
                self.event_sent_frag)
        """
        args = (schc_frag.packet.get_content(), '*', self.event_sent_frag)

        print("MESSSAGE TYPE ----> SCHC ACK REQ frag:", schc_frag.__dict__)
        self.protocol.scheduler.add_event(0, self.protocol.layer2.send_packet,
                                          args)
        """ waits for all the acks before sending the ack request