can there be duplicates in Canada? North America? Why will ATC have you change codes sometimes? When someone does change a code, or when asked to ident, what does that "look" like to the controller on his scope?
The computer assigns a number from a predetermined block of available numbers. Certain blocks may me assigned to different areas or uses.
Yes there can be duplicates in the sense 2 active aircraft will have the same code, but the flight plan system per FIR/Centre should only have one plane per code, which is the main reason ATC may ask you to change from one discrete code to another when going to a new centre's airspace. Edmonton may have someone on a code. Montreal may have someone else on same code. No problem. As they cross the country in Winnipeg's airspace the computer someone needs a new code so the radar system correlates correctly.
With an ident, the target flashes white for a few seconds.
When someone changes their code, the normal target changes to uncorrelated (just a target with the new code, but no aircraft info), for a couple seconds, and then the computer processes it and correlates the new squawk code with a flightplan in the system and looks normal again.