Knock and ping are old car guy terms describing ignition irregularities. It's a common misconception, but in internal combustion theory (4 stroke), the air fuel mixture does not ignite and explode. If it did, you would have uncontrolled combustion, which is what is referred to as knock.
You want the air fuel mixture to burn completely evenly, imagine a field of grass. The flame front travels across the field, it doesn't all go up and once. That's what produces power by creating pressure that acts on the top of the piston.
Knock is really post ignition, which can be anything ranging from the failure of the ignition system to ignite the mixture and an alternative ignition point spontaneously forming to multiple competing flame fronts hitting each other head on in different directions. This is defined as after the point at which the spark plug was supposed to fire the mixture. When it gets super volatile, it just seems to completely explode at the same time.
Pre-ignition, which is called pinging, occurs when there is extremely high pressures caused by lean conditions, too much boost, etc, at a point before the ignition system tries to fire the mixture.
Both knock and ping are detected by a microphone (the knock sensor) which listens for high pitched noises that are associated with both knocking and pinging. The sensor has a tight threshold, so it is easily fooled by noises that are not associated with post and pre-ignition. It'd really an inexact sensing method, but short of putting $5000 pressure transducers inside the actual cylinder it's the best method for detecting problems.