You may look at the following example (after downloading ns-3),
examples/wireless/wifi-simple-adhoc.cc
This example is mainly for ad-hoc network simulations.
This link might help you.. https://groups.google.com/forum/#!topic/ns-3-users/klAS-HqU92I and this tutorial: https://www.nsnam.org/docs/release/3.14/tutorial/singlehtml/index.html#building-a-wireless-network-topology