Browse Source

Final version

master
Christos Houtouridis 1 year ago
parent
commit
a452f2e27c
9 changed files with 122 additions and 76 deletions
  1. +40
    -16
      Makefile
  2. +23
    -19
      measurements/4_10/statistics.txt
  3. BIN
      report/report_rtes_Choutouridis_8997.odt
  4. BIN
      report/resources/rtes_listener.png
  5. BIN
      report/resources/stats.ods
  6. BIN
      report_rtes_Choutouridis_8997.pdf
  7. +4
    -1
      src/client.c
  8. +24
    -20
      src/main.c
  9. +31
    -20
      src/msg_impl.h

+ 40
- 16
Makefile View File

@@ -6,21 +6,45 @@
#
#
# 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
CXX := D:\SysGCC\raspberry\bin\arm-linux-gnueabihf-gcc.exe
# RTES related stuff for upload
SCP := scp
PIUSER := root
PI := 192.168.0.1
RTES_PATH := /usr/local/bin/
CXXFLAGS := -std=c11 -Wall -Wextra -Werror
CXXFEXTR := -c -fmessage-length=0
LDFLAGS := -lm -lpthread
BUILD := ./bin
OBJ_DIR := $(BUILD)/obj
APP_DIR := $(BUILD)
TARGET := rtes_final
SRC := $(wildcard src/*.c)
# === Compilation related stuff ===
CXXFLAGS := -std=c11 -Wall -Wextra -Werror
CXXFEXTR := -c -fmessage-length=0
LDFLAGS := -lm -lpthread
BUILD := ./bin
OBJ_DIR := $(BUILD)/obj
APP_DIR := $(BUILD)
TARGET := rtes_final
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)
$(OBJ_DIR)/%.o: %.c
@@ -34,6 +58,10 @@ $(APP_DIR)/$(TARGET): $(OBJECTS)
# === Rules ===
rtes_final: build $(APP_DIR)/$(TARGET)
clean:
-@rm -rvf $(OBJ_DIR)/*
-@rm -rvf $(APP_DIR)/*
build:
@mkdir -p $(APP_DIR)
@mkdir -p $(OBJ_DIR)
@@ -45,11 +73,7 @@ release: CXXFLAGS += -O2
release: rtes_final
upload:
scp $(BUILD)/$(TARGET) root@192.168.0.1:/root/
clean:
-@rm -rvf $(OBJ_DIR)/*
-@rm -rvf $(APP_DIR)/*
$(SCP) $(BUILD)/$(TARGET) $(PIUSER)@$(PI):$(RTES_PATH)
all: clean release upload


+ 23
- 19
measurements/4_10/statistics.txt View File

@@ -1,20 +1,24 @@

Statistics
total messages: 483
duplicate messages: 277
messages for me: 122
messages by me: 43
In messages direct for me: 33
Out direct messages: 35
Average message size: 28.6562
Average time to me: 67.4166
Device 7700 found on 0, last: 0
Device 8261 found on 1570210285, last: 1570211945
Device 8765 found on 0, last: 0
Device 8844 found on 1570209288, last: 1570217684
Device 8880 found on 1570209288, last: 1570216562
Device 8861 found on 1570209288, last: 1570216904
Device 8877 found on 0, last: 0
Device 8941 found on 1570209289, last: 1570217461
Device 8934 found on 0, last: 0
Device 8997 found on 0, last: 0
Statistics
============
total messages: 483
duplicate messages: 277
messages for me: 122
messages by me: 43
In messages direct for me: 33
Out direct messages: 35
Average message size: 28.6562
Average time to me: 67.4166

Device timestamps
===================
Device 7700 found on 0, last: 0
Device 8261 found on 1570210285, last: 1570211945
Device 8765 found on 0, last: 0
Device 8844 found on 1570209288, last: 1570217684
Device 8880 found on 1570209288, last: 1570216562
Device 8861 found on 1570209288, last: 1570216904
Device 8877 found on 0, last: 0
Device 8941 found on 1570209289, last: 1570217461
Device 8934 found on 0, last: 0
Device 8997 found on 0, last: 0

BIN
report/report_rtes_Choutouridis_8997.odt View File


BIN
report/resources/rtes_listener.png View File

Before After
Width: 958  |  Height: 1489  |  Size: 30 KiB

BIN
report/resources/stats.ods View File


BIN
report_rtes_Choutouridis_8997.pdf View File


+ 4
- 1
src/client.c View File

@@ -205,7 +205,10 @@ static void client (void) {
msg_t msg; // new message buffer
while (true) {
// 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
cMsg_make (&msg.cMsg);
msg.sender = settings.me;


+ 24
- 20
src/main.c View File

@@ -30,21 +30,22 @@ stats_t stats; //!< Statistical data
/*!
* 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
*/
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'},
{"tracktime", no_argument, NULL, 't'},
{"help", no_argument, NULL, 'h'},
{NULL, 0, NULL, 0}
{"outlevel", required_argument, NULL, 'v'},
{"interval", required_argument, NULL, 'i'},
{"msgintervalmin", required_argument, NULL, 'm'},
{"msgintervalmax", required_argument, NULL, 'M'},
{"pingtimeout", required_argument, NULL, 'p'},
{"sendtimeout", required_argument, NULL, 's'},
{"who", required_argument, NULL, 'w'},
{"tracktime", no_argument, NULL, 't'},
{"help", no_argument, NULL, 'h'},
{NULL, 0, NULL, 0}
};
/*!
@@ -71,21 +72,24 @@ 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 'm': s->msgIntervalMin = atoi (optarg); break;
case 'M': s->msgIntervalMax = 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;
case 't': s->trackTime = true; break;
case 'h':
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");
printf ("-t, --tracktime: Enables time tracking in statistics\n");
printf ("-h, --help: Print this and exit\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 ("-i, --interval sec: Set the interval of the seeker 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 ("-s, --sendtimeout sec: Set the connect/send timeout in [sec]\n");
printf ("-w, --who AEM: Select the AEM of the device\n");
printf ("-t, --tracktime: Enables time tracking in statistics\n");
printf ("-h, --help: Print this and exit\n");
exit(1);
case ':':
default:


+ 31
- 20
src/msg_impl.h View File

@@ -17,14 +17,13 @@
#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_1 { 8918, 8929, 8997, 8880, 8844, 8861 }
#define AEMLIST AEMLIST_1
#define AEMLIST AEMLIST_0
#define AEMLIST_SIZE (10)
/*!
* General options
@@ -32,7 +31,7 @@
//! @{
#define MSG_TEXT_SIZE 256 //!< Maximum size of each message
#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 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
*/
typedef struct {
uint16_t A, B, C, D;
uint16_t A, B, C, D; //!< IP octets
}devIP_t;
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
typedef struct sockaddr_in sockaddr_in_t; //!< internet 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
*/
typedef struct {
devAEM_t dev;
bool_t onRange;
tstamp_t begin;
tstamp_t end;
devAEM_t dev; //!< The device
bool_t onRange; //!< Flag to indicate if the device is on range
tstamp_t begin; //!< First time we had answer from the device on ping
tstamp_t end; //!< Last time we had answer from the device on ping
} devList_t;
extern devList_t devList[];
@@ -199,6 +199,9 @@ typedef struct {
extern stats_t stats;
/*!
* Verbose level enumerator for settings
*/
typedef enum {
OUTLEVEL_0, //!< Output only results [default]
OUTLEVEL_1, //!< Output results and every message also
@@ -206,24 +209,32 @@ typedef enum {
}outLevel_en;
/*!
* Application settings
*/
typedef struct {
devAEM_t me;
uint16_t port;
time_t seekerInterval;
time_t msgInterval;
outLevel_en outLevel;
time_t pingTimeout;
timeval_t sendTimeout;
bool_t trackTime;
devAEM_t me; //!< Who Am I
uint16_t port; //!< Application port
time_t seekerInterval; //!< sleep time for seeker
time_t msgIntervalMin; //!< minimum sleep time for client
time_t msgIntervalMax; //!< maximum sleep time for client
outLevel_en outLevel; //!< Verbose level
time_t pingTimeout; //!< Ping timeout
timeval_t sendTimeout; //!< Send and select timeout
bool_t trackTime; //!< Track message timing flag
}settings_t;
extern settings_t settings;
/*!
* Helper macro to setup default settings to application
*/
#define settings_init(s) s = { \
.me = 8997, \
.port = 2288, \
.seekerInterval = 30, \
.msgInterval = 60, \
.msgIntervalMin = 60, \
.msgIntervalMax = 300, \
.outLevel = OUTLEVEL_1, \
.pingTimeout = 1, \
.sendTimeout = {4, 0}, \


Loading…
Cancel
Save