All insects are aerobic organisms -- they must obtain oxygen (O2) from their environment in order to survive. They use the same metabolic reactions as other animals (glycolysis, Kreb's cycle, and the electron transport system) to convert nutrients (e.g. sugars) into the chemical bond energy of ATP. During the final step of this process, oxygen atoms react with hydrogen ions to produce water, releasing energy that is captured in a phosphate bond of ATP.
The respiratory system is responsible for delivering sufficient oxygen to all cells of the body and for removing carbon dioxide (CO2) that is produced as a waste product of cellular respiration. The respiratory system of insects (and many other arthropods) is separate from the circulatory system. It is a complex network of tubes (called a tracheal system) that delivers oxygen-containing air to every cell of the body.
Air enters the insect's body through valve-like openings in the exoskeleton. These openings (called spiracles) are located laterally along the thorax and abdomen of most insects -- usually one pair of spiracles per body segment. Air flow is regulated by small muscles that operate one or two flap-like valves within each spiracle -- contracting to close the spiracle, or relaxing to open it.
After passing through a spiracle, air enters a longitudinal tracheal trunk, eventually diffusing throughout a complex, branching network of tracheal tubes that subdivides into smaller and smaller diameters and reaches every part of the body. At the end of each tracheal branch, a special cell (the tracheole) provides a thin, moist interface for the exchange of gasses between atmospheric air and a living cell. Oxygen in the tracheal tube first dissolves in the liquid of the tracheole and then diffuses into the cytoplasm of an adjacent cell. At the same time, carbon dioxide, produced as a waste product of cellular respiration, diffuses out of the cell and, eventually, out of the body through the tracheal system.
Each tracheal tube develops as an invagination of the ectoderm during embryonic development. To prevent its collapse under pressure, a thin, reinforcing "wire" of cuticle (the taenidia) winds spirally through the membranous wall. This design (similar in structure to a heater hose on an automobile or an exhaust duct on a clothes dryer) gives tracheal tubes the ability to flex and stretch without developing kinks that might restrict air flow.
The absence of taenidia in certain parts of the tracheal system allows the formation of collapsible air sacs, balloon-like structures that may store a reserve of air. In dry terrestrial environments, this temporary air supply allows an insect to conserve water by closing its spiracles during periods of high evaporative stress. Aquatic insects consume the stored air while under water or use it to regulate buoyancy. During a molt, air sacs fill and enlarge as the insect breaks free of the old exoskeleton and expands a new one. Between molts, the air sacs provide room for new growth -- shrinking in volume as they are compressed by expansion of internal organs.
Small insects rely almost exclusively on passive diffusion and physical activity for the movement of gasses within the tracheal system. However, larger insects may require active ventilation of the tracheal system (especially when active or under heat stress). They accomplish this by opening some spiracles and closing others while using abdominal muscles to alternately expand and contract body volume. Although these pulsating movements flush air from one end of the body to the other through the longitudinal tracheal trunks, diffusion is still important for distributing oxygen to individual cells through the network of smaller tracheal tubes. In fact, the rate of gas diffusion is regarded as one of the main limiting factors (along with weight of the exoskeleton) that prevents real insects from growing as large as the ones we see in horror movies!