]> oss.titaniummirror.com Git - tinyos-2.x.git/blobdiff - doc/html/tutorial/lesson11.html
Fix typos and add source addr.
[tinyos-2.x.git] / doc / html / tutorial / lesson11.html
index 48ac8a93224c8023a69620211e5f35e09e57f45f..9f49f9340a9e2d6b1c7b5be5e3f87b5d8ffbe467 100644 (file)
@@ -6,10 +6,8 @@
 </head>
 <body>
 
-<!--- $Id$ --->
-
 <div class="title">Lesson 11: Simulation with TOSSIM</div>
-<div class="subtitle">Last Modified: 18 May 2006</div>
+<div class="subtitle">Last Modified: 20 April 2007</div>
 
       <p>This lesson introduces the TOSSIM simulator. You will become
         familiar with how to compile TOSSIM and use some of its
           <li>Inject packets.</li>
         </ul>
       </p>
-
-
+      
+      <p><b>Note:</b> This tutorial is for TOSSIM in TinyOS 2.0.1. If
+      you are using TinyOS 2.0.0, it has a slightly different 
+       A HREF="lesson11-200.html">tutorial.</A> The principal difference
+      between the two is how you specify noise in RF simulation.
+      </p>
 <h1>Introduction</h1>
 
         TOSSIM simulates entire TinyOS applications. It works by
         </pre>
 
         
-        
-        <p>Currently, the only platform TOSSIM supports is the
+      <p>Currently, the only platform TOSSIM supports is the
         micaz. You should see output similar to this:</p>
-        <pre>
+      <pre>
           mkdir -p build/micaz
             placing object files in build/micaz
             writing XML schema to app.xml
             linking into shared object ./_TOSSIMmodule.so
           g++ -shared build/micaz/pytossim.o build/micaz/sim.o build/micaz/tossim.o -lstdc++ -o _TOSSIMmodule.so
           copying Python script interface TOSSIM.py from lib/tossim to local directory
-         </pre>
+      </pre>
+
+      <p>Depending on what OS you are using and what packages are installed, TOSSIM may
+       not properly compile on the first try. <A HREF="#appendix">Appendix A</A>
+       addresses some of the common causes and gives possible solutions.</p>
+
+
+     <A name="#compiling"></A>
 
+       
         <p>Compiling TOSSIM has five basic steps. Let's go through
         them one by one.</p>
 
@@ -244,10 +253,17 @@ Type "help", "copyright", "credits" or "license" for more information.
         <pre>
 >>> m = t.getNode(32);
 >>> m.bootAtTime(45654);
->>> t.runNextEVent()
+>>> t.runNextEvent()
 1
         </pre>
 
+      <p><b>Segmentation faults:</b>If trying to do this causes TOSSIM
+      to throw a segmentation violation (segfault), then chances are
+      you are using a version of gcc that does not work well with the
+      dynamic linking that TOSSIM is doing. In particular, it has been
+      verified to work properly with 4.0.2 and 3.6, but some people
+      have encountered problems with gcc 4.1.1.</p>
+      
       <p>Instead of using raw simulation ticks, you can also use the
       call <code>ticksPerSecond()</code>. However, you want to be careful
       to add some random bits into this number: having every node
@@ -300,7 +316,7 @@ Type "help", "copyright", "credits" or "license" for more information.
 '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__str__',
 '__swig_getmethods__', '__swig_setmethods__', '__weakref__', 'addChannel',
 'currentNode', 'getNode', 'init', 'mac', 'newPacket', 'radio', 'removeChannel',
-'runNextEvent', 'setCurrentNode', 'setTime', 'this', 'thisown', 'time', 'timeStr']
+'runNextEvent', 'setCurrentNode', 'setTime', 'this', 'thisown', 'ticksPerSecond', 'time', 'timeStr']
         </pre>
 
         <p>The most common utility functions are:</p>
@@ -379,8 +395,8 @@ event message_t* Receive.receive(message_t* bufPtr, void* payload, uint8_t len)
         that the mote has booted. TOSSIM's debugging output can be
         configured on a per-channel basis. So, for example, you can
         tell TOSSIM to send the "Boot" channel to standard output, but
