- 
                Notifications
    
You must be signed in to change notification settings  - Fork 144
 
Description
hi,
I am interested in testing the ntp protocol and real implementations such as chrony (http://chrony.tuxfamily.org) or ntpd (www.ntp.org) in a simulated environement, more precisely in the ns3 simulator (www.nsnam.org). ns3 makes it possible to run real code thanks to its Direct Code Execution (DCE) extension (https://github.com/direct-code-execution/ns-3-dce).
This issue is a way to assess my understanding as well as checking for possible solutions of what I want to achieve. Hence it's likely Ive misunderstood some parts, hope you will correct me.
So far I found a few testing projects:
- https://github.com/johnstultz-work/timetests by @johnstultz-work executes syscalls on a running kernel with various parameters trying to see if syscalls respond accordingly.
 - https://github.com/mlichvar/linux-tktest by @mlichvar implements some kernel functions such as printk and link kernel/time/timekeeping.c and sounds similar to the previous project ?
 - https://github.com/mlichvar/clknetsim is a simulator that start a few ntp servers with LD_PRELOAD trick, it generate ticks and propagates them to the fake nodes, it also delays messages in order to simulate network propagation delays. The downside is that it reimplements adjtimex etc... instead of testing the kernel's.
 
Now there seems to be 2 modes for clocks:
- tick based struct clocksource defined in include/linux/clocksource.h
 - tickless with struct clock_event_device http://lxr.free-electrons.com/source/include/linux/clockchips.h#L99
 
The scenario I would like to achieve is:
- setup a topology/links in ns3
 - load some ntp servers (chrony/ntpd) in the ns3 simulation with DCE
 - these servers should call kernel adjtimex (thanks to lkl or libOS ?)
 - changes made by the kernel need to be reflected in ns3
 
ns3 is a discrete event simulator, ie. it is tickless: if you schedule an event at t0=5sec and a second one at t1=100s, then ns3 will just execute the first event, set the integer representing time to t1=100 and execute the event.
So far in ns3, the nodes share the time value and are all perfectly synchronized, I want to introduce per node clocks.
My problem is step 4:
- when ns3 advances time from t0 to t1, how can it update the kernel value ? There is no notion of tick it justs jumps. Should I write some driver struct clock_event_device ?
 - and the opposite, if the kernel needs to inject an offset, should it have an impact on the ns3 node clock ?
 
Sorry if it sounds confused or for mentioning you if you are not interested. I think this LKL project or libOS can help in what I want to achieve. I am willing to contribute to LKL if that helps but I would need directions.
Matt