The standard (the only way I know) to derive the density of electromagnetic mode (per volume and per unit frequency) for a black body consists in modelling it by a cavity with perfectly reflecting walls.
It implies stationnary electromagnetic waves inside. Then, we say that this electromagnetic field is at equilibrium.
After some calculations, we can show that this energy density is:
$$u(\nu)=\frac{8 \pi h \nu^3}{c^3}\frac{1}{e^{\beta h \nu}-1}$$
Using it we can derive the Stefan Boltzmann law that tells us the power radiated by a black body at temperature $T$.
My main question is:
We modelled the black body by saying it is a cavity with perfectly reflecting walls. We computed some properties of this electromagnetic field at equilibrium. This field is by definition inside the cavity. How can those calculations relate of what is going outside the black body (the power radiated for example).
My second question is:
If I take the black body definition from wikipedia page:
A black body or blackbody is an idealized physical body that absorbs all incident electromagnetic radiation, regardless of frequency or angle of incidence (It does not only absorb radiation, but can also emit radiation)
What is the link between this and the cavity model ? I could imagine that the outside of the cavity is made of perfect mirrors. Then it would mean I didn't model a blackbody.
Why is the cavity model ok for black body ?