diff --git a/report/report_rtes_Choutouridis_8997.odt b/report/report_rtes_Choutouridis_8997.odt index 1691949..c254a3a 100755 Binary files a/report/report_rtes_Choutouridis_8997.odt and b/report/report_rtes_Choutouridis_8997.odt differ diff --git a/report/resources/1 -oMC8qPOVoMjB_SNMLiaXQ.jpeg.jpg b/report/resources/1 -oMC8qPOVoMjB_SNMLiaXQ.jpeg.jpg new file mode 100755 index 0000000..fd14b17 Binary files /dev/null and b/report/resources/1 -oMC8qPOVoMjB_SNMLiaXQ.jpeg.jpg differ diff --git a/report/resources/452655-mesh-network.jpg b/report/resources/452655-mesh-network.jpg new file mode 100755 index 0000000..97dc437 Binary files /dev/null and b/report/resources/452655-mesh-network.jpg differ diff --git a/report/resources/print.png b/report/resources/print.png new file mode 100755 index 0000000..abecf11 Binary files /dev/null and b/report/resources/print.png differ diff --git a/src/client.c b/src/client.c index 993a15e..b55c160 100644 --- a/src/client.c +++ b/src/client.c @@ -205,7 +205,7 @@ static void client (void) { msg_t msg; // new message buffer while (true) { // Idle until the time comes - sleep (settings.msgInterval + (rand()%settings.msgRand)); + sleep (settings.msgInterval + (rand()%(5*settings.msgInterval))); memset ((void*)&msg, 0, sizeof (msg)); // create a new message cMsg_make (&msg.cMsg); msg.sender = settings.me; diff --git a/src/core.c b/src/core.c index 1447e9f..ff04d28 100644 --- a/src/core.c +++ b/src/core.c @@ -345,7 +345,7 @@ bool_t cMsg_equal (cMsg_t* m1, cMsg_t* m2) { if (m1->from != m2->from) return false; if (m1->to != m2->to) return false; if (m1->ts != m2->ts) return false; - if (strncmp (m1->text, m2->text, sizeof(m1->text))) + if (strncmp (m1->text, m2->text, strlen(m1->text))) return false; return true; } diff --git a/src/listener.c b/src/listener.c index af7693a..3477132 100755 --- a/src/listener.c +++ b/src/listener.c @@ -34,10 +34,23 @@ static void listen_handler (devAEM_t dev, char_t* buffer, size_t size) { mIter_t myCopy = msgList_find (&msgList, &msg); // try to find message in msgList if (myCopy == -1) { // We don't have a copy, accept and store it - msgList_add (&msgList, &msg); + mIter_t slot = msgList_add (&msgList, &msg); msgList_release (); statsUpdateIn (&msg, false); // message process log_msg_in (&msg); // log + + // Processing... + devList_acquire(); + dIter_t d = devList_getIter (dev); + dIter_t f = devList_getIter (msg.cMsg.from); + devList_release(); + + msgList_acquire (); + // Do not echo message to sender, he already has it + msgList.m[slot].recipients[d] = true; + // don't push back message to creator, he already has it + msgList.m[slot].recipients[f] = true; + msgList_release (); } else { // We have a copy @@ -45,18 +58,6 @@ static void listen_handler (devAEM_t dev, char_t* buffer, size_t size) { statsUpdateIn (&msg, true); // message process log_debug ("Debug: Duplicate message from: %d\n", msg.sender); } - // Processing... - devList_acquire(); - dIter_t d = devList_getIter (dev); - dIter_t f = devList_getIter (msg.cMsg.from); - devList_release(); - - msgList_acquire (); - // Do not echo message to sender, he already has it - msgList.m[myCopy].recipients[d] = true; - // don't push back message to creator, he already has it - msgList.m[myCopy].recipients[f] = true; - msgList_release (); } /*! diff --git a/src/main.c b/src/main.c index 2b99c2e..5d9eb0d 100644 --- a/src/main.c +++ b/src/main.c @@ -30,7 +30,7 @@ stats_t stats; //!< Statistical data /*! * CLI short options */ -const char *short_opt = "v:i:p:s:w:th"; +const char *short_opt = "v:i:m:p:s:w:th"; /*! * CLI long options @@ -38,6 +38,7 @@ const char *short_opt = "v:i:p:s:w:th"; const struct option long_opt[] = { {"outlevel", required_argument, NULL, 'v'}, {"interval", required_argument, NULL, 'i'}, + {"msginterval", required_argument, NULL, 'm'}, {"pingtimeout",required_argument, NULL, 'p'}, {"sendtimeout",required_argument, NULL, 's'}, {"who", required_argument, NULL, 'w'}, @@ -70,6 +71,7 @@ int parse_args (settings_t *s, int argc, char const *argv[]) { if (s->outLevel < OUTLEVEL_0) s->outLevel = OUTLEVEL_0; break; case 'i': s->seekerInterval = atoi (optarg); break; + case 'm': s->msgInterval = atoi (optarg); break; case 'p': s->pingTimeout = atoi (optarg); break; case 's': s->sendTimeout.tv_sec = atoi (optarg); break; case 'w': s->me = atoi (optarg); break; @@ -78,6 +80,7 @@ int parse_args (settings_t *s, int argc, char const *argv[]) { printf ("Syntax:\nrtes_final [-t] [-v num] [-i num] [-p num] [-s num] [-w num]\n\n"); printf ("-v, --outlevel num: Change the verbosity of the program, num can be 0, 1 or 2\n"); printf ("-i, --interval sec: Set the interval of the seeker in [sec]\n"); + printf ("-m, --msginterval sec: Set the interval of the client in [sec]\n"); printf ("-p, --pingtimeout sec: Set the ping timeout in [sec]\n"); printf ("-s, --sendtimeout sec: Set the connect/send timeout in [sec]\n"); printf ("-w, --who AEM: Select the AEM of the device\n"); diff --git a/src/msg_impl.h b/src/msg_impl.h index 2db5677..1c9e811 100644 --- a/src/msg_impl.h +++ b/src/msg_impl.h @@ -19,20 +19,12 @@ /*! * AEM list */ -#define AEMLIST_SIZE (10) - -#define AEMLIST { \ - 7700, \ - 8261, \ - 8765, \ - 8844, \ - 8880, \ - 8861, \ - 8877, \ - 8941, \ - 8934, \ - 8997 \ -} +#define AEMLIST_SIZE (6) + +#define AEMLIST_0 { 7700, 8261, 8765, 8844, 8880, 8861, 8877, 8941, 8934, 8997 } +#define AEMLIST_1 { 8918, 8929, 8997, 8880, 8844, 8861 } + +#define AEMLIST AEMLIST_1 /*! * General options @@ -219,7 +211,6 @@ typedef struct { uint16_t port; time_t seekerInterval; time_t msgInterval; - time_t msgRand; outLevel_en outLevel; time_t pingTimeout; timeval_t sendTimeout; @@ -233,11 +224,10 @@ extern settings_t settings; .port = 2288, \ .seekerInterval = 30, \ .msgInterval = 60, \ - .msgRand = 240, \ .outLevel = OUTLEVEL_1, \ .pingTimeout = 1, \ .sendTimeout = {4, 0}, \ - .trackTime = true \ + .trackTime = false \ } //! @}