how arduino bootloader work ?

Yep, find Optiboot.c and read that. That will give you a good idea of what the bootloader is up to.