simulating IoT requires integration of wireless sensor and embedded systems to the Internet. "6lowpan" is a standard given by IETF to enable the transmission of IPV6 packets over wireless sensor networks, which is one of the most critical requirement to enable IoT. I dont know whether the implementation of "6lowpan" is available on ns2 or not. But, you can use Omnet++ to simulate the same. Read the following link