Energy is generated in the Sun's core through nuclear fusion and must be transported outwards. In the inner layers, energy is transported via radiation, with photons carrying energy. In the outer layers, convection becomes the dominant transport mechanism, with large masses of hot gas rising and cooler gas falling. It takes approximately 170,000 years for energy generated at the core to reach the Sun's surface through this combination of radiation in the inner layers and convection in the outer layers.