UDPFile_sender.py
def MESSAGE_file_data(self, body, transfer_window_idx):
        ''' This function returns wrapped message i.e. header+body 
            for file transfer where body is the file data '''
        
        # Get file size
        self.file_byte_size = os.path.getsize(self.path_to_file)
        
        ## Write header
        # PACKET NUMBER IN HEADER
        header = self.get_empty_header(header_byte_size=self.header_size)
        header[0] = ord(str(MESSAGE_TYPES['file_data_sent']))
        # Save information about transfer window idx in header
        ASCII_number = str(transfer_window_idx)
        # Check if FILE_REQUEST_SUCCESSFUL_BODY_SIZE is enough
        if not len(ASCII_number) <= FILE_DATA_HEADER_TRANSFER_WINDOW_MAX_LEN: 
            print("ERROR: ERROR in MESSAGE_file_data(), packet number too big for header")
            return False
        for num_idx, num in enumerate(ASCII_number):
            # print(f"bbbbbb: {body.shape}")
            header[FILE_DATA_HEADER_TRANSFER_WINDOW_START_IDX+num_idx] = ord(num)
        # BODY SIZE INFO IN HEADER
        # Save information about body size in the header
        ASCII_number = str(len(body))
        # Check if FILE_REQUEST_SUCCESSFUL_BODY_SIZE is enough
        if not len(ASCII_number) <= FILE_DATA_HEADER_MAX_BODY_LEN: 
            print("ERROR: ERROR in MESSAGE_file_data(), body too big for header")
            return False
        for num_idx, num in enumerate(ASCII_number):
            # print(f"bbbbbb: {body.shape}")
            header[FILE_DATA_HEADER_BODY_LEN_START_IDX+num_idx] = ord(num)

        print(f"message file data header: {header}")

        body = [ body[i] for i in range (0, len(body))]
        # body = [body[i:i+1] for i in range(0, len(body), 1)]
        print(f"FFFFFFFFFFFFF: {len(body)}")
        

        
        ## Write in crc at the end of the body
        # Create additional crc empty body
        crc_sufx = self.get_empty_body(body_byte_size=BODY_END_CRC_LENGTH)
        message_without_crc = np.concatenate((header, body), axis=None)
        message_without_crc = np.concatenate((message_without_crc, crc_sufx), axis=None)
        message_with_crc = append_crc_to_message(message_without_crc)
        return message_with_crc
 This function returns wrapped message i.e. header+body 
            for file transfer where body is the file data 
This function returns wrapped message i.e. header+body
for file transfer where body is the file data
This function returns wrapped message i . e . header + body for file transfer where body is the file data
def MESSAGE_file_data(self, body, transfer_window_idx):
        self.file_byte_size = os.path.getsize(self.path_to_file)
        header = self.get_empty_header(header_byte_size=self.header_size)
        header[0] = ord(str(MESSAGE_TYPES['file_data_sent']))
        ASCII_number = str(transfer_window_idx)
        if not len(ASCII_number) <= FILE_DATA_HEADER_TRANSFER_WINDOW_MAX_LEN: 
            print("ERROR: ERROR in MESSAGE_file_data(), packet number too big for header")
            return False
        for num_idx, num in enumerate(ASCII_number):
            header[FILE_DATA_HEADER_TRANSFER_WINDOW_START_IDX+num_idx] = ord(num)
        ASCII_number = str(len(body))
        if not len(ASCII_number) <= FILE_DATA_HEADER_MAX_BODY_LEN: 
            print("ERROR: ERROR in MESSAGE_file_data(), body too big for header")
            return False
        for num_idx, num in enumerate(ASCII_number):
            header[FILE_DATA_HEADER_BODY_LEN_START_IDX+num_idx] = ord(num)
        print(f"message file data header: {header}")
        body = [ body[i] for i in range (0, len(body))]
        print(f"FFFFFFFFFFFFF: {len(body)}")
        crc_sufx = self.get_empty_body(body_byte_size=BODY_END_CRC_LENGTH)
        message_without_crc = np.concatenate((header, body), axis=None)
        message_without_crc = np.concatenate((message_without_crc, crc_sufx), axis=None)
        message_with_crc = append_crc_to_message(message_without_crc)
        return message_with_crc
def MESSAGE_file_data ( self , body , transfer_window_idx ) : self . file_byte_size = os . path . getsize ( self . path_to_file ) header = self . get_empty_header ( header_byte_size = self . header_size ) header [ 0 ] = ord ( str ( MESSAGE_TYPES [ 'file_data_sent' ] ) ) ASCII_number = str ( transfer_window_idx ) if not len ( ASCII_number ) <= FILE_DATA_HEADER_TRANSFER_WINDOW_MAX_LEN : print ( "ERROR: ERROR in MESSAGE_file_data(), packet number too big for header" ) return False for num_idx , num in enumerate ( ASCII_number ) : header [ FILE_DATA_HEADER_TRANSFER_WINDOW_START_IDX + num_idx ] = ord ( num ) ASCII_number = str ( len ( body ) ) if not len ( ASCII_number ) <= FILE_DATA_HEADER_MAX_BODY_LEN : print ( "ERROR: ERROR in MESSAGE_file_data(), body too big for header" ) return False for num_idx , num in enumerate ( ASCII_number ) : header [ FILE_DATA_HEADER_BODY_LEN_START_IDX + num_idx ] = ord ( num ) print ( f"message file data header: {header}" ) body = [ body [ i ] for i in range ( 0 , len ( body ) ) ] print ( f"FFFFFFFFFFFFF: {len(body)}" ) crc_sufx = self . get_empty_body ( body_byte_size = BODY_END_CRC_LENGTH ) message_without_crc = np . concatenate ( ( header , body ) , axis = None ) message_without_crc = np . concatenate ( ( message_without_crc , crc_sufx ) , axis = None ) message_with_crc = append_crc_to_message ( message_without_crc ) return message_with_crc
This function returns wrapped message i.e.
This function returns wrapped message i . e .
''' This function returns wrapped message i.e. header+body 
            for file transfer where body is the file data ''' # Get file size
 ## Write header
 # PACKET NUMBER IN HEADER
 # Save information about transfer window idx in header
 # Check if FILE_REQUEST_SUCCESSFUL_BODY_SIZE is enough
 # print(f"bbbbbb: {body.shape}")
 # BODY SIZE INFO IN HEADER
 # Save information about body size in the header
 # Check if FILE_REQUEST_SUCCESSFUL_BODY_SIZE is enough
 # print(f"bbbbbb: {body.shape}")
 # body = [body[i:i+1] for i in range(0, len(body), 1)]
 ## Write in crc at the end of the body
 # Create additional crc empty body

self
body
transfer_window_idx