What is the etiquette for repeatedly emailing questions to an author whose work I'm building on? I am doing my master thesis on wireless networking. I am working on the source code, which the writer of one of the articles provided to me.
Initially, I sent him an email and I asked him to send me his C++ source code . So he did. But the problem is, there was no documentation for his code and he is the only one that knows anything about this codebase. As a result, I totally depend on him. Last night I sent him an email and I asked him a question about his code and he replied to me very quickly, only three hours later. Probably, I will need his help again.

Before my last night's email and after spending one month working on his code, I saw  minor progress to my work. But after  yesterday's mail and his guidance, my work was significantly accelerated. I will probably need his help again maybe another two or three emails in a week. But I am afraid he will become angry with me for sending him a lot of emails. 

So what should I do? Assume you are the source code programmer. Do you think he will become angry about my emails? Or he will be willing to help (since I will cite his article)?
Although your intentions are probably good, you seem to take advantage of the creator of the source code. He is not your personal debugger nor he must be the one writing the code for your thesis (especially for free). He has written a paper and he has given you his source code. That is all the information you need to know. Read his paper (or his paper slides if they are publicly available) a hundred times, till you know every little detail of it and then look at his code (another hundred times) until you correlate everything between the paper and the code. Of course this will be slower than sending him a couple of emails but it is YOUR thesis not his. Only when you do all this and still there are unanswered questions, then collect all the possible questions you might have (including queries about his code and his paper) and then send it him ONE email, with all your questions. Anything more than that is exploiting his kindness. This kind of back and forth emails with questions is one of the many reasons why many people are unwilling to share their codebase. 

Since he is probably a nice guy, you should consider that in the future you might collaborate with him or need his help. Being pushy or lazy (and delegating your work to him because you do not want spend 1-3 weeks refactoring or studying his code more carefully) is a sure way to burn bridges with him. And you really do not want to do that.  

On the other hand, if after giving you access to his source code he understands (by your email) that you did everything humanly possible to understand his code and paper and just want some extra help, he will be willing to assist because: a) you seem to appreciate his work b) you seem to understand his time constraints c) you are also a smart, hard working guy worth collaborating with. And this is the message you need to convey.