The insect nervous system consists primarily of a brain (5), located dorsally in the head, and a nerve cord (19) that runs ventrally through the thorax and abdomen.
The insect brain is a fusion of three pairs of ganglia, each supplying nerves for specific functions. The first pair, called the protocerebrum, connects to the compound eyes (4) and the ocelli (2, 3) and controls vision. The deutocerebrum innervates the antennae (1). The third pair, the tritocerebrum, controls the labrum, and also connects the brain to the rest of the nervous system.
Below the brain, another set of fused ganglia forms the subesopagheal ganglion (31). Nerves from this ganglion control most of the mouthparts, the salivary glands, and the neck muscles.
The central nerve cord connects the brain and subesophageal ganglion with additional ganglion in the thorax and abdomen. Three pairs of thoracic ganglia (28) innervate the legs, wings, and muscles that control locomotion.
Abdominal ganglia innervate the muscles of the abdomen, the reproductive organs, the anus, and any sensory receptors at the posterior end of the insect.
A separate but connected nervous system called the stomodaeal nervous system innervates most of the body's vital organs. Ganglia in this system control functions of the digestive and circulatory systems. Nerves from the tritocerebrum connect to a ganglia on the esophagus; additional nerves from this ganglia attach to the gut and heart.