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.ref
module Time:sig
..end
module Interval:sig
..end
val printer : 'a BatIO.output -> Time.t -> unit
module Map:Batteries.Map.Make
(
sig
typet =
Clock.Time.t
val compare :t -> t -> int
end
)
type
clock = {
|
mutable now : |
|
mutable events : |
val current : clock
val now : unit -> Time.t
val cond_lock : Mutex.t
val cond : Condition.t
val signal_me : unit -> unit
val epsilon : Interval.t
val at : Time.t -> ('a -> unit) -> 'a -> unit
at t f x
will execute f x
when simulation clock reaches time t
.val delay : Interval.t -> ('a -> unit) -> 'a -> unit
delay d f x
will delay the execution of f x
by the interval d
.val asap : ('a -> unit) -> 'a -> unit
val synch : unit -> unit
val next_event : unit -> unit
val run : bool -> unit
run 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.