--- /dev/null
+COMPONENT=TestCommAppC
+
+include $(MAKERULES)
+
--- /dev/null
+// $Id$
+
+/* tab:4
+ * "Copyright (c) 2000-2005 The Regents of the University of California.
+ * All rights reserved.
+ *
+ * Permission to use, copy, modify, and distribute this software and its
+ * documentation for any purpose, without fee, and without written agreement is
+ * hereby granted, provided that the above copyright notice, the following
+ * two paragraphs and the author appear in all copies of this software.
+ *
+ * IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY FOR
+ * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT
+ * OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF THE UNIVERSITY OF
+ * CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
+ * AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS
+ * ON AN "AS IS" BASIS, AND THE UNIVERSITY OF CALIFORNIA HAS NO OBLIGATION TO
+ * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS."
+ *
+ * Copyright (c) 2002-2005 Intel Corporation
+ * All rights reserved.
+ *
+ * This file is distributed under the terms in the attached INTEL-LICENSE
+ * file. If you do not find these files, copies can be found by writing to
+ * Intel Research Berkeley, 2150 Shattuck Avenue, Suite 1300, Berkeley, CA,
+ * 94704. Attention: Intel License Inquiry.
+ */
+
+/**
+ * This application sends a single active message broadcast if it has
+ * address 0, and then starts a timer at 1Hz. If it has any address
+ * other than 0, it starts a timer at 1 Hz upon receiving a broadcast
+ * message. The idea is to have one base station with address 0 send
+ * out a broadacst message to synchronize itself with all receivers.
+ * All Leds from the base station and any receivers of the broadcast
+ * should blink together.
+
+ * It uses the radio HIL component
+ * <tt>ActiveMessageC</tt>, and its packets are AM type 240.
+ *
+ * @author Phil Levis
+ * @author Kevin Klues
+ * @date Nov 7 2005
+ */
+
+configuration TestCommAppC {}
+implementation {
+ enum {
+ AM_TEST = 5
+ };
+
+ components MainC, TestCommC as App, RandomC, ActiveMessageC;
+ components new TimerMilliC(), new AMSenderC(AM_TEST), new AMReceiverC(AM_TEST);
+
+ App.Boot -> MainC.Boot;
+ App.SplitControl -> ActiveMessageC;
+ App.Timer -> TimerMilliC;
+ App.AMSend -> AMSenderC;
+ App.Receive -> AMReceiverC;
+ App.Random -> RandomC;
+ App.AMPacket -> AMSenderC;
+ App.PacketAcknowledgements -> AMSenderC;
+}
+
+
--- /dev/null
+// $Id$
+
+/* tab:4
+ * "Copyright (c) 2000-2005 The Regents of the University of California.
+ * All rights reserved.
+ *
+ * Permission to use, copy, modify, and distribute this software and its
+ * documentation for any purpose, without fee, and without written agreement is
+ * hereby granted, provided that the above copyright notice, the following
+ * two paragraphs and the author appear in all copies of this software.
+ *
+ * IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY FOR
+ * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT
+ * OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF THE UNIVERSITY OF
+ * CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
+ * AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS
+ * ON AN "AS IS" BASIS, AND THE UNIVERSITY OF CALIFORNIA HAS NO OBLIGATION TO
+ * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS."
+ *
+ * Copyright (c) 2002-2003 Intel Corporation
+ * All rights reserved.
+ *
+ * This file is distributed under the terms in the attached INTEL-LICENSE
+ * file. If you do not find these files, copies can be found by writing to
+ * Intel Research Berkeley, 2150 Shattuck Avenue, Suite 1300, Berkeley, CA,
+ * 94704. Attention: Intel License Inquiry.
+ */
+
+/**
+ * Implementation of the TestTimer application.
+ *
+ * @author Phil Levis
+ * @date April 7 2007
+ *
+ **/
+
+module TestCommC {
+ uses {
+ interface Boot;
+ interface Timer<TMilli> as Timer;
+ interface Receive;
+ interface AMSend;
+ interface Random;
+ interface SplitControl;
+ interface AMPacket;
+ interface PacketAcknowledgements;
+ }
+}
+implementation {
+
+ message_t packet;
+ uint8_t busy;
+
+ event void Boot.booted() {
+ call SplitControl.start();
+ }
+
+ event void SplitControl.startDone(error_t e) {
+ if (TOS_NODE_ID == 1 ||
+ TOS_NODE_ID == 3) {
+ call Timer.startPeriodic(128);
+ }
+ }
+
+ event void SplitControl.stopDone(error_t e) {
+
+ }
+
+ event void Timer.fired() {
+ if (!busy) {
+ call PacketAcknowledgements.requestAck(&packet);
+ if (call AMSend.send(2, &packet, call AMSend.maxPayloadLength()) == SUCCESS) {
+ dbg("TestComm", "Send succeeded @ %s\n", sim_time_string());
+ busy = TRUE;
+ }
+ else {
+ dbg("TestComm", "Send failed at @ %s\n", sim_time_string());
+ }
+ }
+ else {
+ dbg("TestComm", "Send when busy at @ %s\n", sim_time_string());
+ }
+ }
+
+ event void AMSend.sendDone(message_t* m, error_t s) {
+ dbg("TestComm", "Send completed with %s @ %s\n", call PacketAcknowledgements.wasAcked(m)? "ACK":"NOACK", sim_time_string());
+ busy = FALSE;
+ }
+
+
+ event message_t* Receive.receive(message_t* msg, void* p, uint8_t l) {
+ dbg("TestComm", "Received message from %hu @ %s\n", call AMPacket.source(msg), sim_time_string());
+ return msg;
+ }
+}
+
+
+
+
--- /dev/null
+-41
+-41
+-41
+-41
+-41
+-41
+-41
+-91
+-41
+-41
+-41
+-41
+-41
+-48
+-41
+-41
+-41
+-83
+-98
+-80
+-80
+-79
+-79
+-79
+-79
+-98
+-79
+-80
+-79
+-80
+-80
+-80
+-83
+-83
+-83
+-83
+-82
+-82
+-41
+-82
+-82
+-82
+-82
+-82
+-82
+-41
+-94
+-93
+-93
+-87
+-89
+-90
+-45
+-92
+-85
+-98
+-80
+-80
+-79
+-78
+-79
+-79
+-79
+-97
+-94
+-83
+-81
+-80
+-82
+-81
+-81
+-84
+-84
+-86
+-98
+-89
+-79
+-79
+-79
+-79
+-79
+-79
+-57
+-79
+-79
+-79
+-79
+-79
+-79
+-79
+-41
+-84
+-96
+-97
+-79
+-90
+-98
+-79
+-79
+-79
+-79
+-79
+-79
+-92
+-83
+-83
+-82
+-81
+-83
+-80
+-85
+-82
+-81
+-82
+-82
+-82
+-82
+-41
+-82
+-82
+-82
+-82
+-82
+-82
+-83
+-82
+-82
+-82
+-82
+-82
+-98
+-98
+-79
+-79
+-79
+-79
+-79
+-78
+-97
+-91
+-96
+-91
+-82
+-82
+-82
+-82
+-82
+-82
+-77
+-82
+-82
+-82
+-82
+-82
+-82
+-98
+-79
+-79
+-79
+-79
+-79
+-79
+-94
+-98
+-96
+-81
+-82
+-82
+-82
+-82
+-82
+-91
+-91
+-93
+-91
+-91
+-91
+-91
+-93
+-91
+-91
+-91
+-91
+-91
+-92
+-91
+-91
+-87
+-84
+-79
+-79
+-79
+-79
+-79
+-78
+-94
+-79
+-79
+-79
+-79
+-80
+-79
+-94
+-98
+-82
+-83
+-82
+-82
+-83
+-83
+-82
+-41
+-81
+-98
+-98
+-98
+-86
+-82
+-99
+-82
+-82
+-82
+-82
+-82
+-82
+-82
+-82
+-82
+-81
+-82
+-82
+-90
+-79
+-79
+-79
+-78
+-78
+-79
+-79
+-79
+-78
+-79
+-79
+-79
+-98
+-82
+-81
+-82
+-82
+-82
+-82
+-82
+-82
+-82
+-82
+-81
+-81
+-81
+-90
+-82
+-81
+-82
+-82
+-81
+-81
+-82
+-82
+-82
+-80
+-82
+-81
+-81
+-81
+-42
+-61
+-96
+-82
+-82
+-82
+-82
+-82
+-82
+-82
+-82
+-82
+-82
+-82
+-82
+-82
+-98
+-98
+-98
+-98
+-98
+-41
+-41
+-98
+-99
+-84
+-98
+-41
+-98
+-98
+-98
+-85
+-98
+-96
+-96
+-91
+-87
+-98
+-96
+-99
+-98
+-90
+-88
+-86
+-88
+-96
+-91
+-82
+-82
+-82
+-82
+-82
+-82
+-82
+-82
+-82
+-82
+-82
+-84
+-93
+-79
+-79
+-79
+-79
+-79
+-79
+-79
+-79
+-79
+-79
+-79
+-79
+-80
+-80
+-80
+-79
+-80
+-80
+-80
+-80
+-79
+-79
+-80
+-80
+-73
+-80
+-80
+-80
+-79
+-78
+-80
+-80
+-80
+-80
+-80
+-79
+-80
+-74
+-40
+-40
+-91
+-40
+-40
+-79
+-79
+-79
+-79
+-79
+-79
+-79
+-79
+-79
+-79
+-91
+-91
+-90
+-97
+-40
+-40
+-91
+-91
+-40
+-40
+-82
+-82
+-82
+-82
+-82
+-82
+-82
+-82
+-82
+-83
+-82
+-96
+-79
+-80
+-80
+-80
+-80
+-80
+-80
+-80
+-80
+-79
+-80
+-80
+-80
+-41
+-40
+-40
+-40
+-98
+-80
+-79
+-79
+-79
+-79
+-80
+-80
+-80
+-80
+-79
+-80
+-79
+-40
+-40
+-40
+-79
+-79
+-79
+-79
+-79
+-79
+-79
+-79
+-80
+-80
+-80
+-79
+-92
+-83
+-82
+-83
+-82
+-82
+-82
+-83
+-82
+-81
+-82
+-82
+-82
+-90
+-92
+-82
+-82
+-83
+-83
+-83
+-83
+-83
+-82
+-82
+-83
+-83
+-82
+-42
+-40
+-40
+-70
+-82
+-68
+-80
+-79
+-80
+-79
+-80
+-78
+-80
+-80
+-80
+-96
+-80
+-79
+-80
+-80
+-80
+-80
+-79
+-80
+-80
+-80
+-80
+-80
+-60
+-79
+-80
+-80
+-80
+-80
+-80
+-80
+-80
+-80
+-79
+-80
+-80
+-99
+-80
+-80
+-80
+-80
+-80
+-79
+-80
+-80
+-80
+-79
+-80
+-80
+-99
+-84
+-83
+-83
+-83
+-84
+-83
+-83
+-83
+-84
+-84
+-84
+-84
+-84
+-48
+-79
+-80
+-80
+-80
+-80
+-79
+-80
+-79
+-80
+-80
+-79
+-80
+-91
+-91
+-91
+-92
+-91
+-92
+-94
+-79
+-80
+-80
+-80
+-80
+-80
+-80
+-80
+-80
+-80
+-80
+-80
+-80
+-98
+-80
+-80
+-80
+-80
+-80
+-80
+-80
+-80
+-80
+-80
+-80
+-80
+-58
+-99
+-98
+-84
+-84
+-84
+-84
+-84
+-84
+-84
+-84
+-84
+-84
+-84
+-84
+-83
+-98
+-80
+-92
+-92
+-87
+-98
+-98
+-86
+-98
+-98
+-95
+-98
+-97
+-99
+-97
+-41
+-72
+-87
+-84
+-84
+-83
+-82
+-84
+-78
+-78
+-79
+-79
+-79
+-83
+-85
+-94
+-83
+-86
+-87
+-96
+-84
+-86
+-88
+-98
+-96
+-95
+-85
+-90
+-98
+-98
+-98
+-80
+-80
+-95
+-98
+-98
+-96
+-98
+-98
+-80
+-99
+-96
+-80
+-98
+-96
+-94
+-98
+-96
+-99
+-80
+-80
+-80
+-80
+-80
+-45
+-80
+-91
+-80
+-80
+-80
+-82
+-80
+-80
+-80
+-80
+-80
+-80
+-80
+-80
+-80
+-80
+-80
+-80
+-41
+-40
+-80
+-80
+-80
+-80
+-80
+-80
+-80
+-80
+-80
+-80
+-80
+-80
+-91
+-40
+-97
+-84
+-84
+-84
+-84
+-84
+-84
+-84
+-85
+-84
+-81
+-84
+-85
+-97
+-85
+-85
+-86
+-85
+-85
+-82
+-85
+-85
+-85
+-85
+-85
+-85
+-87
+-86
+-85
+-86
+-86
+-85
+-84
+-86
+-84
+-85
+-86
+-86
+-70
+-86
+-86
+-86
+-86
+-86
+-86
+-86
+-86
+-86
+-86
+-86
+-86
+-41
+-94
+-41
+-40
+-97
+-80
+-40
+-91
+-98
+-80
+-80
+-80
+-80
+-80
+-80
+-80
+-80
+-80
+-80
+-80
+-80
+-93
+-40
+-93
+-93
+-40
+-40
+-93
+-93
+-98
+-80
+-80
+-80
+-80
+-80
+-80
+-80
+-81
+-80
+-80
+-80
+-80
+-80
+-80
+-79
+-80
+-80
+-80
+-80
+-80
+-80
+-80
+-80
+-80
+-98
+-40
+-40
+-93
+-85
+-85
+-82
+-82
+-83
+-86
+-85
+-86
+-84
+-85
+-82
+-83
+-84
+-85
+-40
+-40
+-78
+-40
+-98
+-98
+-98
+-99
+-41
+-80
+-80
+-78
+-81
+-79
+-81
+-81
+-79
+-81
+-81
+-81
+-81
+-96
+-98
+-80
+-93
+-80
+-96
+-98
+-98
+-80
+-80
+-80
+-80
+-80
+-80
+-80
+-81
+-81
+-80
+-80
+-80
+-98
+-80
+-80
+-81
+-80
+-80
+-80
+-80
+-80
+-80
+-81
+-80
+-80
+-99
+-90
+-84
+-82
+-86
+-85
+-85
+-85
+-85
+-86
+-86
+-85
+-86
+-86
+-98
+-96
+-96
+-80
+-80
+-80
+-80
+-80
+-80
+-80
+-80
+-80
+-80
+-80
+-80
+-80
+-80
+-80
+-80
+-80
+-80
+-80
+-80
+-80
+-80
+-79
+-81
+-80
+-48
+-90
+-89
+-79
+-93
+-91
+-95
+-80
+-80
+-80
+-80
+-80
+-80
+-80
+-80
+-80
+-80
+-80
+-80
+-80
+-98
+-95
+-98
+-80
+-80
+-80
+-80
+-80
+-80
+-80
+-80
+-80
+-80
+-80
+-80
+-80
+-80
+-80
+-80
+-41
+-80
+-80
+-80
+-80
+-80
+-80
+-80
+-80
+-80
+-80
+-80
+-80
+-96
+-98
+-98
+-99
+-71
+-98
+-98
+-99
+-98
+-98
+-98
+-98
+-98
+
+
--- /dev/null
+from TOSSIM import *
+import sys
+import time
+
+t = Tossim([])
+r = t.radio();
+
+t.addChannel("TestComm", sys.stdout)
+t.addChannel("SNRLoss", sys.stdout)
+
+#t.addChannel("Acks", sys.stdout)
+#t.addChannel("Gain", sys.stdout)
+#t.addChannel("CpmModelC", sys.stdout)
+#t.addChannel("AM", sys.stdout)
+
+
+start = time.time();
+m1 = t.getNode(1)
+m2 = t.getNode(2)
+m3 = t.getNode(3)
+
+# Set up a hidden terminal problem, where 1 and 3
+# are closely synchronized, but cannot hear each other.
+m1.bootAtTime(345321);
+m2.bootAtTime(82123411);
+m3.bootAtTime(345325);
+r.add(1, 2, -60.0);
+r.add(2, 1, -60.0);
+r.add(2, 3, -60.0);
+r.add(3, 2, -60.0);
+
+noise = open("meyer-short.txt", "r")
+lines = noise.readlines()
+for line in lines:
+ str = line.strip()
+ if (str != ""):
+ val = int(str)
+ m1.addNoiseTraceReading(val)
+ m2.addNoiseTraceReading(val)
+ m3.addNoiseTraceReading(val)
+
+m1.createNoiseModel()
+m2.createNoiseModel()
+m3.createNoiseModel()
+
+for i in range(0, 1000000):
+ t.runNextEvent();
+
+
--- /dev/null
+from TOSSIM import *
+import sys
+import time
+
+t = Tossim([])
+r = t.radio();
+
+t.addChannel("TestComm", sys.stdout)
+t.addChannel("SNRLoss", sys.stdout)
+#t.addChannel("Acks", sys.stdout)
+#t.addChannel("Gain", sys.stdout)
+#t.addChannel("CpmModelC", sys.stdout)
+#t.addChannel("AM", sys.stdout)
+
+
+start = time.time();
+m1 = t.getNode(1)
+m2 = t.getNode(2)
+m3 = t.getNode(3)
+
+# Set up a hidden terminal problem, where 1 and 3
+# are closely synchronized, but cannot hear each other.
+m1.bootAtTime(345321);
+m2.bootAtTime(82123411);
+m3.bootAtTime(345325);
+r.add(1, 2, -50.0);
+r.add(2, 1, -50.0);
+r.add(2, 3, -60.0);
+r.add(3, 2, -60.0);
+
+noise = open("meyer-short.txt", "r")
+lines = noise.readlines()
+for line in lines:
+ str = line.strip()
+ if (str != ""):
+ val = int(str)
+ m1.addNoiseTraceReading(val)
+ m2.addNoiseTraceReading(val)
+ m3.addNoiseTraceReading(val)
+
+m1.createNoiseModel()
+m2.createNoiseModel()
+m3.createNoiseModel()
+
+for i in range(0, 1000000):
+ t.runNextEvent();
+
+