First of all I'd recommend addressing all officials in a polite way, so you use "вы", but not "ты".
Most of the times just that polite addressing is totally fine.
If you're pulled by a cop than he is supposed to introduce himself. That include his rank and surname. "Сержант Козлов" for example, or "Старший инспектор Иванов". Traffic cops are usually some kind of "инспектор".
You could use his rank preceding it with "товарищ". That'll be "товарищ инспектор".
Other options:
- Using just "инспектор" looks kinda rude.
- Surname without rank ("товарищ Иванов") makes it look like you're addressing regular citizen not official. Would not recommend it since reaction is unpredictable.
- Using full introduction as it was "Старший инспектор
Иванов" on the other hand is too official. Sometimes you'd like
that, at least could be useful in case of an argument.
"командир" or "начальник" - naturally used by truck drivers, old school taxi drivers, ex-cons. Others might use it to make situation more friendly in case of asking officer of some favour (not writing a ticket and letting go with warning for example). In that case those addressing is usually done with open smile as if you're friends and prolonged vowels "командииир", "начаааальник".
Note: if used with "товарищ" or "гражданин" it is "товарищ командир". No proof but "гражданин командир" sounds really strange. I presume that's because it's militaristic addressing, there are no citizens in army only comrades.
On the other hand "товарищ начальник" and "гражданин начальник" both ok. Later is more commonly used as more friendlier.
As a rule of thumb "comrade" is a step towards some friendly talk, and "citizen" is a huge leap towards official style communication.