It is often said, when analyzing poems, that alliteration is the effect created by using successive words beginning with the same first letter, which is true, but which does not actually identify why the poet has chosen to use this technique or what effect is derived from it. A clue when we are trying to understand this is to identify which letters are being used alliteratively, and what difference this makes. For example, alliteration on the letter "s" creates a sibilant, snakelike quality and suggests whispering; in the same way, the letters which alliterate here give different sound effects and suggest different images to the reader.
The repeated "n" sound, for example, is staccato in a way that seems to imitate the nodding the speaker is doing as he tries to stay away, "nearly napping": it seems to evoke the feeling of one's head drooping forward and then being jolted to alertness again. The "n" sound is also contrasted directly, through the use of rhyme, with the "t" in "tapping." "T" is a very clear and sharp sound which seems to evoke the feeling of being pulled back sharply to alertness.