A network coding method in a communication system in which data is transmitted between a first terminal device (12, 23) and a second terminal device (23, 24) through an electromagnetic hypersurface array antenna in which antenna units made of different metamaterials are combined, data sending, network coding, and receiving are completed in one transmission/reception slot of a transmission resource, and network coding is performed as a time domain superposition, comprising: determining, by a first terminal device (12, 23), first indication information, wherein the first indication information indicates whether to preprocess a phase of first to-be-coded data to be sent by the first terminal device (12, 23), by shifting the phase of an analog signal of the first to-be-coded data by a specific angle belonging to [ π - α, π + β], where 0 ≤ α, β ≤ π / 4; and transmitting, by the first terminal device (12, 23), data to the second terminal device (13, 24) in the transmission/reception slot through the electromagnetic hypersurface array antenna, wherein the transmitting comprises: sending, by the first terminal device (12, 23), third to-be-coded data to the electromagnetic hypersurface array antenna in the transmission/reception slot, and receiving first network coded data from the electromagnetic hypersurface array antenna in the transmission/reception slot, wherein the third to-be-coded data is obtained based on the first indication information and the first to-be-coded data; and obtaining, by the first terminal device (12, 23), second to-be-coded data from the second terminal device (13, 24) based on the third to-be-coded data and the first network coded data. determining, by a first terminal device (12, 23), first indication information, wherein the first indication information indicates whether to preprocess a phase of first to-be-coded data to be sent by the first terminal device (12, 23), by shifting the phase of an analog signal of the first to-be-coded data by a specific angle belonging to [ π - α, π + β], where 0 ≤ α, β ≤ π / 4; and transmitting, by the first terminal device (12, 23), data to the second terminal device (13, 24) in the transmission/reception slot through the electromagnetic hypersurface array antenna, wherein the transmitting comprises: sending, by the first terminal device (12, 23), third to-be-coded data to the electromagnetic hypersurface array antenna in the transmission/reception slot, and receiving first network coded data from the electromagnetic hypersurface array antenna in the transmission/reception slot, wherein the third to-be-coded data is obtained based on the first indication information and the first to-be-coded data; and obtaining, by the first terminal device (12, 23), second to-be-coded data from the second terminal device (13, 24) based on the third to-be-coded data and the first network coded data. sending, by the first terminal device (12, 23), third to-be-coded data to the electromagnetic hypersurface array antenna in the transmission/reception slot, and receiving first network coded data from the electromagnetic hypersurface array antenna in the transmission/reception slot, wherein the third to-be-coded data is obtained based on the first indication information and the first to-be-coded data; and obtaining, by the first terminal device (12, 23), second to-be-coded data from the second terminal device (13, 24) based on the third to-be-coded data and the first network coded data.