What does this little doo da do?
First, a quick overview concerning those pipes beneath your sink and sticking out your roof, which is part of the Drain, Waste, and Vent (DWV) system of your home. Drain pipes carry water out of the house. Waste pipes are those drain pipes that carry sewage from toilets. Vent pipes supply air to the pipes to keep things running smoothly. An integral part of the whole system is vent pipes that typically run directly to your roof. Without them, wastewater going down the drain could cause the traps (found beneath beneath your sink) to empty out and allow sewer gases into your house. So, what does this doo da do?
The doo da in the photo is called an air admittance valve (AAV.) AAVs are mechanical devices that take the place of plumbing vents. An AAV can take the place of a traditional plumbing vent at various fixtures, because it allows air into the drain without allowing sewer gas to enter the home. To help protect plumbing trap seals, plumbing vents also allow pressurized sewer gas to expel (vent) outside.
Mind you, every home still needs to have at least one full-sized plumbing vent installed, whether or not air admittance valves are present. My concern about them is that they are prohibited in some jurisdictions, and I do occasionally find them in homes. This particular one, I found, in an attic, which may not be a good thing. If the AAV failed, which they have been known to do, then sewer gases could infiltrate into the home.
The graphic below shows how air admittance valves can take the place of traditional vents that you normally see coming out of the roof.