[sim-wg] TOSSIM and the 2.1 Release

Chad Metcalf metcalfc at gmail.com
Thu Sep 20 10:24:04 PDT 2007


> Right -- I did a performance analysis way back when for T1 and found
> that optimistic concurrency control (read: mutexes) was more
> efficient than polling. The original idea behind TOSSIM in T2 was to
> bring it up to Python as quickly as possible, so that things like
> serial forwarders could be incorporated as scripts, which then users
> could choose to include/not include. E.g., there's no reason that
> your Python driver can't do something like
>
> for i in range(0, 100000):
>    t.runNextEvent()
>    processSFPackets()

Right now will this implementation you don't have to use SF in either
the C++ or Python versions. You get an instance of the SF object and
then you use it other wise you don't. So I'm not sure I understand
what you mean or rather what is different. (See the included full
Python example). SF is just an object that lives with the TOSSIM,
radio, and mac objects.

> The one downside of pushing this into the scripting world is it makes
> transitioning between C++ and Python harder.

So is the thought going forward then that TOSSIM won't be supporting
C++ based simulation drivers?

Cheers
Chad

--- Example ---

    1 # This file is an example Python script from the TOSSIM tutorial.
    2 # It is intended to be used with the RadioCountToLeds application.
    3
    4 import sys
    5 import time
    6
    7 from TOSSIM import *
    8 from TestSerialMsg import *
    9
   10 t = Tossim([])
   11 m = t.mac()
   12 r = t.radio()
   13 sf = SerialForwarder(9001)
   14 throttle = Throttle(t, 10)
   15
   16 t.addChannel("Serial", sys.stdout);
   17 t.addChannel("TestSerialC", sys.stdout);
   18
   19 for i in range(0, 2):
   20   m = t.getNode(i);
   21   m.bootAtTime((31 + t.ticksPerSecond() / 10) * i + 1);
   22
   23 sf.process(); # Handle initial connections
   24 throttle.initialize();
   25
   26 for i in range(0, 60):
   27   throttle.checkThrottle();
   28   t.runNextEvent();
   29   sf.process();
   30
   31 msg = TestSerialMsg()
   32 msg.set_counter(7);
   33
   34 serialpkt = t.newSerialPacket();
   35 serialpkt.setData(msg.data)
   36 serialpkt.setType(msg.get_amType())
   37 serialpkt.setDestination(0)
   38 serialpkt.deliver(0, t.time() + 3)
   39
   40 pkt = t.newPacket();
   41 pkt.setData(msg.data)
   42 pkt.setType(msg.get_amType())
   43 pkt.setDestination(0)
   44 pkt.deliver(0, t.time() + 10)
   45
   46 for i in range(0, 20):
   47   throttle.checkThrottle();
   48   t.runNextEvent();
   49   sf.process();

-- 
Chad @ Home


More information about the Sim-wg mailing list