The optical pulses are generated by injecting a large number of carriers (Electrons) into the active region of the device, bringing the carrier density within that region from below to above the lasing threshold. When the carrier density exceeds that value, the ensuing stimulated emission results in the generation of a large number of photons.
However, carriers are depleted as a result of stimulated emission faster than they are injected. So the carrier density eventually falls back to below lasing threshold which results in the termination of the optical output. If carrier injection has not ceased during this period, then the carrier density in the active region can increase once more and the process will repeat itself.
The figure on the right shows a typical pulse generated by Gain-switching with a sinusoidal injection current at 250 MHz producing a pulse of approximately 50 ps. Notice the depletion in carrier density during the pulse, and its subsequent rise due to continued current injection giving rise to a smaller secondary pulse.
The term Gain-switching derives from the fact that the optical gain is negative when carrier density in the active region of the device is below threshold, and switches to a positive value when carrier density exceeds threshold.