What is the function and structure of the nervous system?

The function is to detect and to try to control! The structure is three fold. First, the ANS controls internal functions. Second, the CNS controls the nervous systems. Third, the PNS conveys information about the environment and "output" functions.