1) Install XCode
You will find XCode in the App Store. Alternatively, you can download the most recent version of XCode from the Apple Developer Connection website (http://developer.apple.com/mac/). The XCode development environment includes the gcc compiler and critical libraries required to build applications to be run in Mac OS X. Mac OS X Lion, requires XCode 4.1+.
2) Install MacPorts
2.1) Download MacPorts package installer for Lion release version 2.02 from https://distfiles.macports.org/MacPorts/MacPorts-2.0.2-10.7-Lion.dmg
2.2) Click on the downloaded "pkg" file, to install MacPorts.
2.3) This will place a fully-functioning MacPorts installation on your system
3) Install Required packages for ns-3
3.1) Open a Terminal window and run each command to install the required package
3.2) Install Mercurial and Python:
>> sudo port install mercurial python26
3.3) Install Bzr
>> sudo port install bzr
3.4) Install LibXML
>> sudo port install libxml2
3.5) Install GDB
>> sudo port install gdbm
4) Download ns3 source code
>> hg clone http://code.nsnam.org/ns-3-allinone
>> cd ns-3-allinone
>> ./download.py
5) Build the local repository
>> ./build.py
6) Test the installation
>> cd ns-3-dev
>> ./test.py