def validate_mbap_fields(mbap, slave_id, pdu):
transaction_id = struct.unpack('<STR_LIT>', mbap[:<NUM_LIT:2>])[<NUM_LIT:0>]<EOL>protocol_id = struct.unpack('<STR_LIT>', mbap[<NUM_LIT:2>:<NUM_LIT:4>])[<NUM_LIT:0>]<EOL>length = struct.unpack('<STR_LIT>', mbap[<NUM_LIT:4>:<NUM_LIT:6>])[<NUM_LIT:0>]<EOL>unit_id = struct.unpack('<STR_LIT>', mbap[<NUM_LIT:6>:])[<NUM_LIT:0>]<EOL>assert len(mbap) == <NUM_LIT:7><EOL>assert <NUM_LIT:0> <= transaction_id <= <NUM_LIT><EOL>assert protocol_id == <NUM_LIT:0><EOL>assert length == len(pdu) + <NUM_LIT:1><EOL>assert unit_id == slave_id<EOL>
Check if fields in MBAP header contain expected values.