When at the door, one should knock or ring the bell in a pleasant way and not louder than necessary to make your presence known. One should not knock loudly and violently or ring the bell continuously. In other words, one should act like a visitor, and not a thug or oppressor attempting to frighten the occupants.
A woman went to visit Imam Ahmad Ibn Hanbal (رحمة الله عليه) seeking his opinion on a religious matter. She banged the door loudly. He came out saying "This is the banging of the police". Likewise Imam Bukhari (رحمة الله عليه) reported in al-Adab al-Mufrad that the Companions of the Prophet used to knock with the tips of their fingers in a soft and gentle manner.
If the living quarters of the person you are visiting are close to the door, it is important to only softly/gently knock with the tips of the fingers, to make your presence known. For those with living quarters further from the door, it is appropriate to knock a little louder, but without banging, or ring the bell enough for them to hear. The Prophet (صلى الله عليه وسلم) said:
"Gentleness adorns every act. Its absence will tarnish it."
In addition, Imam Muslim (رحمة الله عليه) reported that the Prophet (صلى الله عليه وسلم) also said:
"Whoever lacks kindness, lacks all good things".
Between knocks or rings of the bell, one should leave adequate time to allow those being visited to finish performing wudu, finish salaah (approximate time it takes to read 4 raka'as) , or to allow them to finish eating without rushing. One should keep in mind that the person being visited may have jsut started one of the above acts, before you knocked or rang the bell.
After attempting knocks or ringing the bell 3 spaced times, it is important to understand that the person you are visiting may be busy, or would have answered, hence you should leave. One should never enter without permission. The Prophet (صلى الله عليه وسلم) said:
"If you sought permission three times, and were not granted permission, then you must leave".
(Bukhari & Muslim)
When you knock or ring the bell, it is also important that you do not stand infront of the door, but to the left or right of it. The Messenger of Allah (صلى الله عليه وسلم) recommended that one should stand to the left or to the right of the door and to avoid facing it to prevent people seeing things that are either unlawful for them to see, or that which is private.
1. Knock gently with the tips of the fingers, or just loud enough for the occupants to hear.
2. Do not bang the door or ring the bell continuously. Be patient.
3. Allow enough time for the person to answer the door (about the time it takes to read 4 raka'ahs) between each knock.
4. After 3 spaced knocks, and no answer. Leave.
5. Do not stand infront of the door, but slightly to the right or left, so that you may protect your eyes from that which may not be lawful for you to see.