Complete the code to set the block size for block-wise transfer.
block_size = [1] # Set block size in bytes
The standard block size for block-wise transfer is 1024 bytes to balance efficiency and resource use.
Complete the code to calculate the number of blocks needed for a payload.
num_blocks = (payload_size + [1] - 1) // [1]
We use block_size to divide the payload size and calculate how many blocks are needed.
Fix the error in the block number calculation for the last block.
last_block_num = total_blocks [1] 1
The last block number is total_blocks minus 1 because block numbering starts at zero.
Fill both blanks to correctly create a block option header with block number and size.
block_option = ([1] << 4) | [2] # Compose block option value
The block number is shifted left by 4 bits and combined with the block size code using bitwise OR.
Fill all three blanks to extract block number and size code from block option.
block_num = (block_option >> [1]) & [2] block_size_code = block_option & [3]
Shift right by 4 bits to get block number, mask with 0x0F to get size code from lower 4 bits.
