A knock sensor tells the engine computer when one or more of your engine's cylinders are "knocking", that is, exploding the air/fuel mixture in a way that delivers less power and can be damaging to the engine if prolonged. The computer uses this information to tune the engine so that it doesn't knock. If your knock sensor wasn't operating properly, so that it was always indicating a knock, the engine computer's response may have been to change the ignition timing on your engine. Knock sensors generally bolt into or thread into the engine block.
If you want to repair it yourself then get a repair manual (Haynes, OEM service manual, etc...) check the circuit for a bad connection, torn wires or a corroded connection, then if the harness is in good condition, replace the sensor.
I don't have a 3rd gen service manual otherwise I'd copy some of it and post it.
Good luck!