A signal transmission method performed by a signal transmission device, comprising: generating a single-wavelength optical carrier; splitting the single-wavelength optical carrier into N subcarriers having a same wavelength, wherein a value of N is a positive integer not less than 2; generating a spreading code corresponding to each of the subcarriers with M spreading generators, wherein M is a positive integer less than N, to obtain N spreading codes, wherein a bandwidth of each of the spreading codes is less than or equal to a preset threshold, the preset threshold being set to half of a maximum bandwidth of a spreading code of the signal transmission device; deserializing a to-be-transmitted data signal into N sub-data signals, wherein the N sub-data signals are in a one-to-one correspondence with the N subcarriers; modulating the N subcarriers based on the N sub-data signals and the N spreading codes, to obtain N modulation signals; and combining the N modulation signals into one combined signal, and outputting the combined signal, wherein when a code type of a spreading code corresponding to an n th subcarrier is the same as a code type of a spreading code of an (n+1) th subcarrier, an m th spreading code generator in the M spreading code generators generates a spreading code, and inputs the spreading code to a second splitter; the second splitter splits the spreading code into two spreading codes, wherein one spreading code is used as an n th spreading code, and is input to an n th modulator to which the n th subcarrier is correspondingly input, and the other spreading code is input to a delayer; and the delayer delays, for t bits, the spreading code that is input by the second splitter and that is obtained after the splitting, to obtain an (n+1) th spreading code, and input the (n+1) th spreading code to an (n+1) th modulator to which the (n+1) th subcarrier is correspondingly input, wherein n is a positive integer less than or equal to N-1, and m is a positive integer less than or equal to M-1, wherein a code type is determined based on a bit length used by the signal transmission device. generating a single-wavelength optical carrier; splitting the single-wavelength optical carrier into N subcarriers having a same wavelength, wherein a value of N is a positive integer not less than 2; generating a spreading code corresponding to each of the subcarriers with M spreading generators, wherein M is a positive integer less than N, to obtain N spreading codes, wherein a bandwidth of each of the spreading codes is less than or equal to a preset threshold, the preset threshold being set to half of a maximum bandwidth of a spreading code of the signal transmission device; deserializing a to-be-transmitted data signal into N sub-data signals, wherein the N sub-data signals are in a one-to-one correspondence with the N subcarriers; modulating the N subcarriers based on the N sub-data signals and the N spreading codes, to obtain N modulation signals; and combining the N modulation signals into one combined signal, and outputting the combined signal, wherein when a code type of a spreading code corresponding to an n th subcarrier is the same as a code type of a spreading code of an (n+1) th subcarrier, an m th spreading code generator in the M spreading code generators generates a spreading code, and inputs the spreading code to a second splitter; the second splitter splits the spreading code into two spreading codes, wherein one spreading code is used as an n th spreading code, and is input to an n th modulator to which the n th subcarrier is correspondingly input, and the other spreading code is input to a delayer; and the delayer delays, for t bits, the spreading code that is input by the second splitter and that is obtained after the splitting, to obtain an (n+1) th spreading code, and input the (n+1) th spreading code to an (n+1) th modulator to which the (n+1) th subcarrier is correspondingly input, wherein n is a positive integer less than or equal to N-1, and m is a positive integer less than or equal to M-1, wherein a code type is determined based on a bit length used by the signal transmission device.