The most basic method to measure airspeed is through a device called a Pitot tube. The tube has a small hole in the front where incoming air applies pressure in a dynamic way. This pressure is compared with one coming from a static port, which is not in the plane of motion, so as to not measure any (or as little as possible) dynamic component of the pressure.
The measurement is called "indicated airspeed", which is quire different from the real speed of travel, as we will see.
The first thing that makes indicated airspeed to be off is called position error. The Pitot tube is supposed to be perpendicular to the direction of motion, but being fixed on the airframe, is not always perpendicular, since an aircraft will vary is angle of attack as a function of its speed and weight, and flap deflection. Flight tests with supplementary external equipment establishes the correction error. Airspeed corrected for position error is called calibrated airspeed.
But this is still not exactly the real speed, as air density and pressure changes with altitude and temperature. If one carries the correction due to air pressure (as well as compression effect when flying at speed close to the speed of sound), then we have the true airspeed.
Which is not the ground speed, as airspeed is relative to the air, which moves if there is wind.
Complicated? You betcha.
The airspeed is what concerns the pilot for a safety point of view. How fast to go to takeoff, how fast to go when landing, and so on, is regulated by airspeed, since this is the only speed that matters for the wing. But an airplane has to go from point A to point B, and those are not affected by wind speed, or varying air pressure.
Modern aircraft are equipped with gyroscopes that sense acceleration and therefore motions, and are able to derive a speed that is correlated with actual ground speed. These are futher agumented by radio emitters, which are located at known points along the way, and which allow triangulation to determine the true position. With any drift in the position relative to what was computed now being known, a better assessment of the actual ground speed is established.
And recently, let's not forget GPS based equipements that can give you position and speed quite accurately.
As for the wind speed, it is known from the various weather and meteorological stations. Doppler radar can measure wind speed, and recent weather forecasts are available to pilots prior to departure, and updated through radio during flight. All the available information is fed into navigation computers by the flight crew, allowing a accurate estimation of the ground speed, and thus allowing a good prediction of the time of arrival at destination.