The knock sensor is a sensor to detect engine combustion knock.
Normally in a petrol engine when the fuel is ignited it burns with progressing flame front. Knocking occurs when the fuel mixture EXPLODES. Explosion causes rapid gas expansion, large shock waves and very high pressures. i.e. instead of the fuel mixture producing progressive pressure/expansion and pushing the piston down it explodes/stamps very hard on the piston head.
The knocking occurs for a variety of reasons e.g fuel mixture too weak, plugs to hot, ignition too advanced. Once knocking is detected by the knock sensor it sends this signal to the engine ECU. The ECU will then retard the ignition and may also make fuel mixture changes as well to reduce the knock.
If a knock sensor is continually signalling a knocking then the ignition will be heavily retard by the ECU. This will cause a drop in power which will be most evident at higher RPMs.
The knock sensor or sensors are located on the engine block on either the front or the back of the block. If you have 1 sensor then it will most likely be centrally mounted between cyls 2 and 3. If you have two then one will be between cyls 1 & 2 and the other between 3 & 4. You are VERY VERY unlikely to have more than two sensors unless you have dropped an F1/similar engine into your car.
Hope this helps