High precision distance between two GPS devices (may be GNSS-SDR)
How to get 1 cm relative accuracy with GPS:

Buy a 1 cm accurate GPS receiver.

For that level of accuracy you need an RTK (Real Time Kinematic) receiver. A good system will give you 1 cm accuracies without any averaging. It will also give you a very large bill to pay, those systems aren't cheap.

Best bang for you buck would probably be something like the ublox NEO-M8P, that datasheet gives an accuracy of 2.5 cm + 1 ppm (that's 1 ppm of the distance between the base and the rover) so around 2.6 cm total for your distance.
If you average that for a while the average should be getting down to your 1 cm target accuracy.