On 01.07.2010 23:10, Chuck Remes wrote:
> My problem is mocking out the time source so that I can run
> simulations in faster than real-time. For example, I may send a
> request for a data record and give it a 5 second timeout. This works
> fine when the clock source is the actual operating system, but if I
> want to run faster than real-time I need to mock the clock out. That
> is, I want to take a simulation that might run in 4 hours real-time
> (with lots of waiting or other timer related delays) to run in 20
> minutes because 1 second of simulation time is only a fraction of a
> second in the real world.
>
> This is simple to do for a single component on a single system
> because I can intercept all calls to Time and replace it with my own
> source. However, I don't know how to get all of the distributed
> components (across multiple machines or multiple processes on one
> machine) to use a mocked clock.
>
> I tried googling around for answers, but all of the papers appear to
> be concerned with adjusting clock skew across a network where each
> device already has a local time source. I don't know if those
> solutions apply here.
>
> Anyone have any bright ideas? Need more information?

A very simplistic solution would be to use DRb and have a centralized 
clock.  Depending on the number of clients this may of course turn out 
as a bottleneck.  In that case you would have to devise a more complex 
mechanism.

Maybe looking at time protocols such as NTP might give you some 
inspiration.  Basically you want to solve the same problem, just with a 
different time source (I don't think that a mocked NTP server will work 
because that needs local clocks with a particular precision.

Another option might be UDP broadcast with the "current time" - if 
network latency as precision is good enough.  If not, again you need a 
more complex mechanism (see time protocols).

Kind regards

	robert

-- 
remember.guy do |as, often| as.you_can - without end
http://blog.rubybestpractices.com/