The ns2 simulator has a support for LEACH protocol. ns2 is open source and there are tutorials to understand the source code. One can go through the LEACH files in ns2 source code. Only it needs some effort to understand the linkage in ns2 source code. However, ns2 Leach implementation is well proven and tested with time by many researchers.