But I do recall tests done with either lobsters or crabs where approaching a region in the test environment caused a "shock". The subjects reversed course, and then practiced avoidance of the area.
Call it what you want, but if the sensation made them not want to have it reoccur, it seems like it would be pretty far down the analogous-to-pain path.
Plants and bacteria have reflexive responses to aversive stimuli. Body's that are physiologically functional, but brainless can respond to aversive stimuli.
You can program robotic cockroaches to respond to various stimuli in a similar manner to cockroaches (scuttle from light, protective response to 'injury', etc.).
This is separate from 'experiencing' pain.
Lobsters and crabs are 'meat robots' - like insects, they simply have too few neurons for subjective experience and their responses are simply preprogrammed reactions like 'if then' trees.