The plumbing code requires every fixture trap to be vented to ensure the proper operation of the drain. The vent allows air into the pipe to replace the vacuum created by flowing water, and if it isn't properly installed, the vacuum slows water flow and may drain the trap. A trap with no water creates an unsanitary condition, because sewer gases and vermin can enter the house through the drain. Other effects of poor venting are frequent drain clogs caused by sediment settling out of slow-moving water and water overflowing from drain openings or toilets.
The main soil stack in a house is the vertical pipe that extends from the main toilet to the sewer, and this pipe also extends upward through the roof to form the main vent stack. Just as all the drains in the house connect to the main soil stack and thus to the sewer, all the vents connect to the main vent stack and thus to fresh air. The main vent stack typically extends about 12 inches above the roof line so sewer gases can disperse in the atmosphere.
When you install a new fixture, such as a sink or toilet, far enough away from the main stack to make tying into it impractical, you have to provide an individual vent for that fixture. If the fixture is on the ground floor of a multi-story building, running the vent through the wall is more practical than extending it up through the roof. This is permissible, but in some states, including California, you can't terminate the vent under a soffit. You have to extend the vent pipe up along the side of the house and extend it either past it or through the roof.
Your vent pipe must be at least half the diameter of the drain pipe it services, and cannot be less than 1 1/4 inches in diameter. Plumbers usually use 2-inch pipe to service a 3- or 4-inch soil stack. The vent can run horizontally, as long as it maintains a minimum pitch of 1/4 inch per foot toward the drain. Once outside, it must terminate at least 12 inches from any wall and at least three feet from any door or window opening. The vent must terminate at least six inches above the roof line.