This is always one of my favorite parts of our Veteran ceremonies. I dont know why but for some reason, I always feel a great sense of pride when this is executed. I did some research on the history of the salute and there is quite a bit out there and there are a few different versions of what the actual history may be. The following is the one that I like and it isnt way different than a couple others but there are some differences in some of the depictions of the history of this ceremonial procedure.
At military funerals, one often sees three volleys of shots fired in honor of the deceased veteran. This is often mistaken by the laymen as a 21-gun salute.
Anyone who is entitled to a military funeral (generally anyone who dies on active duty, honorably discharged veterans, and military retirees) are to the three rifle volleys, subject to availability of honor guard teams. The firing team can consist of any number, but one usually sees a team of eight, with a noncommissioned officer in charge of the firing detail. Whether the team consists of three or eight, or ten, each member fires three times (three volleys).
The three volleys come from an old battlefield custom. The two warring sides would cease hostilities to clear their dead from the battlefield, and the firing of three volleys meant that the dead had been properly cared for and the side was ready to resume the battle.
The flag detail often slips three shell casings into the folded flag before presenting the flag to the family. Each casing represents one volley.
I found a video that I like that depicts this salute with the bigger guns of the Army. I hope you like it as I do.