There is a cluster of nerves close to the surface under the skin, usually found in the neck or belly. This reflex is involuntary and meant to help protect the dog from fleas or ticks.
And yes, the dog knows whats going on in the sense that it knows whats causing it and is aware that the reflex is involuntary.
Latest Answers