Using the analogy between radiation (photon gas) and gas molecules, the photons move in a cavity at random in all directions, rebounding elastically from the walls of the cavity. The pressure exerted by an ideal photon gas is
p = (1/3)ρ < ν2 >
where ρ is the mass density. In the case of photon gas, the speed of all photons is identical being equal to c. Furthermore, from Einstein’* relation
u = ρc2
where u is the energy density. Replacing < ν2 > by c2
prad = (1/3)ρc2 = u/3