A non-transitory computer-readable storage medium that stores a program for causing a computer, provided in a terminal apparatus capable of executing a two-step random access procedure or a four-step random access procedure to establish a connection with a base station apparatus, comprising:
- transmitting a first message of the two-step random access procedure including a preamble and predetermined information for connection establishment and
- transmitting in a case where a number of unsuccessful attempts to receive the first message by the base station apparatus exceeds a predetermined number, a second message to be transmitted from the terminal apparatus to the base station apparatus in the four-step random access procedure,
- wherein communication between the base station apparatus and the terminal apparatus is performed using at least one of a plurality of bandwidth parts included in a usable frequency band,
- the predetermined number is set for each one of the plurality of bandwidth parts, and
- in a case where the number exceeds the predetermined number set for one bandwidth part used to transmit the first message from among the plurality of bandwidth parts, the terminal apparatus transmits the second message.