A wireless ad hoc network is subject to various security attacks. The encryption and authentication methods protect communication partners from disclosure of their secret messages but cannot prevent traffic analysis. It is argued that the mix method is better for wireless ad hoc networks after exploring the approaches to preventing traffic analysis through hiding the source and destination of packets, however, the security and efficiency are mission-critical and challenging to the present mix algorithm for ad hoc networks. In this paper, a pseudo-random mix (RM)-based anonymity algorithm is presented for ad hoc networks by redesigning the buffer manager. The RM algorithm delays a message by time stamps when the mix buffer is not full, otherwise it forwards a message by a random number. The RM algorithm not only guarantees the anonymity of an anonymous communication system, but also solves the problem of discarding packet in the stop and go algorithm. The analysis shows that the RM algorithm has desirable security property and it can evidently improve the efficiency of an anonymous system. The simulation shows that the RM algorithm is better than those known algorithms in adaptability and utility for wireless ad hoc networks.