Here is the recommended set of steps for generating XML Animation traces.They must be applied just before the "Simulation::Run" statement.
NOTE: A node must have an associated mobility model in-order to be displayed on the animation. This applies for both stationary and mobile nodes (See notes below)
0. Ensure that your wscript includes the "netanim" module. Example as in: src/netanim/examples/wscript.
1. Also include the header [#include "ns3/netanim-module.h"] in your test program
2. Add the statement "AnimationInterface anim ("animation.xml");" before Simulator::Run()