Cosmic archeology with gravitational waves