Skip to content
Daniel Zappala edited this page Jan 27, 2016 · 2 revisions

The heart of the simulator is the global Sim object, which provides access to the scheduler:

class Sim(object):
    scheduler = scheduler.Scheduler()

The scheduler is used for adding events and keeping track of the current simulated time. It has the following methods:

reset()

Sets the current simulator time back to zero.

current_time()

Returns the current simulation time in seconds.

add(delay,event,handler)

Adds an event to the scheduler for delay seconds in the future. The handler is a method that will be called when the event occurs, and it will be passed the event object as its only parameter. This event can be any Python object, such as a string, a packet, or any other object you define.

cancel(event)

Cancels a pending event.

run()

Runs the simulation.

Clone this wiki locally