-        another channel, say "AM", to a file. Additionally, you can
-        configureBy default, a channel has no destination, and so
+        another channel, say "AM", to a file. 
+        By default, a channel has no destination, and so
         messages to it are discarded.</p>
 
         <p>In this case, we want to send the Boot channel to standard
@@ -518,33 +534,81 @@ DEBUG (32): Application booted a third time.
           <li><b><code>gain(src, dest)</code></b>: Return the gain value of the
           link from <i>src</i> to <i>dest</i>.</li>
           
-          <li><b><code>remove(src, dest)</code></b>: Remove the link from
-          <i>src</i> to <i>dest</i>.</li>
+          <li><b><code>threshold()</code></b>: Return the CCA threshold.</li>
 
+          <li><b><code>setThreshold(val)</code></b>: Set the CCA threshold value in
+            dBm. The default is -72dbM.</li>
+          
+        </ul>
 
-          <li><b><code>setNoise(node, mean, variance)</code></b>: Set the noise
-          floor at <i>node</i> to be a gaussian distribution with
-          <i>mean</i> and <i>variance</i>.</li>
+      <p>The default values for TOSSIM's radio model are based on the CC2420 radio,
+       used in the micaZ, telos family, and imote2. It uses an SNR curve derived
+       from experimental data collected using two micaZ nodes, RF shielding, and
+       a variable attenuator.</p>
+
+      <p>In addition to the radio propagation above, TOSSIM
+      also simulates the RF noise and interference a node hears, both from other
+      nodes as well as outside sources. It uses the Closest Pattern Matching (CPM)
+      algorithm. CPM takes a noise trace as input and generates a statistical model
+      from it. This model can capture bursts of interference and other correlated
+      phenomena, such that it greatly improves the quality of the RF simulation.
+       It is not perfect (there are several things it does not handle, such as
+       correlated interference at nodes that are close to one another), but
+       it is much better than traditional, independent packet loss models. For
+       more details, please refer to the paper "Improving Wireless Simulation through
+       Noise Modeling," by Lee et al.</p>
+      
 
-          <li><b><code>sensitivity()</code></b>: Return the receive sensitivity of
-            the nodes.</li>
+      <p>To configure CPM, you need to feed it a noise trace. You accomplish this
+       by calling <tt>addNoiseTraceReading</tt> on a Mote object. Once you
+       have fed the entire noise trace, you must call <tt>createNoiseModel</tt>
+       on the node. The directory <tt>tos/lib/tossim/noise</tt> contains
+       sample noise traces, which are a series of noise readings, one per line.
+       For example, these are the first 10 lines of meyer-heavy.txt,
+       which is a noise trace taken from Meyer Library at Stanford University:</p>
 
-          <li><b><code>setSensitivity(val)</code></b>: Set the receive sensitivity
-          of nodes to be <i>val</i>. The sensitivity is how much
-          stronger a signal must be for it to be received
-          uncorrupted. E.g., a sensitivity of 3.0 (the default value)
-          means that a packet must be 3dBm greater than the sum of
-          noise and concurrent transmissions for it to be received
-          uncorrupted.</li>
+      <pre>
+-39
+-98
+-98
+-98
+-99
+-98
+-94
+-98
+-98
+-98
+</pre>
 
-          <li><b><code>threshold()</code></b>: Return the CCA threshold.</li>
+      <p>As you can see, the hardware noise floor is around -98 dBm,
+       but there are spikes of interference around -86dBm and -87dBm.</p>
 
-          <li><b><code>setThreshold(val)</code></b>: Set the CCA threshold value in
-            dBm.The default is -95.</li>
-          
-        </ul>
+      <p>This piece of code will give a node a noise model from a noise trace
+       file. It works for nodes 0-7: you can change the range appropriately:</p>
+
+      <pre>
+noise = open("meyer-heavy.txt", "r")
+lines = noise.readlines()
+for line in lines:
+    str = line.strip()
+    if (str != ""):
+        val = int(str)
+        for i in range(0, 7):
+            t.getNode(i).addNoiseTraceReading(val)
+
+for i in range(0, 7):
+    t.getNode(i).createNoiseModel()</pre>
 
