*jokemaster comes into the cantina wearing casual clothes*
Security Droid: Hand over your weapons. You will get them back when you leave.
*jokemaster gives the security droid two blasters, a sniper rifle, an E-11 blaster rifle, and old lightsaber, a rapid fire machinge gun, a sub-machine gun, 9 knives, 8 thermal detonators, 7 packs of C-4, 6 vials of acid, 5 clips of ammo, 4 miniblasters, and a rabid dog.*
Jokemaster: here you go
*jokemaster orders a drink and sits down at the bar*
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.