The 10,000 foot answer is that a resonator is baffled so that the reflected sound/pressure wave is out of phase with the incoming exhaust pulse. The resonator's port sizes, resonator length, and baffle placement (fiberglass has similar affect to baffles) determine which frequencies and to what extent they are attenuated.

the noise cancelling headphones work by generating a signal that has the same frequency and amplitude of the noise but is 180 degrees out of phase.