Skip to content

Fix flowmonitor stop function

Pedro requested to merge pedrobellotti/ns-3-dev:flowmonitor-fix into master

I encountered a bug with the stop function on flowmonitor while doing an experiment. I wanted to run the simulation for 700 seconds but only monitor the traffic with flowmonitor from 100 seconds to 500 seconds so I used the start and stop function to do just that. The problem was, while start was working properly it seemed like it wouldnt stop at the time I wanted - it always stopped at the end of the simulation (700 seconds) no matter what. Scheduling the StopRightNow function at 500 seconds using Simulator::Schedule worked fine so I took a look at the Stop function and tried a few things. Setting Stop to 500 seconds before Simulator::Run stopped the monitor right away (at 0 seconds), whereas setting it after Simulator::Run didnt stop the monitor at all (which makes sense since you cant go back in time) and I realized that in the function code there was a check for a variable (m_enabled) before scheduling the StopRightNow function. That check was the reason it wasnt working, since the Start was scheduled for 100 seconds that check failed at the start and the simulator never scheduled the actual stop function. The steps to reproduce the problem are very easy: just set the start and stop times and check on the XML file for the time the last packets were transmitted. Remove the m_enabled check on the Stop function and run the same simulation again - it will now stop monitoring packets at the time you set (the time of the last packets wont be after the time you set). Long story short, I just removed the check for the variable and it worked fine. That check (in my opinion) isnt even necessary at all since the StopRightNow function already has the same check.

Merge request reports