(self, pkt)
return self._check_ready(pkt.seq_num)
Append incoming BlocksatPkt

        Append the incoming Blocksat packet to the map of packets (fragments)
        pertaining to the same API message. Once the last fragment of a
        sequence comes, let the caller know that the API message is ready to be
        decoded.

        Args:
            pkt : Incoming BlocksatPkt

        Returns:
            (bool) True if the underlying ApiMsg is ready to be extracted from
            the corresponding collection of packets.
Append incoming BlocksatPkt
Append incoming BlocksatPkt
def append(self, pkt):
        """Append incoming BlocksatPkt

        Append the incoming Blocksat packet to the map of packets (fragments)
        pertaining to the same API message. Once the last fragment of a
        sequence comes, let the caller know that the API message is ready to be
        decoded.

        Args:
            pkt : Incoming BlocksatPkt

        Returns:
            (bool) True if the underlying ApiMsg is ready to be extracted from
            the corresponding collection of packets.

        """
        assert (isinstance(pkt, BlocksatPkt))

        if (pkt.seq_num not in self.frag_map):
            self.frag_map[pkt.seq_num] = {
                'high_frag': None,
                'last_frag': None,
                'concat': bytearray()
            }
            self.frag_map[pkt.seq_num]['frags'] = {}

        # Do not process a repeated fragment
        if (pkt.frag_num in self.frag_map[pkt.seq_num]['frags']):
            logger.debug("BlocksatPktHandler: fragment {} has already "
                         "been received".format(pkt.frag_num))
            # Check if the repeated fragment actually has the same contents
            pre_existing_pkt = self.frag_map[pkt.seq_num]['frags'][
                pkt.frag_num]
            if (pkt.payload != pre_existing_pkt.payload):
                logger.warning(
                    "Got the same fragment twice but with different contents "
                    "(frag_num: {}, seq_num: {})".format(
                        pkt.frag_num, pkt.seq_num))
            return self._check_ready(pkt.seq_num)

        self.frag_map[pkt.seq_num]['frags'][pkt.frag_num] = pkt

        # Timestamp the last fragment reception of this sequence number. Use
        # this timestamp to clean old fragments that were never decoded.
        self.frag_map[pkt.seq_num]['t_last'] = time.time()

        # Concatenate payload by payload instead of waiting to concatenate
        # everything in the end when the message is ready.
        self._concat_pkt(pkt)

        # Track the highest fragment number received so far. This information
        # is used to identify whether the concatenation cache needs to be
        # recomputed for out-of-order packets (see _concat_pkt()).
        if (self.frag_map[pkt.seq_num]['high_frag'] is None
                or pkt.frag_num > self.frag_map[pkt.seq_num]['high_frag']):
            self.frag_map[pkt.seq_num]['high_frag'] = pkt.frag_num

        # Track the last fragment of the sequence. This information is used to
        # more quickly verify whether the message is ready (see
        # _check_ready()).
        if (not pkt.more_frags):
            self.frag_map[pkt.seq_num]['last_frag'] = pkt.frag_num

        logger.debug("BlocksatPktHandler: Append fragment {}, "
                     "Seq Num {}".format(pkt.frag_num, pkt.seq_num))

        return self._check_ready(pkt.seq_num)
def append ( self , pkt ) : assert ( isinstance ( pkt , BlocksatPkt ) ) if ( pkt . seq_num not in self . frag_map ) : self . frag_map [ pkt . seq_num ] = { 'high_frag' : None , 'last_frag' : None , 'concat' : bytearray ( ) } self . frag_map [ pkt . seq_num ] [ 'frags' ] = { } # Do not process a repeated fragment if ( pkt . frag_num in self . frag_map [ pkt . seq_num ] [ 'frags' ] ) : logger . debug ( "BlocksatPktHandler: fragment {} has already " "been received" . format ( pkt . frag_num ) ) # Check if the repeated fragment actually has the same contents pre_existing_pkt = self . frag_map [ pkt . seq_num ] [ 'frags' ] [ pkt . frag_num ] if ( pkt . payload != pre_existing_pkt . payload ) : logger . warning ( "Got the same fragment twice but with different contents " "(frag_num: {}, seq_num: {})" . format ( pkt . frag_num , pkt . seq_num ) ) return self . _check_ready ( pkt . seq_num ) self . frag_map [ pkt . seq_num ] [ 'frags' ] [ pkt . frag_num ] = pkt # Timestamp the last fragment reception of this sequence number. Use # this timestamp to clean old fragments that were never decoded. self . frag_map [ pkt . seq_num ] [ 't_last' ] = time . time ( ) # Concatenate payload by payload instead of waiting to concatenate # everything in the end when the message is ready. self . _concat_pkt ( pkt ) # Track the highest fragment number received so far. This information # is used to identify whether the concatenation cache needs to be # recomputed for out-of-order packets (see _concat_pkt()). if ( self . frag_map [ pkt . seq_num ] [ 'high_frag' ] is None or pkt . frag_num > self . frag_map [ pkt . seq_num ] [ 'high_frag' ] ) : self . frag_map [ pkt . seq_num ] [ 'high_frag' ] = pkt . frag_num # Track the last fragment of the sequence. This information is used to # more quickly verify whether the message is ready (see # _check_ready()). if ( not pkt . more_frags ) : self . frag_map [ pkt . seq_num ] [ 'last_frag' ] = pkt . frag_num logger . debug ( "BlocksatPktHandler: Append fragment {}, " "Seq Num {}" . format ( pkt . frag_num , pkt . seq_num ) ) return self . _check_ready ( pkt . seq_num )