In this work, we apply iterative learning method to address the traffic density control problem in a macroscopic level freeway environment with ramp metering. The second-order traffic flow model is firstly formulated. Then traffic density is selected as the control variable in place of traffic occupancy. Based on the traffic flow model and in conjunction with nonlinear feedback theory, an iterative learning based traffic density controller is designed. Finally, the iterative learning based feedback controller is simulated in Matlab software. Simulation results show that this method has good dynamic and steady-state performance, and can achieve an almost perfect tracking performance.