the answer from Hang is a very good starting point for an energy model.
You have to specify all possible events within the simulation. Node-internal events, node-to-node events, node-to-environment events (and reverse).
You also have to specify the abstraction level of you energy model...real energy consumption on the physical layer (very hard to implement) or virtual energy units, which fit to the communication behaviour.
Furthermore, the time is a very critical issue. What is your minimal time unit (tick counter). Accordingly, you have to map energy units to this time base.
For any kind of communication stack, don't forget command & control traffic (besides your payload), which have to be included into your energy model.
May be the question is about how to calculate some performance measure related to energy consumption. in this case you need to add some AWK code to analyse the simulation trace file.