Physics of the magnetosphere