-        <p>The Radio object only deals with physical layer
+
+      <p>CPM can use a good deal of RAM: using the entire meyer-heavy
+      trace as input has a cost of approximately 10MB per node. You
+      can reduce this overhead by using a shorter trace; this will of
+      course reduce simulation fidelity. <u>The trace
+      must be at least 100 entries long, or CPM will not work as it does
+      not have enough data to generate a statistical model.</u> </p>
+
+      <p>You can also use 
+      <p>The Radio object only deals with physical layer
         propagation. The MAC object deals with the data link layer,
         packet lengths, and radio bandwidth. The default TOSSIM MAC
         object is for a CSMA protocol. You get a reference to the MAC
@@ -659,14 +723,23 @@ for line in lines:
 t.addChannel("RadioCountToLedsC", sys.stdout)
 t.addChannel("Boot", sys.stdout)
 
+noise = open("meyer-heavy.txt", "r")
+lines = noise.readlines()
+for line in lines:
+  str = line.strip()
+  if (str != ""):
+    val = int(str)
+    for i in range(1, 4):
+      t.getNode(i).addNoiseTraceReading(val)
+
+for i in range(1, 4):
+  print "Creating noise model for ",i;
+  t.getNode(i).createNoiseModel()
+
 t.getNode(1).bootAtTime(100001);
 t.getNode(2).bootAtTime(800008);
 t.getNode(3).bootAtTime(1800009);
 
-r.setNoise(1, -100.0, 5.0)
-r.setNoise(2, -100.0, 5.0)
-r.setNoise(3, -100.0, 5.0)
-
 for i in range(0, 100):
   t.runNextEvent()
         </pre>          
@@ -708,10 +781,9 @@ DEBUG (3): RadioCountToLedsC: packet sent.
 DEBUG (1): Received packet of length 2.
         </pre>
 
-        <p>If you set the noise to be 30 plus or minus 5 dBm instead
-        of 80 plus or minus 5 dBm, then nodes will never transmit, as
-        the default CCA threshold is -95 dBm. You'll see something
-        like this:</p>
+        <p>If you set node's clear channel assessment to be at -110dBm,
+       then nodes will never transmit, as noise and interference never
+       drop this low. You'll see something like this:</p>
              <pre>
 1  2 -54.0
 2  1 -55.0
@@ -760,29 +832,21 @@ while (time + 50000000000 > t.time()):
         topology. There are two approaches you can take. The first is
         to take data from a real world network and input this into
         TOSSIM. The second is to generate it from applying a
-        theoretical propagation model to a physical layout. TOSSIM has
-        an example of the first from the <A
-        HREF="https://mirage.berkeley.intel-research.net/">Mirage
-        testbed</A> at Intel Research Berkeley. The network topology
-        is from data gathered from one hundred micaZ nodes over an
-        eight hour period in February 2006. It can be found in <code><A
-        HREF="../../../tos/lib/tossim/topologies/mirage-1.txt">tos/lib/tossim/topologies/mirage-1.txt</A></code>, and has the following format:
+        theoretical propagation model to a physical layout.  The standard
+        file format is
 
           <pre>
-noise n avg std
 gain src dest g
           </pre>
 
-          where each statement is on a separate line. The <i>noise</i>
-          statement defines the noise observed at node <i>n</i> with
-          an average of <i>avg</i> and a standard deviation of
-          <i>std</i>.  The <i>gain</i> statement defines a propagation
+          where each statement is on a separate line.
+       The <i>gain</i> statement defines a propagation
           gain <i>g</i> when <i>src</i> transmits to <i>dest</i>. This
           is a snippet of python code that will parse this file
           format:
 
           <pre>
-f = open("mirage-1.txt", "r")
+f = open("15-15-tight-mica2-grid.txt", "r")
 
 lines = f.readlines()
 for line in lines:
@@ -790,8 +854,6 @@ for line in lines:
   if (len(s) > 0):
     if (s[0] == "gain"):
       r.add(int(s[1]), int(s[2]), float(s[3]))
-    elif (s[0] == "noise"):
-      r.setNoise(int(s[1]), float(s[2]), float(s[3]))
           </pre></p>
 
         <p>TOSSIM has a tool for the second option of generating a
@@ -807,18 +869,15 @@ java net.tinyos.sim.PropagationModel config.txt
 
         <p>The format of a configuration file is beyond the scope of
         this document: the tool has its own <A
