knock sensor, obviously is to detect knock in your engine, haha :D
seriously, knock, which is also known as pinking or detonation, is the worst case that can happen in you combustion cycle. it usually happens when you air/fuel ratio is too lean causing overheating or your cylinder block and piston is dirty, having deposit (like carbon) sticking at them, that will cause detonation.
in a normal combustion, the flame start from top to bottom. that is from the spark of the spark plug, the flame pushes downward to the direction of the piston.
in detonation/knock/pinking, the flame start from top as usual. because there is overheating or deposits at the piston, this part tends to act like a spark plug too, cause it is hot enuf to ignite the fuel. therefore, the flame travels from from bottom to up (from piston to the spark plug direction). 2 flames coming in head to head will cause detonation, causing severe damage such as broken pistons and so on..
correct me if i'm wrong :)