Experimental and Monte Carlo simulation studies of the magnetocaloric effect in R2Fe17 (R = Nd and Gd) compounds