Engine Knocking is a nightmare to the vehicle owners as repairing such engine would eat up his/her pocket. Engine knocking is loud bang heard from the engine and it happens due to the pressure wave generated due to flames from two directions collide with each other. This damages the piston surface, spark plugs, valves, cracks the cylinder liners, blows away the cylinder gasket and much more.
Table of Contents
How it happens?
When the air fuel mixture inside the combustion chamber gets ignited from a source other than the ignition due to spark plug (near the cylinder walls or the top surface of the piston due to Auto ignition temperature . The flame would tend to propagate from two sides of the chamber; when these flames collide at a central point, they produce pressure waves of very high amplitude and damage the engine severely. The sound heard here is very similar to the sound produced while banging the engine hard with a hammer. This is known as detonation and the sound produced is knocking.

Detonation is often confused with pre-ignition. Detonation (the above-mentioned phenomenon) happens only after ignition (spark) and all the engines will have a mild detonation which is typically harmless unless it becomes severe. But pre-ignition happens when the fuel ignites before the actual ignition. This reduces the performance and efficiency of the engine. Sometimes this also affects the engine very badly as the igniting fuel opposes and pushes the piston coming up in its compression stroke.
Causes of knocking
Knocking can happen due to,
1. High compression ratios.
High compression ratios can cause knocking. As high compression is always associated with high cylinder pressures and temperatures, this would make the fuel to attain its to Auto ignition temperature and hence detonation occurs. Compression ratio of a gasoline engine is somewhere between 8:1 to 20:1. Manufacturers set the compression ratios in such a way that it will not cause knocking.
2. Low octane rating of the fuel
Octane number is a property of a fuel. It is a measure of the amount of isooctane present in a mixture of n heptane and isooctane. Generally, Octane number represents petrol fuels and higher the octane number, higher the compression ratio can be achieved. In other words, it is a measure of anti knock property of the fuel.

One thing which I wanted to convey to the readers, special fuels fuels DO NOT improve the mileage of the vehicle but it just improves the knocking properties of the engine so that higher compression ratios can be achieved.
3. Carbon build up in the cylinder.
This happens in the long run. As the engine gets older, due to incomplete combustion, carbon particles builds up in the cylinder walls and the cylinder head. This reduces the overall volume of the cylinder hence the compression ratio increases (the piston moves the same distance but the overall volume is lower than actual). This causes knocking.

In order to prevent Knocking, add some additives and it helps in flushing away these carbon particles.
4. Incorrect spark plugs.
It is very important to use only the spark plugs that is recommend by the manufacturer. Choosing a wrong spark plug may result in catastrophe. As this may alter the ignition timing or the flame temperature.
5. Increased wall temperatures.
If the wall temperature due to various reasons, is more than the to Auto ignition temperature of the fuel used, fuel tend to ignite at near the wall which results in engine knocking.
6. Lean mixtures
In an air fuel mixture, fuel takes away most of the heat produced to the exhaust as it has higher specific heat than air. Therefore, running an engine lean would increase the chamber temperatures and this results in knocking.
Therefore, it is very important to service the vehicle often and save the engine from knocking