You can download the NS2 source packages from the Internet. It is open source. According to me, NS2/NS3 is one of the best simulators for WSN. So, I would suggest to use either NS2 or NS3.
In case of NS2, you have to code with TCL. On the other hand, in NS3, you have to do it with only C++, while installing python and eclipse.
Avoid NS2. It is old and deprecated. For free and open source network simulation I suggest either NS3 or OmNeT++, both of which are C++ based and well documented.
I would definitely suggest NetSim. If you use NS2 / NS3 you will spend all your time only learning about the tool and not doing any real research work.
With NetSim it is easy to create scenarios and also writing custom code. You can see various videos that are available in youtube about NetSim.
NS-2 is getting old and it's being replaced by NS-3. So If you're new in this field, it's better to start with the new version. In fact, the migration from NS-2 to NS-3 is not straightforward, because they are completely two different simulators. They only share the same name. Also, the design of NS-3 is better and provide many tools to facilitate the programing like "Smart pointers" and "Callbacks".