A communication method, comprising: sending (S101), by a network device, a first message to terminal device, wherein the first message is used to indicate a set of candidate time domain resource units of a physical random access channel; sending (S102), by the network device, a second message to the terminal device, wherein the second message carries first indication information, and the first indication information is used to indicate a time domain resource unit format of a first candidate time domain resource unit in the set of candidate time domain resource units; and receiving (S104), by the network device from the terminal device based on the time domain resource unit format, a random access preamble in the first candidate time domain resource unit, wherein the candidate time domain resource unit comprises an uplink time domain resource region, the time domain resource unit format is one of a plurality of time domain resource unit formats, and uplink time domain resource regions comprised in the plurality of time domain resource unit formats have different sizes; wherein the receiving, by the network device from the terminal device based on the time domain resource unit format, a random access preamble in the first candidate time domain resource unit comprises: receiving, by the network device, the random access preamble in the first candidate time domain resource unit based on a first mapping mode corresponding to the time domain resource unit format of the first candidate time domain resource unit, wherein the first mapping mode is one of a plurality of first mapping modes, and the first mapping mode comprises a mode of mapping between the random access preamble and a time domain position in the uplink time domain resource region. sending (S101), by a network device, a first message to terminal device, wherein the first message is used to indicate a set of candidate time domain resource units of a physical random access channel; sending (S102), by the network device, a second message to the terminal device, wherein the second message carries first indication information, and the first indication information is used to indicate a time domain resource unit format of a first candidate time domain resource unit in the set of candidate time domain resource units; and receiving (S104), by the network device from the terminal device based on the time domain resource unit format, a random access preamble in the first candidate time domain resource unit, wherein the candidate time domain resource unit comprises an uplink time domain resource region, the time domain resource unit format is one of a plurality of time domain resource unit formats, and uplink time domain resource regions comprised in the plurality of time domain resource unit formats have different sizes; wherein the receiving, by the network device from the terminal device based on the time domain resource unit format, a random access preamble in the first candidate time domain resource unit comprises: receiving, by the network device, the random access preamble in the first candidate time domain resource unit based on a first mapping mode corresponding to the time domain resource unit format of the first candidate time domain resource unit, wherein the first mapping mode is one of a plurality of first mapping modes, and the first mapping mode comprises a mode of mapping between the random access preamble and a time domain position in the uplink time domain resource region. <EOS>