While deployment and practical on-site testing remains the ultimate touchstone for sensor network code, good simulation tools can help curtail in-field troubleshooting time. Unfortunately, current simulators are successful only at evaluating system performance and exposing manifestations of errors. They are not designed to diagnose the root cause of the exposed anomalous behavior. This paper presents a diagnostic simulator, implemented as an extension to TOSSIM . It (i) allows the user to ask questions such as "why is (some specific) bad behavior occurring?", and (ii) conjectures on possible causes of the user-specified behavior when it is encountered during simulation. The simulator works by logging event sequences and states produced in a regular simulation run. It then uses sequence extraction, and frequent pattern analysis techniques to recognize sequences and states that are possible root causes of the user-defined undesirable behavior. To evaluate the effectiveness of the tool, we have implemented the directed diffusion protocol and used our tool during the development process. During this process the tool was able to uncover two design bugs that were not addressed in the original protocol. The manifestation of these two bugs were same but the causes of failure were completely different - one was triggered by node reboot and the other was triggered by an overflow of timestamps generated by the local clock. The case study demonstrates a success scenario for diagnostic simulation.