The exchange, by diffusion through a respiratory membrane, of carbon dioxid for oxygen. The oxygen may be taken from the atmospheric air, as in aerial respiration, or from the air dissolved in water, as in aquatic respiration.