Code Monkey home page Code Monkey logo

realtime-messaging-lab's Introduction

This project was developed for the 'Real-Time Embedded Systems' course, part of the MEng in Electrical and Computer Engineering at the Aristotle University of Thessaloniki in 2019. Its purpose is to develop a simple message exchange system based on an integrated real-time system that manages the flow of messages. Messages are generated by devices corresponding to each student and are shared among all possible devices until they reach their destination.

Overview

The logic behind the implemented code is as follows: A thread is created and tasked with passively receiving messages from neighboring devices seeking communication. Concurrently, it attempts to connect to every possible available device sequentially to send stored messages. In addition to these, randomly generated messages are sent to devices at regular intervals. This process continues for the 2 hours designated as the experiment's duration.

Note on terminology: In this project, "AEM" refers to the unique student identification number used in Greece. This is practically the ID of each participating student.

Global Variables

  • uint32_t peerAEM[nAEMs]: A static vector storing an array of AEMs of potential network devices (where nAEMs is the constant for the number of these AEMs).
  • char** history: A two-dimensional dynamic array storing incoming messages.
  • char** aemIPs: A 2D dynamic array storing the IP addresses of potential network devices.
  • int history_idx: A pointer to the current position in history where a new entry is stored.
  • int end_flag: A flag indicating the end of the program after 2 hours.
  • uint32_t info[6][nAEMs]: A multipurpose 2D static array storing AEMs, message indices, and statistics for communication analysis.
  • FILE* recFile, sendFile, randomMesFile, forMeFile, statsFile: Files for storing received messages, sent messages, random messages, messages intended for the device itself, and statistical data, respectively.

Functions

IP to AEM Conversion

int IptoAEM(char* ip): Converts an IP address to its corresponding AEM number by extracting and processing the address components.

Making IP Addresses

void makeIPs(): Converts stored AEMs to their corresponding IP addresses and stores them in aemIPs.

Writing to Files

void write_file(FILE* file, char* data): Writes data to a file if the file is open successfully.

Connecting to a Server

int connect_server(char* ip, char* message): Creates a socket and connects to a device at the specified IP address to send a message.

Server Function

void server(char* ip): Manages connections to an IP address and sends messages following a random delay.

Listener Function

void listener(): Creates a socket to passively receive messages from any neighboring device and processes them.

Listener Thread

void* thListener(void* ptr): Calls the listener function; used to implement a listener thread.

Main Function

int main(int argc, char const *argv[]): Initializes files, arrays, and variables; creates a listener thread; and manages the sending and receiving of messages.

realtime-messaging-lab's People

Contributors

annatz avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.