  In this paper, we investigate the problem of pilot optimization and channel
estimation of two-way relaying network (TWRN) aided by an intelligent
reflecting surface (IRS) with finite discrete phase shifters. In a TWRN, there
exists a challenging problem that the two cascading channels from
source-to-IRS-to-Relay and destination-to-IRS-to-relay interfere with each
other. Via designing the initial phase shifts of IRS and pilot pattern, the two
cascading channels are separated by using simple arithmetic operations like
addition and subtraction. Then, the least-squares estimator is adopted to
estimate the two cascading channels and two direct channels from source to
relay and destination to relay. The corresponding mean square errors (MSE) of
channel estimators are derived. By minimizing MSE, the optimal phase shift
matrix of IRS is proved. Then, two special matrices Hadamard and discrete
Fourier transform (DFT) matrix is shown to be two optimal training matrices for
IRS. Furthermore, the IRS with discrete finite phase shifters is taken into
account. Using theoretical derivation and numerical simulations, we find that
3-4 bits phase shifters are sufficient for IRS to achieve a negligible MSE
performance loss. More importantly, the Hadamard matrix requires only one-bit
phase shifters to achieve the optimal MSE performance while the DFT matrix
requires at least three or four bits to achieve the same performance. Thus, the
Hadamard matrix is a perfect choice for channel estimation using low-resolution
phase-shifting IRS.
