In addition to salutes offered to the President and heads of state, it was also a tradition in the U.S. Navy to render a "national salute" on 22 February (Washington's Birthday) and 4 July (the anniversary of the Declaration of Independence).
A twenty-one gun salute for the President and heads of state, Washington's Birthday, and the Fourth of July became the standard in the United States Navy with the issuance of new regulations on 24 May 1842. Those regulations laid out the specifics:
- "When the President of the United States shall visit a vessel of the navy, he shall be received with the following honors: The yards shall be manned, all the officers shall be on deck in full uniform, the full guard shall be paraded and present arms, the music shall play a march, and a salute of twenty-one guns shall be fired. He shall receive the same honors when he leaves the ship."
"Upon the anniversary of the Declaration of Independence of the United States, the colors shall be hoisted at sunrise, and all the vessels of the navy shall, when in port, be dressed, and so continue until the colors are hauled down at sunset, if the state of the weather and other circumstances will allow it. At sunrise, at meridian, and at sunset, a salute of twenty-one guns shall be fired from every vessel in commission mounting six guns and upwards."
"On the twenty-second day of February, the anniversary of the birth of Washington, a salute of twenty-one guns shall be fired at meridian from every vessel of the navy in commission mounting six guns and upwards."
Gun salutes are also rendered to other military and civilian leaders of this and other nations. The number of guns is based on their protocol rank. These salutes are always in odd numbers. For example, the Vice President of the United States, Secretary Defense, and Secretaries of the Army, Air Force, and Navy all rate 19 guns. The highest-ranking generals in the services (Commadant of the Marine Corps, Chief of Naval Operations, and the Army and Air Force Chief of Staffs) all rate 17 guns. Other 4-star generals and admirals rate 17 guns. Three-stars rate 15, two-stars rate 13, and one-stars rate 11.
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, although it is entirely different (in the military, a "gun" is a large-calibered weapon. The three volleys are fired from "rifles," not "guns." Therefore, the three volleys isn't any kind of "gun salute," at all).
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. As I said, this is not a 21-gun salute, nor any other type of "gun salute." They are simply three rifle volleys fired. 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 comes 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.
Much of the above information compiled from the Naval Historical Society and the Army Center of Military History

