Ultrasound is passed through one end of the metal and a detector is installed at the other end. When the metal is perfect, the ultrasonic waves travel as expected and hence are detected on the other end. For a metal with a defect, the waves are reflected back and hence don't reach the other end. When no detection is received, it can be concluded that the metal has a defect.