In the presence of gravitational field (or, in general, of any potential field) the molecules of gas are acted upon by the gravitational forces. As a result the concentration of gas molecules is not the same at various points of the space and described by Boltzman distribution law:
n = n0exp( -mgh / kT )
where n is concentration of molecules at the height h, n0 is the concentration of molecules at the initial level h = 0, m is the mass of particles, g is the acceleration of free fall, k is the Boltzman constant, T is the temperature.
The animation shows schematically the behavior of the gas molecules in the presence of a gravitational field. We can see in this figure that the concentration of molecules at the bottom of the vessel is higher than the one at the top of the vessel, and that the molecules being pushed upwards fall again under the action of the gravitational field.
If h << kT/mg, then the effect of the height of the vessel on the concentration is negligible. On the contrary, in the atmosphere, the concentration of molecules diminishes quickly with height, and for this reason, the atmospheric pressure diminishes too. Taking into account that pressure P = nkT, we can write the formula for atmospheric pressure:
P = P0exp( -mgh / kT )
Using this formula and measuring the pressure outside of an airplane, we can roughly determine the altitude of the plane.