When a ray of light travels from a denser medium to a rarer medium it bends away from the normal. It the angle of incidence is too large, the angle of refraction will be very large as well (It can be proved by Snell's law). If the value of angle of incidence is higher than a certain value which is known as the critical angle, the ray of light doesn't travel to the rarer medium instead it gets internally reflected in the denser medium. The value of critical angle can be calculated by the following formulae.
Critical angle = arcsin(nr/ni)
Where nr is the refractive index of the rarer medium, ni is the refractive index of the denser medium and arcsin is sine inverse.