The ventilatory control mechanism must accomplish two tasks: establishing the automatic rhythm of respiration and adjusting the rhythm based on metabolic demands, mechanical conditions, and other behaviors. This is accomplished by networks of respiratory neurons located in the dorsal and ventral respiratory groups in the medulla that generate the respiratory rhythm through intrinsic properties and synaptic interactions. These neurons are modulated by peripheral and central chemoreceptors that sense changes in blood gases like oxygen and carbon dioxide levels to adjust ventilation. Higher brain centers and afferent feedback further influence the respiratory control system.