diff --git a/document/hardware-12_routers.jpg b/document/hardware-12_routers.jpg new file mode 100644 index 0000000000000000000000000000000000000000..60afe5f659f818bb53880996db869e0810307ef8 Binary files /dev/null and b/document/hardware-12_routers.jpg differ diff --git a/document/hardware-12_routers_tmp11945 b/document/hardware-12_routers_tmp11945 new file mode 100644 index 0000000000000000000000000000000000000000..60afe5f659f818bb53880996db869e0810307ef8 Binary files /dev/null and b/document/hardware-12_routers_tmp11945 differ diff --git a/document/hardware-12_routers_tmp242 b/document/hardware-12_routers_tmp242 new file mode 100644 index 0000000000000000000000000000000000000000..49bd3e2aa8b74709a732b84831d66f5f7fac5ebf Binary files /dev/null and b/document/hardware-12_routers_tmp242 differ diff --git a/embedded/README.md b/embedded/README.md index a8f79c072fb5d66f396e44f0d3539cb4161638df..b2147fed52f7aff982bac8b5d4117ed0c58050ee 100644 --- a/embedded/README.md +++ b/embedded/README.md @@ -1,7 +1,11 @@ # 'API' -// how to do big packet pushing? how to verify? -// start writing now +Send Packet on Every Ack - window 1, write this. + +Also, every Ack, write to pin. + +Then say, if button has been pushed, + // better app layer - and make sure to clear space? # Results diff --git a/embedded/atsams70-tinyrouter/atsams70-tinyrouter/src/application.c b/embedded/atsams70-tinyrouter/atsams70-tinyrouter/src/application.c index ca790042879188a248843b85bbf8766d88557fe6..b8e85419b84c92fa060e077ffd08d40a8488e680 100644 --- a/embedded/atsams70-tinyrouter/atsams70-tinyrouter/src/application.c +++ b/embedded/atsams70-tinyrouter/atsams70-tinyrouter/src/application.c @@ -6,7 +6,6 @@ */ #include "application.h" -#include "ports.h" void app_onpacket(packet_t p){ switch (p.raw[5]){ // key: @@ -24,6 +23,12 @@ void app_onpacket(packet_t p){ pin_set(&stlb); } break; + case 3: + if(p.raw[6] == 1){ + window = 0; // should kick off cycle + } else { + window = 2; // should stop cycle + } default: pin_set(&stlb); pin_set(&stlr); @@ -32,5 +37,7 @@ void app_onpacket(packet_t p){ } void app_onack(packet_t p){ - // windows? + pin_set(&tstpckt); + window --;// + pin_clear(&tstpckt); } \ No newline at end of file diff --git a/embedded/atsams70-tinyrouter/atsams70-tinyrouter/src/application.h b/embedded/atsams70-tinyrouter/atsams70-tinyrouter/src/application.h index a8efb21df8b0eea31f7ebc9df3722a43758886cf..d29539c552657d58b32f0128698cb1d8c629c065 100644 --- a/embedded/atsams70-tinyrouter/atsams70-tinyrouter/src/application.h +++ b/embedded/atsams70-tinyrouter/atsams70-tinyrouter/src/application.h @@ -10,6 +10,8 @@ #define APPLICATION_H_ #include "packet.h" +#include "ports.h" +#include "node.h" void app_onpacket(packet_t p); diff --git a/embedded/atsams70-tinyrouter/atsams70-tinyrouter/src/main.c b/embedded/atsams70-tinyrouter/atsams70-tinyrouter/src/main.c index a85d612eb3ea110e286190475aeb5ff18a82e983..bb3cd35bfd0e95cd6eb357e4e9d5e975cce66115 100644 --- a/embedded/atsams70-tinyrouter/atsams70-tinyrouter/src/main.c +++ b/embedded/atsams70-tinyrouter/atsams70-tinyrouter/src/main.c @@ -234,9 +234,20 @@ int main (void){ } packet_t packetlooper = packet_new(); + packet_t packetsend = packet_new(); uint32_t beatTicker = 0; uint32_t packetTicker = 0; + + window = 2; + + packetsend.raw[0] = P_STANDARD; + packetsend.raw[1] = 12; // destination + packetsend.raw[2] = 0; // hops + packetsend.raw[3] = 1; // source + packetsend.raw[4] = 7; // # bytes + packetsend.raw[5] = 1; + packetsend.raw[6] = 1; while(1){ pin_set(&tstclk); @@ -257,6 +268,18 @@ int main (void){ } } + #if IS_HOME_PORT + if(window < 2){ + window ++; + if (in_table(packetsend.raw[1])) { + send_on_bestport(&packetsend); + } else { + packetsend.raw[0] = P_STANDARD_FLOOD; + broadcast_packet(&packetsend, 4); + } + } + #endif + pin_clear(&tstclk); /* if(!(packetTicker % HEARTBEAT_PERPACKET_MODULO)){ diff --git a/embedded/atsams70-tinyrouter/atsams70-tinyrouter/src/node.h b/embedded/atsams70-tinyrouter/atsams70-tinyrouter/src/node.h index b4931a187d1b37e415cd68b018f1e4564e2c5c19..4b650514c02b440ee2f49ce7147c6bdbe4239df7 100644 --- a/embedded/atsams70-tinyrouter/atsams70-tinyrouter/src/node.h +++ b/embedded/atsams70-tinyrouter/atsams70-tinyrouter/src/node.h @@ -2,10 +2,11 @@ #define NODE_H_ #define MAX_HOPCOUNT 6 -#define MYADDRESS 9 -#define IS_HOME_PORT 0 +#define MYADDRESS 1 +#define IS_HOME_PORT 1 uint8_t LUT[1024][4]; uint8_t myAddress; +uint8_t window; #endif \ No newline at end of file diff --git a/embedded/atsams70-tinyrouter/atsams70-tinyrouter/src/packet_handling.c b/embedded/atsams70-tinyrouter/atsams70-tinyrouter/src/packet_handling.c index b294db76e7348634bbccabfb2459a6d59566bd9d..27d8dc54359a5045616aacff1685fb583592a6af 100644 --- a/embedded/atsams70-tinyrouter/atsams70-tinyrouter/src/packet_handling.c +++ b/embedded/atsams70-tinyrouter/atsams70-tinyrouter/src/packet_handling.c @@ -11,7 +11,7 @@ int parse_type(packet_t* p) { return p->raw[0]; } -void update_LUT(uint16_t src, uint8_t hopCount, uint8_t port) { +void update_LUT(uint8_t src, uint8_t hopCount, uint8_t port) { LUT[src][port] = LUT[src][port] > hopCount ? hopCount : LUT[src][port]; } @@ -31,35 +31,17 @@ int in_table(uint8_t dest) { LUT[dest][2] == MAX_HOPCOUNT && LUT[dest][3] == MAX_HOPCOUNT); } -packet_t ackpack; - -void acknowledge_packet(packet_t* p){ - ackpack.raw[0] = P_ACK; // is ack - ackpack.raw[1] = p->raw[3]; // destination = source - ackpack.raw[2] = 0; // hopcount = 0 - ackpack.raw[3] = p->raw[1]; // source = destination (should be us) - ackpack.raw[4] = 5; // all acks are 5 bytes - - if (in_table(ackpack.raw[1])) { - send_on_bestport(&ackpack); - } else { - // altho, this should not happen - we have presumably just seen this come in. - p->raw[0] = P_ACK_FLOOD; - broadcast_packet(p, 4); - } -} - void send_on_bestport(packet_t* p){ // empty buffer reads buffersize '1' // from there, 8 bytes in buffer is + 1 (x >> 3) // so divide by 1 is like ~ packet lambda (where packet is 3 byte payload) // divide by 3 for one hopcount = three packets in buffer *shrugman* int bestPort = 0; - int bestLambda = LUT[p->raw[1]][0] + ports[0]->buffersize / 3; + int bestLambda = LUT[p->raw[1]][0];// + ports[0]->buffersize / 3; for (int i = 0; i < 4; i++) { if (LUT[p->raw[1]][i] < bestLambda) { bestPort = i; - bestLambda = LUT[p->raw[1]][0] + ports[0]->buffersize / 3; + bestLambda = LUT[p->raw[1]][0];// + ports[0]->buffersize / 3; } } send_packet(p, bestPort); @@ -145,4 +127,22 @@ void handle_packet(packet_t* p, uint8_t port) { pin_clear(&stlr); // err indicator break; } +} + +packet_t ackpack; + +void acknowledge_packet(packet_t* p){ + ackpack.raw[0] = P_ACK; // is ack + ackpack.raw[1] = p->raw[3]; // destination = source + ackpack.raw[2] = 0; // hopcount = 0 + ackpack.raw[3] = p->raw[1]; // source = destination (should be us) + ackpack.raw[4] = 5; // all acks are 5 bytes + + if (in_table(ackpack.raw[1])) { + send_on_bestport(&ackpack); + } else { + // altho, this should not happen - we have presumably just seen this come in. + p->raw[0] = P_ACK_FLOOD; + broadcast_packet(p, 4); + } } \ No newline at end of file diff --git a/embedded/atsams70-tinyrouter/atsams70-tinyrouter/src/packet_handling.h b/embedded/atsams70-tinyrouter/atsams70-tinyrouter/src/packet_handling.h index d19fa65f6ddb186f788d61a240ce139fd893c735..9882759379c58960b8cfb5802ad4136c94be4fed 100644 --- a/embedded/atsams70-tinyrouter/atsams70-tinyrouter/src/packet_handling.h +++ b/embedded/atsams70-tinyrouter/atsams70-tinyrouter/src/packet_handling.h @@ -16,7 +16,7 @@ int parse_type(packet_t* p); -void update_LUT(uint16_t src, uint8_t hopCount, uint8_t port); +void update_LUT(uint8_t src, uint8_t hopCount, uint8_t port); void send_packet(packet_t* p, uint8_t port); diff --git a/results/12node-rtt/ct0-rtt-471us.png b/results/12node-rtt/ct0-rtt-471us.png new file mode 100644 index 0000000000000000000000000000000000000000..3c5dd8a95fe5634186e5c0934d25801cf22f699d Binary files /dev/null and b/results/12node-rtt/ct0-rtt-471us.png differ diff --git a/results/3node-delays/results-D_p.png b/results/3node-delays/results-D_p.png new file mode 100644 index 0000000000000000000000000000000000000000..cd9e02d152eabc2b8bd323f6ac1371806dba63b4 Binary files /dev/null and b/results/3node-delays/results-D_p.png differ