Git Product home page Git Product logo

rci-reliable-message-board's Introduction

RCI-Reliable-Message-Board

Project for the Computer Networks course at IST, Lisbon during the summer semester of 2016/17. Authors: Filipe Ferreira, João Nobre, Pedro Ferreira

To run the ID server: ./sid64 -debug.

To run msgserv and rmb, you need to make sure you're connecting to the right ID server. If you're running it on your machine, make sure you run msgserv and rmb with the option -i set to your machine's IP address. In Ubuntu you can find this out by using the command ifconfig.

How it works

The project consists of two applications: rmb and msgserv. rmb is the app that users use to communicate with each other, publishing and accessing messages in the message board. msgserv is a server which stores messages. An ID server is assumed to exist, containing the list of online msgservs.

When a msgserv is launched, it creates 3 sockets: one to listen to UDP requests from an rmb, another to send UDP requests to the ID server and another to listen to TCP requests from other msgservs. Then, it sends a GET_SERVERS message via UDP to the ID server, to which the ID server responds with a SERVERS\n(name;ip;upt;tpt)\n (one \n after each server description). The msgserv then sends a REG name;ip;upt;tpt UDP message to the ID server, and the ID server adds this server to the server list. Then, the msgserv counts the number of connected servers. If there are other connected msgservs, this server estabilishes a TCP session (socket() + connect()) with each one (avoiding a connection to itself).

After connecting to the other servers, this msgserv fetches the messages which the others already have stored in their memories. This is done by sending a SGET_MESSAGES\n TCP message to each of the connected servers (we decided to send to all of them to check if they are actually alive). Each server will answer with a SMESSAGES\n TCP message containing all its messages. After all servers have been queried for messages, the response of the last one is the one used to copy the received messages into this msgserv.

We now enter the main loop of the msgserv application. The app will be constantly listening, via a select(), to incoming requests from the command line, from an rmb or from other msgservs, which may be either trying to connect() - in which case we call accept() - to this one or sending a MESSAGES\n TCP message. We set a timeout in select() so that every T seconds the server sends a REG name;ip;upt;tpt UDP message to the ID server to signal that it's online and available.

All UDP requests, both in msgserv and in rmb, are made so as to guarantee that the message was received by the peer or, if it wasn't, to inform the requester of what happened. Everytime a UDP request is made to an ID server or from an rmb to a msgserv, we wait 1 second 5 times (yielding a maximum of 5 seconds of hold), each time repeating the request we didn't get an answer from before. In the case of rmb to msgserv requests, we send a GET_MESSAGES n message to see if the server is responding. If it isn't - no messages where received - after 5 tries, rmb asks the ID server for the server list, and randomly tries to connect to another server in the list.

If a msgserv tries to connect to one which is not online, connect() fails and that socket is set to NULL.

rci-reliable-message-board's People

Contributors

joaonobre avatar pedrofale avatar

Stargazers

 avatar

Watchers

 avatar

rci-reliable-message-board's Issues

RMB reliable publishing

Whenever an RMB user publishes a message, check if the message was actually published in the corresponding message server, by sending a GET_MESSAGES. If no response is received, the RMB client automatically tries to connect to another message server and asks the user to PUBLISH again.

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.