code: def prepare_packed_data(radius_packet, packed_req_authenticator):
      
  
      packed_hdr = struct.pack("!B", radius_packet.code)
      packed_hdr += struct.pack("!B", radius_packet.id)
      packed_hdr += struct.pack("!H", radius_packet.len)
  
      packed_attrs = b''
      for attr in radius_packet.attributes:
          packed_attrs += raw(attr)
  
      return packed_hdr + packed_req_authenticator + packed_attrs
docs: Pack RADIUS data prior computing the authentication MAC