module Clock:sig..end
When in realtime mode (the default), the clock will merely follow
wall-clock. Then, scheduling an event in the future is equivalent to
Unix.sleep for some time. This is not very interesting but is required
whenever you plan to work with real network devices and outside world. On
the other hand, if your simulated network does not communicates with the
outside world, for instance because your objective is to build a pcap file,
then you can use not realtime mode and then play your simulation at full
speed (and full CPU), and produce a pcap file representing, say, the
workload of a day in minutes, or conversely a very busy hour in several
hours but with all packets and accurate timestamps.
val debug : bool
val realtime : bool Batteries.refmodule Time:sig..end
module Interval:sig..end
val printer : 'a BatIO.output -> Time.t -> unitmodule Map:Batteries.Map.Make(sigtypet =Clock.Time.tval compare :t -> t -> intend)
type clock = {
|
mutable now : |
|
mutable events : |
val current : clockval now : unit -> Time.tval cond_lock : Mutex.t
val cond : Condition.t
val signal_me : unit -> unit
val epsilon : Interval.t
val at : Time.t -> ('a -> unit) -> 'a -> unitat t f x will execute f x when simulation clock reaches time t.val delay : Interval.t -> ('a -> unit) -> 'a -> unitdelay d f x will delay the execution of f x by the interval d.val asap : ('a -> unit) -> 'a -> unit
val synch : unit -> unitval next_event : unit -> unitval run : bool -> unitrun true will run forever while run false will return once no more
events are waiting. If you chose no to run forever, beware that waiting for
an answer from the outside world is _not_ a clock event. You should probably
run forever whenever you communicate with the outside.