Diode Theory
When a p-n semiconductor diode is forward biased, the electrons and holes recombine within the p-n junction and emit recombination energy in the form of electromagnetic radiation.
Below is a diagram of a forward biased p-n junction. A voltage is applied so that a current flows through the junction. An applied voltage V causes the potential difference "eV" from the chemical potential "μ" on the p and n sides.

Fig. 1
This image from Britney's Guide to Semi-Conductor Physics
http://britneyspears.ac/lasers.htm
Diode Lasers
The wavelength of electromagnetic radiation emitted from the p-n junction is determined by the difference between the energy levels of the electrons and holes, or by the band gap of the material. The specific spectral range of the spontaneous emission in the laser is determined by the type of semiconductor material used.
Figure 2 below shows a typical diode laser:

Fig. 2
Typical double heterostructure GaAs-GaAlAs laser
(Yariv 480)
The output wavelength of the radiation emitted by this laser, then, is determined by the 0.2μm band gap.
The radiation is amplified through multiple reflections from the polished ends of the semi-conducting medium making it strong enough for induced emission to occur in the p-n junction. Above a certain threshold current (see Fig. 4) (determined by the particular semiconductor diode) the radiation field in the junction is great enough such that the induced emission rate exceeds the spontaneous recombination process.
There are three basic radiative transitions that occur between energy levels E2 and E1, or in the case of semiconductor lasers, between the conduction and valence bands of the material: stimulated absorption, spontaneous emission, and stimulated emission (Sze 707). Fig. 2 below is an illustration of the stimulated emission process which occurs above threshold (when stimulated/induced emission exceeds spontaneous emission in the material).

Fig. 3
This image from Britney's Guide to Semi-Conductor Physics
http://britneyspears.ac/lasers.htm
In stimulated emission, if a photon is strongly coupled with an electron, it can cause it to decay to a lower energy level, releasing a photon of the same energy. The emitted photon has the same direction and phase as the incident photon. The rate of stimulated emission depends on the occupation probabilities of the upper and lower states and also on the photon density at the wavelength incident photon energy (http://britneyspears.ac/physics/radiative/radiative.htm).
The wavelength of the laser diode can be tuned by varying the parameters which determine the energy gap. A change in temperature produced either by external cooling or heating or by a current change generates a change in the wavelength. The tuning of the wavelength, however is not continuous. Mode hops occur because the cavity length does not change at the same rate as the maximum of the gain profile. When the maximum of the gain profile shifts to a new resonator mode, this mode's gain is larger than the currently oscillating mode, and so the laser jumps to this wavelength. For more information on mode hops, see Demtröder's Laser Spectroscopy: Basic Concepts and Instrumentation.
A fixed cavity length implies that different wavelengths can exist as standing waves inside the laser cavity. As a result, different longitudinal modes can be viewed in the output once the current has passed a certain threshold current. "Below threshold the semiconductor emits a broad, continuous spectrum, but as the current density rises above threshold, distinct longitudinal modes oscillate" (Davis 296).

Fig. 4
Power Output (mW) vs. Current (mA) for an InGaAsP/InP laser
(Davis 297)
One or two modes may begin to dominate as the current rises far above threshold.
Finding the Cavity Length
For this experiment, we assume that the index of refraction does not change with wavelength. We assume furthermore that the longitudinal modes of the semiconductor laser are equally spaced (Davis 296).
The calculation to find cavity length, then, is highly simplified. According to first year physics, the equation for the wavelength of standing waves in a cavity of length L is l=2nL/k. Differentiating this with respect to k gives Dl= -2nL/k2 or L= -l2/2nDl.
The Dl between the wavelengths of the different modes can be measured from the spectra of the laser at different currents. For our calculations, we assumed an index of refraction of 3.5.
Below threshold, the laser is multi-modal. The presence of these multiple modes can be observed in the beat pattern signal that results. A beat pattern is the result of two or more slightly different frequencies.
If a light source travels in the same direction with two multiple wavelengths exhibited, the superposition of multiple wavelengths creates an alternation between constructive and destructive interference, thus resulting in a beat pattern. This type of interference is known as temporal interference, meaning that interference occurs over time. These patterns are periodically in and out of phase, and thus create a wave packet, or beats. While beats are usually compared by differences in frequency, we will compare our beats with differences in wavelength (Serway, 515). From our understanding of a Michelson interferometer, a light source consisting of more than one wavelength will go in and out of phase at different lengths of the variable mirror, thus creating a beat pattern.
For a beat pattern the number of fringes within a beat equals the wavelength of the first mode divided by the difference in the wavelengths (# of fringes=l/Dl). Since for a single mode the fringe spacing is l/2 (for one whole wavelength, the light travels up and down the length of the cavity) the number of fringes within a beat of length DD can be determined. From this, the Dl between modes can be found, and then finally the length of the cavity calculated.