Alliteration is a literary device whereby there is an occurrence of the same letter or sound at the beginning of closely connected words. Tongue twisters use alliteration, as in the following:
Peter Piper picked a peck of pickled peppers.
The same device can be seen in the following line, from the first stanza of “The Raven” by Edgar Allan Poe:
While I nodded, nearly napping, suddenly there came a tapping.
In this case, Poe uses alliteration to grab the reader's attention. This is despite the fact that nothing much is actually happening at this particular point in the poem; the speaker's simply nodding off to sleep. But the use of alliteration prepares us for the fact that something momentous is about to happen, namely the tapping at the speaker's chamber door by the eponymous raven.
In this line, Poe also uses rhyme, which he employs extensively throughout the poem. Here we have the rhyme words napping and tapping. Although the words rhyme, they are conceptually different. Napping, or sleeping, is entirely passive, whereas the tapping of the raven on the speaker's chamber door is the exact opposite; it's positive.
The same rhyme can be observed in the next line. Here, Poe uses the word rapping twice, with which he compares the tapping sound that the speaker hears. To the speaker, who's just woken from his slumber, the tapping sounds like someone gently rapping at the door. As he will soon discover, nothing could be farther from the truth.