コード例 #1
0
    def receive_message(self, msg):
        self.messages.append(msg)
        # creating ack-message to confirm the receipt of the message
        ack_msg = Messages.AckMessage(msg)

        # check if System is still running
        if System.stopp == 0:
            # forwarding ack-message to batch-mix
            System.batch_mix.receive_message(ack_msg)
コード例 #2
0
    def send_ack(self, message, dst_mac):
        ARQ_HANDLER_LOG.info("Sending ACK back on the message %s",
                             str(message))

        hash_str = hashlib.md5(str(message.id) +
                               self.raw_transport.node_mac).hexdigest()

        hash_int = int(hash_str, 16) & max_int32

        ack_message = Messages.AckMessage()
        ack_message.msg_hash = hash_int

        self.raw_transport.send_raw_frame(dst_mac, ack_message, "")
コード例 #3
0
ファイル: ArqHandler.py プロジェクト: zhangmwg/adhoc_routing
 def send_ack(self, message, dst_mac):
     ARQ_HANDLER_LOG.info("Sending ACK back on the message %s",
                          str(message))
     # Generate hash from the given message id
     hash_str = hashlib.md5(str(message.id) +
                            self.raw_transport.node_mac).hexdigest()
     # Convert hash_str from hex to 32-bit integer
     hash_int = int(hash_str, 16) & max_int32
     # Create ACK message object
     ack_message = Messages.AckMessage()
     ack_message.msg_hash = hash_int
     # Send the message
     self.raw_transport.send_raw_frame(dst_mac, ack_message, "")