UDPFile_receiver.py
def MESSAGE_acknowledge(self, valid, transfer_window_idx):
        ''' This function returns byte array of full message
        to be sent as acknowledge to data transfer '''
        
        ## Write header
        header = self.get_empty_header(header_byte_size=self.header_size)
        header[0] = ord(str(MESSAGE_TYPES['file_data_acknowledge']))
        header[1] = ord('1') if valid else ord('2')
        # Write ascii number of requiered transfer_window_idx to 2-8th byte idx
        # Convert file_byte_size to string and write the values to body
        ASCII_number = str(transfer_window_idx)
        # Check if FILE_REQUEST_SUCCESSFUL_BODY_SIZE is enough
        if not len(ASCII_number) <= FILE_DATA_TRANSFER_ACKNOWLEDGE_WINDOW_MAX_NUM_SIZE: 
            print(f"ERROR: ERROR in MESSAGE_acknowledge(), window of size {len(ASCII_number)} too large for header space {FILE_DATA_TRANSFER_ACKNOWLEDGE_WINDOW_MAX_NUM_SIZE}")
            return False
        for num_idx, num in enumerate(ASCII_number):
            print( ord(num))
            header[num_idx+FILE_DATA_TRANSFER_ACKNOWLEDGE_WINDOW_HEADER_START_IDX] = ord(num)
        print(f"header ACK: {header}")

        ## Write body
        body = self.get_empty_body(body_byte_size=FILE_DATA_TRANSFER_ACKNOWLEDGE)
        # Iterate path to file and save the ASCII chars to array
        
        # Write in crc at the end of the body
        message_without_crc = np.concatenate((header, body), axis=None)
        message_with_crc = append_crc_to_message(message_without_crc)
        
        return message_with_crc
 This function returns byte array of full message
        to be sent as acknowledge to data transfer 
This function returns byte array of full message
to be sent as acknowledge to data transfer
This function returns byte array of full message to be sent as acknowledge to data transfer
def MESSAGE_acknowledge(self, valid, transfer_window_idx):
        header = self.get_empty_header(header_byte_size=self.header_size)
        header[0] = ord(str(MESSAGE_TYPES['file_data_acknowledge']))
        header[1] = ord('1') if valid else ord('2')
        ASCII_number = str(transfer_window_idx)
        if not len(ASCII_number) <= FILE_DATA_TRANSFER_ACKNOWLEDGE_WINDOW_MAX_NUM_SIZE: 
            print(f"ERROR: ERROR in MESSAGE_acknowledge(), window of size {len(ASCII_number)} too large for header space {FILE_DATA_TRANSFER_ACKNOWLEDGE_WINDOW_MAX_NUM_SIZE}")
            return False
        for num_idx, num in enumerate(ASCII_number):
            print( ord(num))
            header[num_idx+FILE_DATA_TRANSFER_ACKNOWLEDGE_WINDOW_HEADER_START_IDX] = ord(num)
        print(f"header ACK: {header}")
        body = self.get_empty_body(body_byte_size=FILE_DATA_TRANSFER_ACKNOWLEDGE)
        message_without_crc = np.concatenate((header, body), axis=None)
        message_with_crc = append_crc_to_message(message_without_crc)
        return message_with_crc
def MESSAGE_acknowledge ( self , valid , transfer_window_idx ) : header = self . get_empty_header ( header_byte_size = self . header_size ) header [ 0 ] = ord ( str ( MESSAGE_TYPES [ 'file_data_acknowledge' ] ) ) header [ 1 ] = ord ( '1' ) if valid else ord ( '2' ) ASCII_number = str ( transfer_window_idx ) if not len ( ASCII_number ) <= FILE_DATA_TRANSFER_ACKNOWLEDGE_WINDOW_MAX_NUM_SIZE : print ( f"ERROR: ERROR in MESSAGE_acknowledge(), window of size {len(ASCII_number)} too large for header space {FILE_DATA_TRANSFER_ACKNOWLEDGE_WINDOW_MAX_NUM_SIZE}" ) return False for num_idx , num in enumerate ( ASCII_number ) : print ( ord ( num ) ) header [ num_idx + FILE_DATA_TRANSFER_ACKNOWLEDGE_WINDOW_HEADER_START_IDX ] = ord ( num ) print ( f"header ACK: {header}" ) body = self . get_empty_body ( body_byte_size = FILE_DATA_TRANSFER_ACKNOWLEDGE ) message_without_crc = np . concatenate ( ( header , body ) , axis = None ) message_with_crc = append_crc_to_message ( message_without_crc ) return message_with_crc
This function returns byte array of full message
to be sent as acknowledge to data transfer
This function returns byte array of full message to be sent as acknowledge to data transfer
''' This function returns byte array of full message
        to be sent as acknowledge to data transfer ''' ## Write header
 # Write ascii number of requiered transfer_window_idx to 2-8th byte idx
 # Convert file_byte_size to string and write the values to body
 # Check if FILE_REQUEST_SUCCESSFUL_BODY_SIZE is enough
 ## Write body
 # Iterate path to file and save the ASCII chars to array
 # Write in crc at the end of the body

self
valid
transfer_window_idx