-        HREF="">documentation</A>. TOSSIM has two sample configuration
+        HREF="usc-topologies.html">documentation</A>. TOSSIM has a few sample configuration
         files generated from the tool in
-        <code>tos/lib/tossim/topologies</code>. The first is <code><A
-        HREF="">grid.txt</A></code>, which is a 10x10 grid of nodes
-        spaced roughly 40 feet apart. Each node is placed randomly
-        within a 40'x40' "cell." The cells follow a strict grid. The
-        second file is <code><A HREF="">scatter.txt</A></code>, which is
-        100 nodes scattered randomly (with a uniform distribution)
-        over a 360'x360' area. Note that the tool uses random numbers,
+        <code>tos/lib/tossim/topologies</code>. 
+        Note that the tool uses random numbers,
         these configuration files can generate multiple different
         network topologies. Network topology files generated from the
-        tool follow the same format as <code>mirage-1.txt</code>.</p>
+        tool follow the same format as <code>15-15-tight-mica2-grid.txt</code>.
+        If you have topologies measured from real networks, we would love
+        to include them in the TOSSIM distribution.</p>
 
         <h1>Variables</h1>
 
@@ -835,7 +894,10 @@ java net.tinyos.sim.PropagationModel config.txt
         variables properly. You do this by instantiating a Python
         object that parses the XML file to extract all of the relevant
         information. You have to import the Python support package for
-        TOSSIM to do this:</p>
+        TOSSIM to do this. First, set your PYTHONPATH environment variable
+       to point to <tt>tinyos-2.x/support/sdk/python</tt>. This tells
+       Python where to find the TOSSIM packages. Then, in an interpreter
+       type this:</p>
 
         <pre>
 from tinyos.tossim.TossimApp import *
@@ -928,19 +990,29 @@ for line in lines:
   if (len(s) > 0):
     if (s[0] == "gain"):
       r.add(int(s[1]), int(s[2]), float(s[3]))
-    elif (s[0] == "noise"):
-      r.setNoise(int(s[1]), float(s[2]), float(s[3]))
 
-for i in range (0, 9):
-  m = t.getNode(i)
-  m.bootAtTime(randint(1000, 2000) * 1000000)
+noise = open("meyer-heavy.txt", "r")
+lines = noise.readlines()
+for line in lines:
+  str = line.strip()
+  if (str != ""):
+    val = int(str)
+    for i in range(0, 4):
+      t.getNode(i).addNoiseTraceReading(val)
+
+for i in range (0, 4):
+  t.getNode(i).createNoiseModel()
+  t.getNode(i).bootAtTime(i * 2351217 + 23542399)
 
 m = t.getNode(0)
 v = m.getVariable("RadioCountToLedsC.counter")
 
+
+
 while (v.getData() < 10):
   t.runNextEvent()
 
+print "Counter variable at node 0 reached 10."
         </pre>
 
       <p>The TOSSIM <A
@@ -1103,8 +1175,18 @@ for line in lines:
   if (len(s) > 0):
     if (s[0] == "gain"):
       r.add(int(s[1]), int(s[2]), float(s[3]))
-    elif (s[0] == "noise"):
-      r.setNoise(int(s[1]), float(s[2]), float(s[3]))
+
+noise = open("meyer-heavy.txt", "r")
+lines = noise.readlines()
+for line in lines:
+  str = line.strip()
+  if (str != ""):
+    val = int(str)
+    for i in range(0, 4):
+      t.getNode(i).addNoiseTraceReading(val)
+
+for i in range (0, 4):
+  t.getNode(i).createNoiseModel()
 
 for i in range(0, 60):
   t.runNextEvent();
@@ -1116,7 +1198,7 @@ pkt.setData(msg.data)
 pkt.setType(msg.get_amType())
 pkt.setDestination(0)
 
-print "Delivering " + msg.__str__() + " to 0 at " + str(t.time() + 3);
+print "Delivering " + str(msg) + " to 0 at " + str(t.time() + 3);
 pkt.deliver(0, t.time() + 3)
 
 
@@ -1159,7 +1241,8 @@ for i in range(0, 20):
       want to deliver a packet through C++, you can do so.</p>
 
       <p>Usually, the C++ and Python versions of a program look pretty
