The general idea is that you go between phases in your sleep cycle. Without getting to technical there are 5 phases of sleep: 1, 2, 3, 4 and REM (rapid eye movement, dreaming phase). Usually when you are sleeping, you begin at stage 1 (light sleep and go through each phase until you reach the REM sleep phase. Each complete sleep cycle is around 90 to 110 minutes long, so you go through several of them while sleeping.Your body and brain behaves differently in each phase of sleep. In some of the phases, your body will make movements, and in others your arms and legs will be immobile. So dependent on your movement it's possible to say what stage you are in.