Skip to content
Snippets Groups Projects
Select Git revision
  • d64331e2d4c94d1477a65ff925c36089c8e0e9ef
  • master default protected
2 results

README.md

Blame
  • Mohamad Moussa's avatar
    mohamad.moussa authored
    d64331e2
    History

    Lab : Distributed Algorithm - Message Passing

    Overview

    This project implements a distributed algorithm for communication between nodes in a network using Sockets. The code is designed to be containerised using Docker.

    Prerequisites

    • Python 3.x
    • Docker and Docker Compose

    Description

    Each node in the network has a configuration file that lists its neighbors.

    The exercise involves the following steps, main file:

    1. Initalisation:
      • Each node reads its neighbors file.
      • Each node starts a server socket to listen for incoming connections
    2. Message Exchange:
      • During the first x iterations, each node sends a message of type REQUEST_WEIGHT to all its neighbors.
      • Upon receiving a message of type REQUEST_WEIGHT, a node responds by sending back a message of type WEIGHTS to the requesting node.
      • The algorithm runs for a total of N iterations
      • Each node logs its activities and messages

    Neighbors Configuration

    The neighbors configuration is a directory that contains the neighbors files for all the nodes. Ensure that you have a corresponding number of neighbor files in the neighbors directory, named neighbors0.txt, neighbors1.txt, etc.

    Dockerfile

    Once your code is developed, it is time to build the container image, DockerFile

    Local Deployment

    For local deployment, you can use the script to generate a Docker Compose file. This script takes the number of nodes in your network as an argument and generates the Docker Compose configuration. To generate the Docker Compose file, run the script with the desired number of nodes:

    python generate_docker_compose.py <num_nodes>

    Replace <num_nodes> with the number of nodes in your network.

    Replace the varibale image (line 3) with your previouly built container image.

    Troubleshooting

    • Check the container logs
    • Ensure that all environment variables are correctly set and that the neighbors' file is correctly configured.