DJI drones are equipped with the so-called IMU, an acronym for "Inertial Measurement Unit". It is the heart of the flight controller that allows the drones like the Dji
Mavic 2 to fly in a stable and safe way. Its main sensors are: accelerometer, gyroscope, barometer and thermometer.
The barometer measures air pressure; it’s altitude indication (as calculated by the IMU and passed to the DJI app) shows height above the takeoff point.
While some have maintained that the GPS might also be (additionally) used in this calculation GPS altitude in DJI consumer birds is not as accurate as most of the high-end commercial drones. GPS is more accurate for horizontal positioning than vertical and will depend on the number of satellites locked.
Altitude indications via barometer - filtered thru the IMU - may also be subject to a sampling rate/integration time to smooth out the results. Some drones have dual barometers...and dual IMUs for increased accuracy and reliability.
The
Mavic 2-series (along with some others) have some additional controls for precision altitude that uses downward sensors, but that is only functional up to about 8 meters...
Someone will inevitably point out it is the PIC’s responsibility to monitor altitude and not rely on the controller, but I’m not concerned about a 17-foot deviation being a regulatory problem.
I would recommend a flight test; using the same settings (not in a 100-foot Class D) try to go to the limit and see if it stops...then take a screen shot. Hover at 3 ft...make sure the indicated altitude is 3’ (-ish).
Next, review the flight logs and see if that value upon reaching the altitude limit and 3 ft. hover agree...