We present in this chapter a review of some recent research work about a new approach to the numerical simulation of time harmonic wave propagation in infinite periodic media including a local perturbation. The main difficulty lies in the reduction of the effective numerical computations to a bounded region enclosing the perturbation. Our objective is to extend the approach by Dirichlet-to-Neumann (DtN) operators, well known in the case of homogeneous media (as non local transparent boundary conditions). The new difficulty is that this DtN operator can no longer be determined explicitly and has to be computed numerically. We consider successively the case of a periodic waveguide and the more complicated case of the whole space. We show that the DtN operator can be characterized through the solution of local PDE cell problems, the use of the Floquet-Bloch transform and the solution of operator-valued quadratic or linear equations. In our text, we shall outline the main ideas without going into the rigorous mathematical details. The non standard aspects of this procedure will be emphasized and numerical results demonstrating the efficiency of the method will be presented.