Index: vtcross/trunk/src/main_test.c
===================================================================
--- vtcross/trunk/src/main_test.c	(revision 12)
+++ vtcross/trunk/src/main_test.c	(revision 12)
@@ -0,0 +1,89 @@
+//
+// Cognitive radio simulator
+//
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <math.h>
+#include <sigprocc/sigprocc.h>
+#include "cognitive_radio_test.h"
+
+// options
+#define PACKET_SIZE 1024    // packet size (number of bits)
+#define NUM_TRIALS 250      // number of epochs
+#define REPORT_TRIALS 10    // print report every so often
+
+int main() {
+    // bookkeeping variables and buffers
+    unsigned int num_bits=PACKET_SIZE;
+    char msg_in[num_bits], msg_out[num_bits];
+    float I[num_bits], Q[num_bits];
+    unsigned int num_symbols, num_bits_out;
+
+    float noise_psd = -100.0f; // noise power spectral density
+    float noise_power, noise_std;
+    
+    // quality of service metrics
+    unsigned int num_bit_errors;
+    float throughput_bps;
+
+    // metadata defaults
+    struct metadata_t mdt;
+    metadata md = &mdt;
+
+    md->mod_scheme = MOD_QAM;   // MOD_PSK, MOD_QAM, MOD_PAM, MOD_DPSK
+    md->mod_bps = 4;            // modulation scheme [bits/s]
+    md->tx_power_dBW = -3.0f;   // transmit power [dBW]
+    md->symbol_rate = 250e3f;   // symbol rate [symbols/s]
+
+    unsigned int i;
+    // generate random message
+    for (i=0; i<num_bits; i++)
+        msg_in[i] = (char) (rand() % 2);
+
+    printf("epoch\tutility\n");
+    printf("-----\t-------\n");
+    for (i=0; i<NUM_TRIALS; i++) {
+        // compute internals
+        noise_power = noise_psd + 20*log10f(md->symbol_rate);
+        noise_std = powf(10.0f, (noise_power - md->tx_power_dBW) / 10.0f) / 2.0f;
+
+        // execute transmitter
+        execute_tx(md, msg_in, num_bits, I, Q, &num_symbols);
+
+        // execute channel
+        execute_channel(md, noise_std, I, Q, num_symbols);
+
+        // execute receiver
+        execute_rx(md, I, Q, num_symbols, msg_out, &num_bits_out);
+
+        //
+        // *** compute quality of service metrics ***
+        //
+
+        // count errors, etc.
+        num_bit_errors = count_errors(msg_in, msg_out, num_bits);
+        throughput_bps = ((float)(md->mod_bps)) * md->symbol_rate;
+
+        if ( ((i+1)%REPORT_TRIALS)==0 || (i+1)==NUM_TRIALS) {
+            // print results
+            printf("%u\t%.2f\terrors:\t%u\t/ %u, power: %.1f dBW, Fs: %.3f kHz\n",
+                    i+1, 0.0f, num_bit_errors, num_bits, md->tx_power_dBW, md->symbol_rate/1e3 );
+        }
+
+        // 
+        // *** execute cognition here ***
+        //
+
+        // simple power adaptation
+        if (num_bit_errors > 30) {
+            md->tx_power_dBW += 0.1f;
+        } else {
+            md->tx_power_dBW -= 0.1f;
+        }
+
+    }
+
+    printf("done.\n");
+    return 0;
+}
Index: vtcross/trunk/src/cognitive_radio_test.c
===================================================================
--- vtcross/trunk/src/cognitive_radio_test.c	(revision 12)
+++ vtcross/trunk/src/cognitive_radio_test.c	(revision 12)
@@ -0,0 +1,94 @@
+//
+// Cognitive radio simulator
+//
+
+#include "cognitive_radio_test.h"
+
+// transmitter thread
+void execute_tx(
+        metadata _md,
+        char *_msg_in,
+        unsigned int _msg_len,
+        float * _I,
+        float *_Q,
+        unsigned int *_sym_len)
+{
+    // symbols buffer
+    char sym[_msg_len];
+
+    // pack bits into symbols
+    repack_bytes(
+        _msg_in,        // input buffer
+        1,              // input symbol size (number bits)
+        _msg_len,       // input buffer size
+        sym,            // output buffer
+        _md->mod_bps,   // output symbol size (number of bits)
+        _msg_len,       // output buffer size
+        _sym_len        // number of symbols written to output
+        );
+
+    // run modulator
+    unsigned int i, s;
+    modem * mod = modem_create(_md->mod_scheme, _md->mod_bps);
+    for (i=0; i<(*_sym_len); i++) {
+        s = (unsigned int)(sym[i]);
+        modulate(mod, s, &_I[i], &_Q[i]);
+    }
+}
+
+// channel thread
+void execute_channel(metadata _md, float _std, float * _I, float *_Q, unsigned int _len)
+{
+    // add noise
+    float noise_i, noise_q;
+    unsigned int i;
+    for (i=0; i<_len; i++) {
+        // generate random noise values
+        randnf(&noise_i, &noise_q);
+
+        // TODO scale by appropriate amount
+        _I[i] += noise_i * _std;
+        _Q[i] += noise_q * _std;
+    }
+}
+
+// receiver thread
+void execute_rx(
+        metadata _md,
+        float * _I,
+        float *_Q,
+        unsigned int _sym_len,
+        char *_msg_out,
+        unsigned int *_msg_len)
+{
+    char msg[_sym_len];
+
+    // create demodulator and demodulate
+    modem * demod = modem_create(_md->mod_scheme, _md->mod_bps);
+    unsigned int i, s;
+    for (i=0; i<_sym_len; i++) {
+        demodulate(demod, _I[i], _Q[i], &s);
+        msg[i] = (char) s;
+    }
+
+    // unpack bytes
+    repack_bytes(
+        msg,            // input buffer
+        _md->mod_bps,   // input symbol size (number of bits)
+        _sym_len,       // num input symbols
+        _msg_out,       // output buffer
+        1,              // output symbol size (number of bits)
+        999999,         // output buffer size
+        _msg_len        // number of output symbols written
+        );
+
+}
+
+unsigned int count_errors(char * _msg_in, char * _msg_out, unsigned int _num_bits)
+{
+    unsigned int i, num_errors=0;
+    for (i=0; i<_num_bits; i++)
+        num_errors += (_msg_in[i]==_msg_out[i]) ? 0 : 1;
+
+    return num_errors;
+}
Index: vtcross/trunk/src/cognitive_radio_test.h
===================================================================
--- vtcross/trunk/src/cognitive_radio_test.h	(revision 12)
+++ vtcross/trunk/src/cognitive_radio_test.h	(revision 12)
@@ -0,0 +1,48 @@
+//
+// Cognitive radio simulator
+//
+
+#ifndef __COGNITIVE_RADIO_TEST_H__
+#define __COGNITIVE_RADIO_TEST_H__
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <math.h>
+#include <sigprocc/sigprocc.h>
+
+typedef struct metadata_t * metadata;
+
+// transmitter thread
+void execute_tx(
+        metadata _md,
+        char *_msg_in,
+        unsigned int _msg_len,
+        float * _I,
+        float *_Q,
+        unsigned int *_sym_len);
+
+// channel thread
+void execute_channel(metadata _md, float _std, float * _I, float *_Q, unsigned int _len);
+
+// receiver thread
+void execute_rx(
+        metadata _md,
+        float * _I,
+        float *_Q,
+        unsigned int _sym_len,
+        char *_msg_out,
+        unsigned int *_msg_len);
+
+// count bit errors
+unsigned int count_errors(char * _msg_in, char * _msg_out, unsigned int _num_bits);
+
+struct metadata_t {
+    modulation_scheme mod_scheme;
+    unsigned int mod_bps;
+    float tx_power_dBW;
+    //unsigned int packet_size;
+    float symbol_rate;
+};
+
+
+#endif // __COGNITIVE_RADIO_TEST_H__
Index: vtcross/trunk/Makefile
===================================================================
--- vtcross/trunk/Makefile	(revision 12)
+++ vtcross/trunk/Makefile	(revision 12)
@@ -0,0 +1,18 @@
+# 
+# Cognitive radio simulator
+#
+
+all: cognitive_radio_test
+
+main_test.o: src/main_test.c
+	gcc -c src/main_test.c -Wall -o main_test.o
+
+cognitive_radio_test.o: src/cognitive_radio_test.c
+	gcc -c src/cognitive_radio_test.c -Wall -o cognitive_radio_test.o
+
+cognitive_radio_test: cognitive_radio_test.o main_test.o
+	gcc cognitive_radio_test.o main_test.o -Wall -lm -lsigprocc -o cognitive_radio_test
+
+clean:
+	rm -rf *.o *_test
+
Index: vtcross/trunk/README
===================================================================
--- vtcross/trunk/README	(revision 12)
+++ vtcross/trunk/README	(revision 12)
@@ -0,0 +1,41 @@
+# 
+# Cognitive Radio Simulation Program
+# 
+
+Compile and run:
+
+ $ make
+ $ ./cognitive_radio_test
+
+To change adaption algorithm, scroll down to line including
+*** execute cognition here *** and add your source code.
+
+# Dependencies
+
+This package relies on a DSP library on the OSSIE repo that you will
+need to download, compile, and install.  To download from the
+repository, execute
+ $ svn co https://ossie.wireless.vt.edu/repos/ossie/people/jgaeddert/sigprocc/tags/sigprocc-0.7.0
+
+Compile and install
+ $ ./reconf
+ $ ./configure
+ $ make
+ $ sudo make install
+
+If this is your first time installing sigprocc, yo uwill need to run
+ $ sudo /sbin/ldconfig
+
+To ensure that the library run properly, run the autotests.  NOTE: you
+will need cxxtest [http://cxxtest.sourceforge.net] to do this.
+ $ make check
+
+If everything works properly, you should see
+PASS: autotest
+==================
+All 1 tests passed
+==================
+
+Additionally you can benchmark the code on your machine by executing
+ $ make bench
+
