Search code examples
ns-3

How can I measure instantaneuous bandwidth using ns-3?


I have looked into FlowMon which counts packets over the entire simulation interval. Can I specify shorter intervals and many such intervals? Are there other options to measure instantaneous bandwidth (or at least, bandwidth averaged over short intervals like 1ms) in ns-3?


Solution

  • You could still use FlowMon for this. FlowMon accumulates the number of packets as you progress through the simulation so at different time intervals you can get values such as txBytes and do some calculations with that.

    Take a look at NS3 scheduling, and try using that

    Simulator::Schedule(Seconds(1), &StatsCalculationCallback);
    

    Where the StatsCalculationsCallback is the function where you would calculate the difference between the value now and value before to get for that short interval. Then in the StatsCalculationsCallback function you would then also need to reschedule again for the next interval.