In the last few years, commercial and private aircraft have been equipped with transponders that transmit both location and altitude. This information is transmitted to everyone, including on FlightAware, and is also available from aircraft to aircraft.
Source: ABC News 6
