I added a security agent to the NS2 core. My aim is to calculate the extra overhead (time and memory allocation) due to the addition of this agent inside the network nodes. Is that possible using NS2 or do I need other tools?
You can compute the running time and memory usage of the code that implements your agent in NS2. However, this does not give you a real indication about time or memory on actual nodes. This is because NS2 is a simulator, so, your NS2 code will not directly run on actual nodes.