Caterpillars moult four to five times before turning into an adult as a moth or butterfly, usually after reaching a specific size. Until recently scientists had no idea how caterpillars sensed they had reached that specific size.
The respiratory system of baby moths is fixed in size at each stage of its development. As it grows its oxygen intake becomes increasingly limited. Sensing it is low on oxygen causes it to proceed to the next stage of its development, by moulting.
Read more at Proceedings of the National Academy of Sciences of the United States of America