Skip to content

OMNeT++ simulation of P2P distributed computing with CHORD-inspired routing and gossip protocol for task distribution

Notifications You must be signed in to change notification settings

RohanLambture/BitTorrent-DHT-Simulator

Repository files navigation

P2P Program Execution Simulation using OMNeT++

Overview

This project simulates remote program execution using the OMNeT++ Discrete Event Simulator. In the simulation, a client node divides a computational task (for example, determining the maximum element in an array) into several subtasks and distributes them among other client nodes for parallel processing. The overall result is determined by aggregating the maximum received for each subtask. Additionally, client nodes do gosip message to all other clients after getting the task done.

Assignment Objectives

  • Task Partitioning:
    • Divide an array of x integer elements (with x ≥ 2) into n approximately equal segments, ensuring each segment contains at least two elements.

      Note: It is assumed that x is always at least 2.

    • Dispatch each subtask to a client based on clientid = subtaskid % num_of_clients

Network Setup

The network consists of N client nodes arranged in a ring topology. Each client has a unique ID starting from 0 and is connected to its successor and predecessor in the ring. Additional connections are established to optimize message exchange complexity from O(N) to O(logN), inspired by the CHORD Distributed Hash Table protocol.

Simulation Workflow

  1. A client node initializes a task (e.g., finding the maximum element in an array).
  2. The client divides the task into x subtasks, where x > N.
  3. For each subtask with ID i:
    • The subtask is assigned to client with ID (i % N).
    • The client routes the subtask to the target client using O(logN) message exchanges.
  4. Each client executes its assigned subtasks and sends results back to the requesting client.
  5. The requesting client consolidates results (e.g., finds the maximum among all returned values).
  6. After completing the task, the client sends gossip messages to all other clients.
  7. Once a client receives gossip messages from all N clients, it terminates.

Gossip Protocol

  • When a client completes a task, it generates a message in the format:
    <self.timestamp>:<self.IP>:<self.ClientID#>
    
  • This message is transmitted to all adjacent nodes.
  • When a node receives a message for the first time:
    • It makes an entry in the Message Log (ML) to track the message.
    • It forwards the message to all peers except the source peer.
  • Subsequent receipts of the same message are ignored to prevent loops.

Program Output

  • Each client logs the result of each subtask it receives from other clients, both to the console and an output file.
  • Each client displays the consolidated result of each task.
  • Every gossip message received for the first time is displayed on the console and written to the output file, along with:
    • A local timestamp
    • The IP address (node ID) of the source node

File Structure

  • README.md: This comprehensive documentation file.
  • Makefile: Contains the build instructions for compiling the simulation project.
  • topo.txt: Defines the network topology configuration parameters.
  • Source code files (e.g., *.cc and *.h) that implement the simulation logic.
  • OMNeT++ NED files (e.g., *.ned) that define the network topology or enable dynamic module creation.
  • The config.py file, which dynamically generates the NED file based on the network topology specified in topo.txt.

Network Configuration

topo.txt

The topology file defines the network structure including the number of clients and their connections.

config.py

This script reads the topology file and dynamically generates the NED file that defines the network structure for the simulation.

Compilation and Execution Instructions

Prerequisites

  • OMNeT++ Installation:
    Ensure that OMNeT++ is installed on your system. For installation instructions, please refer to the OMNeT++ Install Guide.

  • C++ Compiler:
    A compatible C++ compiler is required to build the simulation project.

  • Python:
    Python is required to run the provided configuration script.

  • Environment Setup:
    Configure the necessary environment variables for OMNeT++.

Steps to Compile and Run the Simulation

  1. Open a terminal and navigate to the OMNeT++ installation root directory.

  2. Launch OMNeT++ by executing: bash

    omnetpp
    
  3. Within the OMNeT++ IDE, select the CNAssignment2 project.

  4. Update the network topology in the topo.txt file as needed, and run the provided Python script (e.g., config.py) to generate the Network.ned file: bash

    python config.py
    
  5. Finally, start the simulation by executing the omnetpp.ini file, which initiates the simulation process.

About

OMNeT++ simulation of P2P distributed computing with CHORD-inspired routing and gossip protocol for task distribution

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published