# (Required for this setup) TossimTopo provides topology control # extension to Tossim. The normal Tossim object may be used but it # will require disabling some "core" modules below. print "starting tossim-topo" import TOSSIM from tossim_topo import Topo, TopoGen tossim = Topo.TossimTopo(TOSSIM, vars if vars is not None else []) tossim_topo = tossim T = tossim # (Required for this setup) Schedule python events "in mote # time". This provides the periodic time reporting. It is also # extremely useful to setup events that occur when a node is booted. from tossim_evt.TossimEvent import * tossim_event = TossimEvent(tossim) # (Optional) Enable to forward packets from mote serial to SF. This # is not strictly required for TReact but allows another application # to simultaneously monitor normal mote output. from TOSSIM import SerialForwarder sf = SerialForwarder(9002) # (Required for this setup) Manage simulation time. This can be # disabled but it requires disabling a "core" module. from TossimSync import TossimSync from act import TimeControl time_control = TimeControl.Remote(tossim, TossimSync(), tossim_event) # (Required) Start packet injector. print "starting injector"
from tossim_topo import Topo, TopoGen tossim = Topo.TossimTopo(TOSSIM, vars if vars is not None else []) tossim_topo = tossim T = tossim # (Required for setup) Load additional objects -- requires compiled support! from SimxTxPower import TxPower from txpower.TxPowerSupport import bootstrapTxPower tx_power = TxPower() bootstrapTxPower(tx_power, tossim_topo) # (Required for this setup) Schedule python events "in mote # time". This provides the periodic time reporting. It is also # extremely useful to setup events that occur when a node is booted. from tossim_evt.TossimEvent import * tossim_event = TossimEvent(tossim) # (Required for this setup) Manage simulation time. This can be # disabled but it requires disabling a "core" module. from TossimSync import TossimSync from act import TimeControl time_control = TimeControl.Remote(tossim, TossimSync(), tossim_event) # (Required) Create the main reactor. For consistency with modules, # the global variable 'R' should be used. print "creating reactor" from act.ReactR import ReactR R = ReactR(injector=injector, globals=globals()) # (Required unless explicit passed in to loadMod()) Allows modules to # automatically "discover" services.