direct-code-execution / ns-3-dce

Run real programs in the discrete time simulator ns3
http://www.nsnam.org/projects/direct-code-execution/
75 stars 46 forks source link

LinuxStackHelper delays sysctl.set calls until 100ms into simulation #101

Open tomhenderson opened 4 years ago

tomhenderson commented 4 years ago

Description of the problem

I encountered a problem that my calls to LinuxStackHelper::SysctlSet() were not taking effect, and then I traced it to the fact that my TCP sockets were created after a few milliseconds into the simulation, while the stack helper is deferring its set until 100ms in. Below is a workaround but something cleaner (to execute around time 0) should be devised.

diff --git a/helper/linux-stack-helper.cc b/helper/linux-stack-helper.cc
index 18c0919..0af2707 100644
--- a/helper/linux-stack-helper.cc
+++ b/helper/linux-stack-helper.cc
@@ -186,7 +186,7 @@ LinuxStackHelper::SysctlSet (NodeContainer c, std::string path, std::string valu
                          "You may need to do it via DceManagerHelper::Install ()");
         }
       // i.e., TaskManager::Current() needs it.
-      Simulator::ScheduleWithContext (node->GetId (), Seconds (0.1),
+      Simulator::ScheduleWithContext (node->GetId (), MicroSeconds (1),
                                       MakeEvent (&LinuxSocketFdFactory::Set, sock,
                                                  path, value));
     }
teto commented 4 years ago

I remember having the same issue. I think the change might be good enough for now. I would merge the PR.