Final version

This commit is contained in:
Christos Houtouridis 2019-10-09 23:03:29 +03:00
parent 3ec3db11c9
commit a452f2e27c
9 changed files with 122 additions and 76 deletions

View File

@ -6,12 +6,21 @@
# #
# #
# select one of the following or edit for your environment # Edit the paths to match your environment
# Currently supported:
# Windows (we prefer Cygwin)
# GNU/Linux
# #
LINUX_CXX := /usr/local/bin/cross-pi0/bin/arm-linux-gnueabihf-gcc
WIN_CXX := D:\SysGCC\raspberry\bin\arm-linux-gnueabihf-gcc.exe
#CXX := /usr/local/arm/bin/arm-unknown-linux-gnueabi-gcc # RTES related stuff for upload
CXX := D:\SysGCC\raspberry\bin\arm-linux-gnueabihf-gcc.exe SCP := scp
PIUSER := root
PI := 192.168.0.1
RTES_PATH := /usr/local/bin/
# === Compilation related stuff ===
CXXFLAGS := -std=c11 -Wall -Wextra -Werror CXXFLAGS := -std=c11 -Wall -Wextra -Werror
CXXFEXTR := -c -fmessage-length=0 CXXFEXTR := -c -fmessage-length=0
LDFLAGS := -lm -lpthread LDFLAGS := -lm -lpthread
@ -21,6 +30,21 @@ APP_DIR := $(BUILD)
TARGET := rtes_final TARGET := rtes_final
SRC := $(wildcard src/*.c) SRC := $(wildcard src/*.c)
# === OS selection ===
ifeq ($(OS),Windows_NT)
# Windows, select exe path
CXX := $(WIN_CXX)
else
# Linux filter [currently only GNU/Linux]
UNAME := $(shell uname)
ifeq ($(UNAME),Linux)
CXX := $(LINUX_CXX)
else
ERR := $(error Not supporting OS)
endif
endif
# === MakeFile body ===
OBJECTS := $(SRC:%.c=$(OBJ_DIR)/%.o) OBJECTS := $(SRC:%.c=$(OBJ_DIR)/%.o)
$(OBJ_DIR)/%.o: %.c $(OBJ_DIR)/%.o: %.c
@ -34,6 +58,10 @@ $(APP_DIR)/$(TARGET): $(OBJECTS)
# === Rules === # === Rules ===
rtes_final: build $(APP_DIR)/$(TARGET) rtes_final: build $(APP_DIR)/$(TARGET)
clean:
-@rm -rvf $(OBJ_DIR)/*
-@rm -rvf $(APP_DIR)/*
build: build:
@mkdir -p $(APP_DIR) @mkdir -p $(APP_DIR)
@mkdir -p $(OBJ_DIR) @mkdir -p $(OBJ_DIR)
@ -45,11 +73,7 @@ release: CXXFLAGS += -O2
release: rtes_final release: rtes_final
upload: upload:
scp $(BUILD)/$(TARGET) root@192.168.0.1:/root/ $(SCP) $(BUILD)/$(TARGET) $(PIUSER)@$(PI):$(RTES_PATH)
clean:
-@rm -rvf $(OBJ_DIR)/*
-@rm -rvf $(APP_DIR)/*
all: clean release upload all: clean release upload

View File

@ -1,5 +1,6 @@
Statistics Statistics
============
total messages: 483 total messages: 483
duplicate messages: 277 duplicate messages: 277
messages for me: 122 messages for me: 122
@ -8,6 +9,9 @@ Statistics
Out direct messages: 35 Out direct messages: 35
Average message size: 28.6562 Average message size: 28.6562
Average time to me: 67.4166 Average time to me: 67.4166
Device timestamps
===================
Device 7700 found on 0, last: 0 Device 7700 found on 0, last: 0
Device 8261 found on 1570210285, last: 1570211945 Device 8261 found on 1570210285, last: 1570211945
Device 8765 found on 0, last: 0 Device 8765 found on 0, last: 0

Binary file not shown.

After

Width:  |  Height:  |  Size: 30 KiB

BIN
report/resources/stats.ods Executable file

Binary file not shown.

BIN
report_rtes_Choutouridis_8997.pdf Executable file

Binary file not shown.

View File

@ -205,7 +205,10 @@ static void client (void) {
msg_t msg; // new message buffer msg_t msg; // new message buffer
while (true) { while (true) {
// Idle until the time comes // Idle until the time comes
sleep (settings.msgInterval + (rand()%(5*settings.msgInterval))); sleep (
settings.msgIntervalMin +
(rand() % (settings.msgIntervalMax - settings.msgIntervalMin))
);
memset ((void*)&msg, 0, sizeof (msg)); // create a new message memset ((void*)&msg, 0, sizeof (msg)); // create a new message
cMsg_make (&msg.cMsg); cMsg_make (&msg.cMsg);
msg.sender = settings.me; msg.sender = settings.me;

View File

@ -30,7 +30,7 @@ stats_t stats; //!< Statistical data
/*! /*!
* CLI short options * CLI short options
*/ */
const char *short_opt = "v:i:m:p:s:w:th"; const char *short_opt = "v:i:m:M:p:s:w:th";
/*! /*!
* CLI long options * CLI long options
@ -38,7 +38,8 @@ const char *short_opt = "v:i:m:p:s:w:th";
const struct option long_opt[] = { const struct option long_opt[] = {
{"outlevel", required_argument, NULL, 'v'}, {"outlevel", required_argument, NULL, 'v'},
{"interval", required_argument, NULL, 'i'}, {"interval", required_argument, NULL, 'i'},
{"msginterval", required_argument, NULL, 'm'}, {"msgintervalmin", required_argument, NULL, 'm'},
{"msgintervalmax", required_argument, NULL, 'M'},
{"pingtimeout", required_argument, NULL, 'p'}, {"pingtimeout", required_argument, NULL, 'p'},
{"sendtimeout", required_argument, NULL, 's'}, {"sendtimeout", required_argument, NULL, 's'},
{"who", required_argument, NULL, 'w'}, {"who", required_argument, NULL, 'w'},
@ -71,16 +72,19 @@ int parse_args (settings_t *s, int argc, char const *argv[]) {
if (s->outLevel < OUTLEVEL_0) s->outLevel = OUTLEVEL_0; if (s->outLevel < OUTLEVEL_0) s->outLevel = OUTLEVEL_0;
break; break;
case 'i': s->seekerInterval = atoi (optarg); break; case 'i': s->seekerInterval = atoi (optarg); break;
case 'm': s->msgInterval = atoi (optarg); break; case 'm': s->msgIntervalMin = atoi (optarg); break;
case 'M': s->msgIntervalMax = atoi (optarg); break;
case 'p': s->pingTimeout = atoi (optarg); break; case 'p': s->pingTimeout = atoi (optarg); break;
case 's': s->sendTimeout.tv_sec = atoi (optarg); break; case 's': s->sendTimeout.tv_sec = atoi (optarg); break;
case 'w': s->me = atoi (optarg); break; case 'w': s->me = atoi (optarg); break;
case 't': s->trackTime = true; break; case 't': s->trackTime = true; break;
case 'h': case 'h':
printf ("Syntax:\nrtes_final [-t] [-v num] [-i num] [-p num] [-s num] [-w num]\n\n"); printf ("Syntax:\n");
printf ("rtes_final [-t] [-h] [-v num] [-i num] [-m num] [-M 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 ("-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 ("-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 ("-m, --msgintervalmin sec: Set the interval of the client in [sec]\n");
printf ("-M, --msgintervalmax sec: Set the interval of the client in [sec]\n");
printf ("-p, --pingtimeout sec: Set the ping timeout 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 ("-s, --sendtimeout sec: Set the connect/send timeout in [sec]\n");
printf ("-w, --who AEM: Select the AEM of the device\n"); printf ("-w, --who AEM: Select the AEM of the device\n");

View File

@ -17,14 +17,13 @@
#include <netinet/in.h> #include <netinet/in.h>
/*! /*!
* AEM list * Hard-coded AEM list
*/ */
#define AEMLIST_SIZE (6)
#define AEMLIST_0 { 7700, 8261, 8765, 8844, 8880, 8861, 8877, 8941, 8934, 8997 } #define AEMLIST_0 { 7700, 8261, 8765, 8844, 8880, 8861, 8877, 8941, 8934, 8997 }
#define AEMLIST_1 { 8918, 8929, 8997, 8880, 8844, 8861 } #define AEMLIST_1 { 8918, 8929, 8997, 8880, 8844, 8861 }
#define AEMLIST AEMLIST_1 #define AEMLIST AEMLIST_0
#define AEMLIST_SIZE (10)
/*! /*!
* General options * General options
@ -32,7 +31,7 @@
//! @{ //! @{
#define MSG_TEXT_SIZE 256 //!< Maximum size of each message #define MSG_TEXT_SIZE 256 //!< Maximum size of each message
#define MSG_LIST_SIZE 2000 //!< Maximum size of message history buffer #define MSG_LIST_SIZE 2000 //!< Maximum size of message history buffer
#define DEVICE_LIST_SIZE 100 //!< Maximum size of the device list #define DEVICE_LIST_SIZE 200 //!< Maximum number of the device in listener's queue
#define MSG_DELIMITER '_' //!< Message delimiter #define MSG_DELIMITER '_' //!< Message delimiter
#define ADHOC_NET_A 10 //!< [A.B.C.D] #define ADHOC_NET_A 10 //!< [A.B.C.D]
@ -71,7 +70,7 @@ typedef aem_t devAEM_t; //!< device as AEM type
* device as IP type * device as IP type
*/ */
typedef struct { typedef struct {
uint16_t A, B, C, D; uint16_t A, B, C, D; //!< IP octets
}devIP_t; }devIP_t;
typedef double fpdata_t; //!< Select floating point data type for the application typedef double fpdata_t; //!< Select floating point data type for the application
@ -79,15 +78,16 @@ typedef double fpdata_t; //!< Select floating point data type for the
// Syntactic sugar types // Syntactic sugar types
typedef struct sockaddr_in sockaddr_in_t; //!< internet socket address type definition typedef struct sockaddr_in sockaddr_in_t; //!< internet socket address type definition
typedef struct sockaddr sockaddr_t; //!< general socket address type definition typedef struct sockaddr sockaddr_t; //!< general socket address type definition
typedef struct timeval timeval_t; typedef struct timeval timeval_t; //!< general timeval type definition
/*! /*!
* AEM list for our mesh network * AEM list for our mesh network
*/ */
typedef struct { typedef struct {
devAEM_t dev; devAEM_t dev; //!< The device
bool_t onRange; bool_t onRange; //!< Flag to indicate if the device is on range
tstamp_t begin; tstamp_t begin; //!< First time we had answer from the device on ping
tstamp_t end; tstamp_t end; //!< Last time we had answer from the device on ping
} devList_t; } devList_t;
extern devList_t devList[]; extern devList_t devList[];
@ -199,6 +199,9 @@ typedef struct {
extern stats_t stats; extern stats_t stats;
/*!
* Verbose level enumerator for settings
*/
typedef enum { typedef enum {
OUTLEVEL_0, //!< Output only results [default] OUTLEVEL_0, //!< Output only results [default]
OUTLEVEL_1, //!< Output results and every message also OUTLEVEL_1, //!< Output results and every message also
@ -206,24 +209,32 @@ typedef enum {
}outLevel_en; }outLevel_en;
/*!
* Application settings
*/
typedef struct { typedef struct {
devAEM_t me; devAEM_t me; //!< Who Am I
uint16_t port; uint16_t port; //!< Application port
time_t seekerInterval; time_t seekerInterval; //!< sleep time for seeker
time_t msgInterval; time_t msgIntervalMin; //!< minimum sleep time for client
outLevel_en outLevel; time_t msgIntervalMax; //!< maximum sleep time for client
time_t pingTimeout; outLevel_en outLevel; //!< Verbose level
timeval_t sendTimeout; time_t pingTimeout; //!< Ping timeout
bool_t trackTime; timeval_t sendTimeout; //!< Send and select timeout
bool_t trackTime; //!< Track message timing flag
}settings_t; }settings_t;
extern settings_t settings; extern settings_t settings;
/*!
* Helper macro to setup default settings to application
*/
#define settings_init(s) s = { \ #define settings_init(s) s = { \
.me = 8997, \ .me = 8997, \
.port = 2288, \ .port = 2288, \
.seekerInterval = 30, \ .seekerInterval = 30, \
.msgInterval = 60, \ .msgIntervalMin = 60, \
.msgIntervalMax = 300, \
.outLevel = OUTLEVEL_1, \ .outLevel = OUTLEVEL_1, \
.pingTimeout = 1, \ .pingTimeout = 1, \
.sendTimeout = {4, 0}, \ .sendTimeout = {4, 0}, \