If a planet moves around the sun in a circular orbit of radius r at speed v, then the mass M of the sun is given by where G is a gravitational constant. If we can measure speed and size of orbit, we can estimate the mass of the central object. For our sun it is about 2,000,000,000,000,000,000,000,000,000,000 kg.
Most solar systems are elliptical rather than circular.
The universe is expanding, and so most objects are receding from us. By measuring the redshift we can find out how fast they are moving away. This makes it straightforward to decide the distance of say a galaxy. Light Years Particles of light, called photons, move faster than any other object with a speed of three hundred million metres per second. In one year they move a distance 950,000,000,000 kilometres, which is called a light year .