The man who had captured and killed Ankip was still on Bastion. He was the one who was guarding the docks. The force gave him a feeling something was going to happen soon. He was a sith, but had never honed his powers or trained with a lightsaber, all he did was hone his instincts.
Per ran through the ship to the bridge. He yelled through his comlink at an ensign.
"DAMMIT TELL THEM NEXT TIME SOMEONE'S DOCKING WITH US GIVE ME MORE TIME TO GET THE SHIELDS DOWN!"
He switched the code to Locke's and said.
"Locke, tell whoever's on the shuttle to slow down! We need time to get the shields down."
He kept running, cursing the sith for withholding information until it was necessary for him to know and finally arrived. He quickly started working on getting the shields down. He barely managed to get them down before the shuttle crashed into them. He sighed with relief.
"All right, she can land" He announced.
Vader's wife was very pregnant when she died 19 years ago. All of a sudden a 19 year old who is very strong in the force and has a distinct resembalance to him in his younger days rolls in from Vader's home planet with his old Master Obi-Wan (Who was the ONLY other person preset at the time his wife died. And to boot, the kid's last name is Skywalker.
So in answer to your question, he knew Luke was his son because his name is Darth Vader, and not Darth Retard.
-Forum post on why Vader knew Luke was his son.