-      similar. For example:</p>
+      similar. For example (note that this program will use a lot of RAM
+         and take a long time to start due to its noise models):</p>
 
       <table WIDTH=800>
 
@@ -1170,6 +1253,7 @@ for i in range(0, 20):
             <PRE>
 import TOSSIM
 import sys
+import random
 
 from RadioCountMsg import *
 
@@ -1179,13 +1263,15 @@ r = t.radio();
 for i in range(0, 999):
   m = t.getNode(i);
   m.bootAtTime(5000003 * i + 1);
-  r.setNoise(i, -99.0, 3.0);
+  
   for j in range (0, 2):
     if (j != i):
       r.add(i, j, -50.0);
 
-
-
+  # Create random noise stream
+  for j in range (0, 500):
+    m.addNoiseTraceReading(int(random.random() * 20) - 70);
+  m.createNoiseModel()
 
 for i in range(0, 1000000):
   t.runNextEvent();
@@ -1194,7 +1280,7 @@ for i in range(0, 1000000):
           <TD VALIGN=TOP>
             <PRE>
 #include &lt;tossim.h&gt;
-
+#include &lt;stdlib.h&gt;
 
 
 int main() {
@@ -1204,14 +1290,18 @@ int main() {
   for (int i = 0; i &lt; 999; i++) {
     Mote* m = t->getNode(i);
     m->bootAtTime(5000003 * i + 1);
-    r->setNoise(i, -99.0, 3);
     for (int j = 0; j &lt; 2; j++) {
       if (i != j) {
         r->add(i, j, -50.0);
       }
     }
+    for (int j = 0; j &lt; 500; j++) {
+       m->addNoiseTraceReading((char)(drand48() * 20) - 70);
+    }
+    m->createNoiseModel();
   }
 
+
   for (int i = 0; i &lt; 1000000; i++) {
     t->runNextEvent();
   }
@@ -1232,7 +1322,7 @@ int main() {
 all:
         make micaz sim
         g++ -g -c -o Driver.o Driver.c -I../../tos/lib/tossim/
-        g++ -o Driver Driver.o build/micaz/tossim.o build/micaz/sim.o
+        g++ -o Driver Driver.o build/micaz/tossim.o build/micaz/sim.o build/micaz/c-support.o
       </pre>
         
 
@@ -1306,8 +1396,8 @@ $4 = 0
 <i>slow</i>:</p>
 
 <pre>
-(gdb) watch UscGainInterferenceModelC$receiving[23]
-Hardware watchpoint 2: UscGainInterferenceModelC$receiving[23]
+(gdb) watch CpmModelC$receiving[23]
+Hardware watchpoint 2: CpmModelC$receiving[23]
 </pre>
 
 <p>This variable happens to be an internal variable in the 
@@ -1356,9 +1446,239 @@ This lesson introduced the basics of the TOSSIM simulator. It showed
 you how to configure a network, how to run a simulation, how to
 inspect variables, how to inject packets, and how to compile with C++.
 
+<center>
+<p>&lt;&nbsp;<b><a href="lesson10.html">Previous Lesson</a></b> |&nbsp; <b><a
+ href="index.html">Top</a></b> &nbsp;|&nbsp; <b><a href="lesson12.html">Next
+Lesson </a>&nbsp;&gt;</b>
+             </center>
+</p>
+
+
+           <A name="appendix"><H1>Appendix A: Troubleshooting TOSSIM compilation</H1></A>
 
-<p><b><a href="lesson5.html">&lt; Previous Lesson</a></b> &nbsp;|&nbsp; <b><a
- href="index.html">Top</a></b>
+           <p>TOSSIM is a C/C++ shared library with an optional
+           Python translation layer. Almost all of the problems
+           encountered in compiling TOSSIM are due to C linking
+           issues. If you don't know what a linker is (or have never
+           linked a C program), then chances are the rest of this
+           appendix is going to be cryptic and
+           incomprehensible. You're best off starting with learning
+           about <A
+           HREF="http://en.wikipedia.org/wiki/Linker">linkers</A>, <A
+           HREF="http://www.iecc.com/linker/linker01.html">why they
+           are needed</A>, and how you <A
+           HREF="http://www.linuxjournal.com/article/6463">use the
+           gcc/g++ compilers</A> to link code.</p>
+               
+
+           <p>Generally, when compiling TOSSIM using <tt>make micaz sim</tt>,
+             one of four things can go wrong:</p>
+
+           <ol>
+             <li>You are using Cygwin but the <tt>sim</tt> compilation option
+               can't figure this out.</li>
+
+             <li>You do not have the needed Python support installed.</li>
+
+             <li>You have Python support installed, but the make
+             system can't find it.</li>
+
+             <li>You have Python support installed, but it turns out to
+               be incompatible with TOSSIM.</li>
+              
+              <li>You have a variant of gcc/g++ installed that 
+               expects slightly different compilation options than the
+               normal installation.</li>
+           </ol>
+
+           <p>We'll visit each in turn.</p>
+
+           <h2>You are using Cygwin but the <tt>sim</tt> compilation option
+             can't figure this out</h2>
+
+           <p>It turns out that the Cygwin and Linux versions of gcc/g++
+             have different command-line flags and require different options
+             to compile TOSSIM properly. For example, telling the Linux
+             compiler to build a library requires <tt>-fPIC</tt> while
+             the Cygwin is <tt>-fpic</tt>. If you're using Cygwin and
+             you see the output look like this:
+
+             <pre>
+  ncc -c -shared -fPIC -o build/micaz/sim.o ...
+             </pre>
+
+             rather than
+
+             <pre>
+  ncc -c -DUSE_DL_IMPORT -fpic -o build/micaz/sim.o ...
+             </pre>
+
+             then you have encountered this problem. The problem
+             occurs because Cygwin installations do not have a
+             consistent naming scheme, and so it's difficult for the
+             compilation toolchain to always figure out whether it's
+             under Linux or Cygwin.</p>
+
+           <p><b>Symptom:</b> You're running cygwin but you see the
+             <tt>-fPIC</tt> rather than <tt>-fpic</tt> option being
+             passed to the compiler.</b></p>
+           
+           <p><b>Solution:</b> Explicitly set the OSTYPE environment
+             variable to be <tt>cygwin</tt> either in your <tt>.bashrc</tt>
+             or when you compile. For example, in bash:</p>
+
+           <pre>
+$ OSTYPE=cygwin make micaz sim
+           </pre>
+
+           or in tcsh
+
+           <pre>
+$ setenv OSTYPE cygwin
+$ make micaz sim
+           </pre>
+
+           <p>Note that often this problem occurs in addition to
+           other ones, due to using a nonstandard Cygwin
+           installation. So you might have more problems to track
+           down.</p>
+           
+           <h2>You do not have the needed Python support installed</h2>
+
+           <p>If when you compile you see lots of errors such as
+           "undefined reference to" or "Python.h: No such file or
+           directory" then this might be your problem. It is a
+           subcase of the more general problem of TOSSIM not being
+           able to find needed libraries and files.</p>
+           
+           <p>Compiling Python scripting support requires that you
+             have certain Python development libraries installed. First, check
+             that you have Python installed:</p>
+
+           <pre>
+$ python -V
+Python 2.4.2
+           </pre>
+
+           <p>In the above example, the system has Python 2.4.2. If
+           you see "command not found" then you do not have Python
+           installed. You'll need to track down an RPM and install
+           it.  TOSSIM has been tested with Python versions 2.3 and
+           2.4. You can install other versions, but there's no
+           assurance things will work.</p>
+
+           <p>In addition to the Python interpreter itself, you need
+           the libraries and files for Python development. This is
+           essentially a set of header files and shared libraries. If
+           you have the <tt>locate</tt> command, you can type
+           <tt>locate libpython</tt>, or if you don't, you can look
+           in <tt>/lib</tt>, <tt>/usr/lib</tt> and
+           <tt>/usr/local/lib</tt>. You're looking for a file with a
+           name such as <tt>libpython2.4.so</tt> and a file named
+           <tt>Python.h</tt>. If you can't find these files, then you
+           need to install a <tt>python-devel</tt> package.</p>
+
+
+           <p><b>Symptom:</b> Compilation can't find critical files
+           such as the Python interpreter, <tt>Python.h</tt> or a
+           Python shared library, and searching your filesystem shows
+           that you don't have them.</p>
+
+           <p><b>Solution:</b> Installed the needed files from Python
+           and/or Python development RPMS.</p>
+
+           <p>If you have all of the needed files, but are still
+           getting errors such as "undefined reference" or "Python.h:
+           No such file or directory", then you have the next
+           problem: they're on your filesystem, but TOSSIM can't find
+           them.</p>
+             
+           <h2>You have Python support installed, but the make
+             system can't find it</h2>
+
+           <p>You've found libpython and Python.h, but when TOSSIM compiles
+           it says that it can't find one or both of them. If it can't
+           find Python.h then compilation will fail pretty early, as g++ won't
+           be able to compile the Python glue code. If it can't find the python
+           library, then compilation will fail at linking, and you'll see
+           errors along the lines of "undefined reference to __Py...". You
+           need to point the make system at the right place.</p>
+
+           <p>Open up <tt>support/make/sim.extra</tt>. If the make
+             system can't find Python.h, then chances are it isn't in
+             one of the standard places (e.g., /usr/include). You need to tell
+             the make system to look in the directory where Python.h is with
+             a <tt>-I</tt> option. At the top of sim.extra, under the PFLAGS entry,
+             add
+
+           <pre>
+CFLAGS += -I/path
+           </pre>
+
+             where <tt>/path</tt> is the path of the directory where Python.h
+             lives. For example, if it is in <tt>/opt/python/include</tt>,
+             then add <tt>CFLAGS += -I/opt/python/include</tt>.</p>
+           
+           <p>If the make system can't find the python library for
+           linking (causing "undefined reference") error messages,
+           then you need to make sure the make system can find
+           it. The sim.extra file uses two variables to find the
+           library: <tt>PYDIR</tt> and <tt>PYTHON_VERSION</tt>.  It
+           looks for a file named libpython$(PYTHON_VERSION).so. So
+           if you have Python 2.4 installed, make sure that
+           PYTHON_VERSION is 2.4 (be sure to use no spaces!) and if
+           2.3, make sure it is 2.3.</p>
+
+           <p>Usually the Python library is found in
+           <tt>/usr/lib</tt>. If it isn't there, then you will need
+           to modify the <tt>PLATFORM_LIB_FLAGS</tt> variable.  The
+           -L flag tells gcc in what directories to look for
+           libraries. So if libpython2.4.so is in
+           <tt>/opt/python/lib</tt>, then add
+           <tt>-L/opt/python/lib</tt> to the
+           <tt>PLATFORM_LIB_FLAGS</tt>. Note that there are three
+           different versions of this variable, depending on what OS
+           you're using. Be sure to modify the correct one (or be
+           paranoid and modify all three).
+
+             
+           <p><b>Symptom:</b> You've verified that you have the
+           needed Python files and libraries, but compilation is
+           still saying that it can't link to them ("undefined
+           reference") or can't find them ("cannot find -lpython2.4").</p>
+
+           <p><b>Solution:</b> Change the sim.extra file to point to
+           the correct directories using -L and -I flags.</p>
+
+           <h2>You have Python support installed, but it turns out to
+             be incompatible with TOSSIM.</h2>
+
+           <p><b>Symptom:</b> You get a "This python version requires
+             to use swig with the -classic option" error message.</p>
+
+           <p><b>Solution:</b> Install SWIG and regenerate Python
+           support with the sing-generate script in
+           <tt>tos/lib/tossim</tt>, or install a different version of
+           Python.</p>
+           
+              <h2>You have a variant of gcc/g++ installed that 
+               expects slightly different compilation options than the
+               normal installation.</h2>
+
+               <p><b>Symptom:</b> g++ complains that it cannot find
+                main() when you are compiling the shared library
+                ("undefined reference to `_WinMain@16'").</p>
+
+                <p><b>Solution:</b> There are two possible solutions.
+                The first is to include a dummy main(), as described
+                 in this <A HREF="http://mail.millennium.berkeley.edu/pipermail/tinyos-help/2006-December/021719.html">tinyos-help posting.</A> The
+                 second is to add the -shared option, as described in
+                 this <A HREF="http://curl.haxx.se/mail/archive-2003-01/0056.html">web page</A>.
+                 
+                 <p>Hopefully, these solutions worked and you can get back
+           to <A HREF="#compiling">compiling</A>, If not, then you
+               should email tinyos-help.</p>
+</center>
 
 </body>
 </html>