Theory of microwave generation by an intense relativistic electron beam in a rippled magnetic field