Sunan Abi Dawud, Book 43, Hadith 427 (Abu Dawud 5201)

Abu Hurairah reported the Messenger of Allah (May peace be upon him) as saying:

one who is riding should salute one who is walking. He then mentioned the rest of the tradition.