As the infantry charged across the plain, a small flag began waving from atop the cliff to their left. "Shit" exclaimed the exec, pointing it out to the captain. "They know we're coming."

With that, the rumble of heavy artillery began from the far side of the hill across the plain. "Not to worry," began the captain. "Arced shot isn't going to be painful. When we get closer, if they skip shot, then we'll have to worry." Even as the first balls began falling around them, a sergeant in the third platoon called out, "Skirmishers on the right!"

A squad of light cavalry, armed with pistols came on an oblique approach, snapping shots at long distance. "Third platoon! Wheel and engage! First and second platoons! Charge!" Even as the third platoon snapped their rifles to firing position, the voices of the first two platoons rose in a ululating war cry.

Grape shot came whizzing out of the fixed emplacements at the top of the hill, dismembering soldiers as the laboriously charged uphill. Then the advancing units reached the earthworks, and began clambering up into the teeth of enemy gunfire. As they reached the brush and spikes at the crest, they began shoving through, their numbers much reduced. Here, it was bloody work - with no time to reload, both sides began stabbing with the bayonets fixed to their rifles.

The coronets of the defenders rose, and a fresh squad of defenders rushed forward into the breech, repulsing the attack.

An example of physical defense in depth
Forward Observers
Provides the ability to see the enemy's formation prior to the engagement
Long range artillery
Forces the enemy to keep moving - as soon as they become stationary, the artillery can range on them. As it is, the benefits of suppressive fire against morale is high.
In this instance, skirmishers forced the advancing unit to divide, thus weakening the attack against the main fortification.
Enfilading fire
At close range, grape shot into attacking infantry is ... lethal.
Being on the uphill side of a charge is always advantageous.
Having units firing upon the chargers - even as they ran uphill.
Effectively, walls to shield the defenders against incoming fire, and forcing the attackers over yet another hurdle.
Preparing infantry for a shift from long range to close quarters combat.
A strategic force prepared to reinforce the defense.