How Did Medieval Armies Defend Their Camps From Ambush?

How Did Medieval Armies Defend Their Camps From Ambush? Not everyone had a tent, sometimes lower class soldiers just slept on the ground, but if they expected to stay more than a night they would build some sort of shelter. Camps that were constructed for sieges almost always had fortifications, because they were often raided.