Blah blah blah, you broke the law and got a ticket.
As far as I know, the officer does NOT have to give you his name, but if you ask for his badge number, he is required to give you that. This is to prevent personal vendettas and forces you to take appropriate action for bad police work: filing a complaint.